Skip to content

Commit

Permalink
enable archive location in crossref metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
mfenner committed Nov 4, 2023
1 parent f64fa7e commit 0dd5f8e
Show file tree
Hide file tree
Showing 11 changed files with 307 additions and 34 deletions.
25 changes: 12 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
commonmeta-ruby (3.6.1)
commonmeta-ruby (3.7.0)
activesupport (>= 4.2.5, < 8.0)
addressable (~> 2.8.1, < 2.8.2)
base32-url (>= 0.7.0, < 1)
Expand All @@ -27,7 +27,7 @@ PATH
GEM
remote: https://rubygems.org/
specs:
activesupport (7.1.0)
activesupport (7.1.1)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
Expand Down Expand Up @@ -128,7 +128,7 @@ GEM
ffi-compiler (~> 1.0)
rake (~> 13.0)
logutils (0.6.1)
loofah (2.21.3)
loofah (2.21.4)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
matrix (0.4.2)
Expand All @@ -151,12 +151,12 @@ GEM
props (1.2.0)
iniparser (>= 0.1.0)
public_suffix (4.0.7)
racc (1.7.1)
racc (1.7.3)
rack (3.0.8)
rack-test (2.1.0)
rack (>= 1.3)
rainbow (3.1.1)
rake (13.0.6)
rake (13.1.0)
rdf (3.3.1)
bcp47_spec (~> 0.2)
link_header (~> 0.0, >= 0.0.8)
Expand All @@ -171,7 +171,7 @@ GEM
rdf-xsd (3.3.0)
rdf (~> 3.3)
rexml (~> 3.2)
regexp_parser (2.8.1)
regexp_parser (2.8.2)
rexml (3.2.6)
rspec (3.12.0)
rspec-core (~> 3.12.0)
Expand All @@ -189,19 +189,18 @@ GEM
rspec-xsd (0.1.0)
nokogiri (~> 1.6)
rspec (~> 3)
rubocop (1.56.4)
base64 (~> 0.1.1)
rubocop (1.57.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
parser (>= 3.2.2.4)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-capybara (2.19.0)
rubocop (~> 1.41)
Expand All @@ -212,8 +211,8 @@ GEM
rubocop-ast (>= 0.4.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
rubocop-rspec (2.24.1)
rubocop (~> 1.33)
rubocop-rspec (2.25.0)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
ruby-progressbar (1.13.0)
Expand All @@ -236,7 +235,7 @@ GEM
logutils (>= 0.6.1)
props (>= 1.1.2)
rubyzip (>= 1.0.0)
thor (1.2.2)
thor (1.3.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unf (0.1.4)
Expand Down
12 changes: 12 additions & 0 deletions lib/commonmeta/crossref_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def insert_journal(xml)
insert_funding_references(xml)
insert_crossref_access_indicators(xml)
insert_crossref_relations(xml)
insert_archive_locations(xml)
insert_doi_data(xml)
insert_citation_list(xml)
end
Expand All @@ -85,6 +86,7 @@ def insert_posted_content(xml)
insert_funding_references(xml)
insert_crossref_access_indicators(xml)
insert_crossref_relations(xml)
insert_archive_locations(xml)
insert_doi_data(xml)
insert_citation_list(xml)
end
Expand Down Expand Up @@ -327,6 +329,16 @@ def insert_item_number(xml)
end
end

def insert_archive_locations(xml)
return xml if archive_locations.blank?

xml.archive_locations do
archive_locations.each do |archive_location|
xml.archive("name" => archive_location)
end
end
end

def insert_doi_data(xml)
return xml if doi_from_url(id).blank? || url.blank?

Expand Down
6 changes: 5 additions & 1 deletion lib/commonmeta/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Metadata
:email, :registrant
attr_reader :doc, :page_start, :page_end
attr_writer :id, :provider_id, :client_id, :doi, :alternate_identifiers, :contributors,
:titles, :publisher, :license, :date, :volume, :url, :version, :subjects, :descriptions, :language, :sizes, :formats, :schema_version, :meta, :container, :provider, :format, :funding_references, :state, :geo_locations, :type, :additional_type, :files, :references, :related_identifiers, :related_items, :style, :locale
:titles, :publisher, :license, :date, :volume, :url, :version, :subjects, :descriptions, :language, :sizes, :formats, :schema_version, :meta, :container, :provider, :format, :funding_references, :state, :geo_locations, :type, :additional_type, :files, :references, :related_identifiers, :related_items, :style, :locale, :archive_locations

def initialize(options = {})
options.symbolize_keys!
Expand Down Expand Up @@ -253,5 +253,9 @@ def titles
def contributors
@contributors ||= meta.fetch('contributors', nil)
end

def archive_locations
@archive_locations ||= meta.fetch('archive_locations', nil)
end
end
end
14 changes: 14 additions & 0 deletions lib/commonmeta/readers/json_feed_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ def read_json_feed_item(string: nil, **options)
funding_references = get_funding_references(meta)
related_identifiers = get_related_identifiers(meta)
alternate_identifiers = [{ "alternateIdentifier" => meta["id"], "alternateIdentifierType" => "UUID" }]

archive_url = meta.fetch("archive_url", nil)

if archive_url
host = URI.parse(archive_url).host
if ["web.archive.org", "wayback.archive-it.org"].include?(host)
archive_locations = ["Internet Archive"]
else
archive_locations = nil
end
else
archive_locations = nil
end

{ "id" => id,
"type" => type,
Expand All @@ -86,6 +99,7 @@ def read_json_feed_item(string: nil, **options)
"funding_references" => funding_references.presence,
"related_identifiers" => related_identifiers.presence,
"alternate_identifiers" => alternate_identifiers,
"archive_locations" => archive_locations,
"state" => state }.compact.merge(read_options)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/commonmeta/schema_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

module Commonmeta
module SchemaUtils
COMMONMETA = File.read(File.expand_path("../../resources/commonmeta_v0.10.3.json",
COMMONMETA = File.read(File.expand_path("../../resources/commonmeta_v0.10.4.json",
__dir__))

def json_schema_errors
Expand Down
2 changes: 1 addition & 1 deletion lib/commonmeta/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Commonmeta
VERSION = '3.6.1'
VERSION = '3.7.0'
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://commonmeta.org/commonmeta_v0.10.3.json",
"title": "Commonmeta v0.10.3",
"$id": "https://commonmeta.org/commonmeta_v0.10.4.json",
"title": "Commonmeta v0.10.4",
"description": "JSON representation of the Commonmeta schema.",
"additionalProperties": false,
"definitions": {
Expand Down Expand Up @@ -516,6 +516,15 @@
"description": "The state of the resource.",
"type": "string",
"enum": ["findable", "not_found"]
},
"archive_locations": {
"description": "The location where content is archived.",
"type": "array",
"items": {
"type": "string",
"enum": ["CLOCKSS", "Internet Archive", "KB", "LOCKSS", "Portico", "Other"]
},
"uniqueItems": true
}
},
"required": [
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0dd5f8e

Please sign in to comment.