Skip to content

Commit

Permalink
don't support alternate_identifiers internally
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jul 12, 2020
1 parent 2228c1b commit 5c57c15
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 11 deletions.
7 changes: 5 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
bolognese (1.7.1)
bolognese (1.7.2)
activesupport (>= 4.2.5)
benchmark_methods (~> 0.7)
bibtex-ruby (>= 5.1.0)
Expand All @@ -14,7 +14,7 @@ PATH
faraday (~> 0.17.3)
gender_detector (~> 0.1.2)
iso8601 (~> 0.9.1)
json-ld (~> 3.1, >= 3.1.4)
json-ld-preloaded (~> 3.1, >= 3.1.3)
jsonlint (~> 0.3.0)
loofah (~> 2.0, >= 2.0.3)
maremma (>= 4.7, < 5)
Expand Down Expand Up @@ -90,6 +90,9 @@ GEM
multi_json (~> 1.14)
rack (~> 2.0)
rdf (~> 3.1)
json-ld-preloaded (3.1.3)
json-ld (~> 3.1)
rdf (~> 3.1)
jsonlint (0.3.0)
oj (~> 3)
optimist (~> 3)
Expand Down
2 changes: 1 addition & 1 deletion bolognese.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Gem::Specification.new do |s|
s.add_dependency 'csl-styles', '~> 1.0', '>= 1.0.1.10'
s.add_dependency 'iso8601', '~> 0.9.1'
s.add_dependency 'postrank-uri', '~> 1.0', '>= 1.0.18'
s.add_dependency 'json-ld', '~> 3.1', '>= 3.1.4'
s.add_dependency 'json-ld-preloaded', '~> 3.1', '>= 3.1.3'
s.add_dependency 'jsonlint', '~> 0.3.0'
s.add_dependency 'oj', '~> 3.10'
s.add_dependency "oj_mimic_json", "~> 1.0", ">= 1.0.1"
Expand Down
9 changes: 2 additions & 7 deletions lib/bolognese/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Metadata

attr_accessor :string, :from, :sandbox, :meta, :regenerate, :issue, :show_errors
attr_reader :doc, :page_start, :page_end
attr_writer :id, :provider_id, :client_id, :doi, :identifiers, :alternate_identifiers, :creators, :contributors, :titles, :publisher,
attr_writer :id, :provider_id, :client_id, :doi, :identifiers, :creators, :contributors, :titles, :publisher,
:rights_list, :dates, :publication_year, :volume, :url, :version_info,
:subjects, :contributor, :descriptions, :language, :sizes,
:formats, :schema_version, :meta, :container, :agency,
Expand Down Expand Up @@ -99,7 +99,6 @@ def initialize(input: nil, from: nil, **options)
:titles,
:types,
:identifiers,
:alternate_identifiers,
:container,
:publisher,
:funding_references,
Expand Down Expand Up @@ -216,11 +215,7 @@ def publisher
end

def identifiers
@identifiers ||= Array.wrap(@alternate_identifiers).map { |a| { "identifierType" => a["alternateIdentifierType"], "identifier" => a["alternateIdentifier"] } }.presence || meta.fetch("identifiers", nil)
# (Array.wrap(@identifiers) +
# Array.wrap(@alternate_identifiers).select { |r| r["alternateIdentifierType"] != "DOI" }.map do |a|
# { "identifierType" => a["alternateIdentifierType"], "identifier" => a["alternateIdentifier"] }
# end).uniq ||= meta.fetch("identifiers", nil)
@identifiers ||= meta.fetch("identifiers", nil)
end

def content_url
Expand Down
2 changes: 1 addition & 1 deletion lib/bolognese/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Bolognese
VERSION = "1.7.1"
VERSION = "1.7.2"
end

Large diffs are not rendered by default.

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions spec/writers/datacite_writer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,17 @@
expect(subject.state).to eq("registered")
end

it "change identifiers" do
input = "10.7554/eLife.01567"
subject = Bolognese::Metadata.new(input: input, from: "crossref")
expect(subject.valid?).to be true
expect(subject.identifiers).to eq( [{"identifier"=>"e01567", "identifierType"=>"Publisher ID"}])
subject.identifiers = [{ "identifierType" => "Publisher ID", "identifier" => "abc" }]
datacite = Maremma.from_xml(subject.datacite).fetch("resource", {})
expect(datacite.dig("identifier", "__content__")).to eq("10.7554/elife.01567")
expect(subject.identifiers).to eq([{"identifier"=>"abc", "identifierType"=>"Publisher ID"}])
end

it "validates against schema" do
input = "10.7554/eLife.01567"
subject = Bolognese::Metadata.new(input: input, from: "crossref")
Expand Down

0 comments on commit 5c57c15

Please sign in to comment.