Skip to content

Commit

Permalink
Merge pull request #187 from datacite/schema-4.5-post-release
Browse files Browse the repository at this point in the history
Revert temporary mod to DC JSON publisher that only allowed publisher…
  • Loading branch information
svogt0511 authored Feb 26, 2024
2 parents 02e1860 + 300f8e9 commit 4912aaf
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
bolognese (2.1.0)
bolognese (2.1.1)
activesupport (>= 4.2.5)
benchmark_methods (~> 0.7)
bibtex-ruby (>= 5.1.0)
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 = "2.1.0"
VERSION = "2.1.1"
end
5 changes: 1 addition & 4 deletions lib/bolognese/writers/datacite_json_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ module Bolognese
module Writers
module DataciteJsonWriter
def datacite_json
# Remove the following change for the schema 4.5 release
if crosscite_hsh.present?
datacite_json_hsh = crosscite_hsh
datacite_json_hsh['publisher'] = self.publisher['name'] if self.publisher&.respond_to?(:to_hash) && self.publisher.has_key?('name') && !self.publisher['name'].blank?
JSON.pretty_generate datacite_json_hsh.transform_keys! { |key| key.camelcase(uppercase_first_letter = :lower) }
JSON.pretty_generate crosscite_hsh.transform_keys! { |key| key.camelcase(uppercase_first_letter = :lower) }
end
end
end
Expand Down
48 changes: 16 additions & 32 deletions spec/writers/datacite_json_writer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
"rightsIdentifierScheme"=>"SPDX",
"rightsUri"=>"https://creativecommons.org/licenses/by/3.0/legalcode",
"schemeUri"=>"https://spdx.org/licenses/"}])
# REVERT the publisher line to the commented line for the schema 4.5 release
# expect(datacite.fetch("publisher")).to eq({"name"=>"eLife Sciences Publications, Ltd"})
expect(datacite.fetch("publisher")).to eq("eLife Sciences Publications, Ltd")
expect(datacite.fetch("publisher")).to eq({"name"=>"eLife Sciences Publications, Ltd"})
end

it "with ORCID ID" do
Expand All @@ -31,9 +29,7 @@
expect(datacite.fetch("types")).to eq("bibtex"=>"article", "citeproc"=>"article-journal", "resourceType"=>"JournalArticle", "resourceTypeGeneral"=>"JournalArticle", "ris"=>"JOUR", "schemaOrg"=>"ScholarlyArticle")
expect(datacite.fetch("creators").length).to eq(7)
expect(datacite.fetch("creators").first).to eq("nameType"=>"Personal", "name"=>"Thanassi, Wendy", "givenName"=>"Wendy", "familyName"=>"Thanassi", "affiliation" => [{"name"=>"Department of Medicine, Veterans Affairs Palo Alto Health Care System, 3801 Miranda Avenue MC-, Palo Alto, CA 94304-1207, USA"}, {"name"=>"Occupational Health Strategic Health Care Group, Office of Public Health, Veterans Health Administration, Washington, DC 20006, USA"}, {"name"=>"Division of Emergency Medicine, Stanford University School of Medicine, Stanford, CA 94304, USA"}, {"name"=>"War Related Illness and Injury Study Center (WRIISC) and Mental Illness Research Education and Clinical Center (MIRECC), Department of Veterans Affairs, Palo Alto, CA 94304, USA"}])
# REVERT the publisher line to the commented line for the schema 4.5 release
# expect(datacite.fetch("publisher")).to eq({"name"=>"Hindawi Limited"})
expect(datacite.fetch("publisher")).to eq("Hindawi Limited")
expect(datacite.fetch("publisher")).to eq({"name"=>"Hindawi Limited"})
end

it "Crossref DOI" do
Expand All @@ -45,9 +41,7 @@
expect(datacite.dig("descriptions", 0, "description")).to start_with("Among various advantages, their small size makes model organisms preferred subjects of investigation.")
expect(datacite.fetch("creators").length).to eq(5)
expect(datacite.fetch("creators").first).to eq("nameType"=>"Personal", "name"=>"Sankar, Martial", "givenName"=>"Martial", "familyName"=>"Sankar")
# REVERT the publisher line to the commented line for the schema 4.5 release
# expect(datacite.fetch("publisher")).to eq({"name"=>"{eLife} Sciences Organisation, Ltd."})
expect(datacite.fetch("publisher")).to eq("{eLife} Sciences Organisation, Ltd.")
expect(datacite.fetch("publisher")).to eq({"name"=>"{eLife} Sciences Organisation, Ltd."})
end

it "BlogPosting Citeproc JSON" do
Expand All @@ -58,9 +52,7 @@
expect(datacite.fetch("titles")).to eq([{"title"=>"Eating your own Dog Food"}])
expect(datacite.dig("descriptions", 0, "description")).to start_with("Eating your own dog food")
expect(datacite.fetch("creators")).to eq([{"familyName"=>"Fenner", "givenName"=>"Martin", "name"=>"Fenner, Martin"}])
# REVERT the publisher line to the commented line for the schema 4.5 release
# expect(datacite.fetch("publisher")).to eq({"name"=>"DataCite"})
expect(datacite.fetch("publisher")).to eq("DataCite")
expect(datacite.fetch("publisher")).to eq({"name"=>"DataCite"})
end

it "rdataone" do
Expand All @@ -72,9 +64,7 @@
expect(datacite.fetch("creators").first).to eq("affiliation"=>[{"name"=>"NCEAS"}], "nameType"=>"Personal", "name" => "Jones, Matt",
"nameIdentifiers" => [{"nameIdentifier"=>"https://orcid.org/0000-0003-0077-4738", "nameIdentifierScheme"=>"ORCID", "schemeUri"=>"https://orcid.org"}], "givenName"=>"Matt", "familyName"=>"Jones")
expect(datacite.fetch("version")).to eq("2.0.0")
# REVERT the publisher line to the commented line for the schema 4.5 release
# expect(datacite.fetch("publisher")).to eq({"name"=>"https://cran.r-project.org"})
expect(datacite.fetch("publisher")).to eq("https://cran.r-project.org")
expect(datacite.fetch("publisher")).to eq({"name"=>"https://cran.r-project.org"})
end

it "maremma" do
Expand All @@ -90,9 +80,7 @@
[{"nameIdentifier"=>"https://orcid.org/0000-0003-0077-4738",
"nameIdentifierScheme"=>"ORCID", "schemeUri"=>"https://orcid.org"}],
"nameType"=>"Personal"}])
# REVERT the publisher line to the commented line for the schema 4.5 release
# expect(datacite.fetch("publisher")).to eq({"name"=>"DataCite"})
expect(datacite.fetch("publisher")).to eq("DataCite")
expect(datacite.fetch("publisher")).to eq({"name"=>"DataCite"})
end

it "with data citation schema.org" do
Expand All @@ -103,26 +91,22 @@
expect(datacite.fetch("titles")).to eq([{"title"=>"Eating your own Dog Food"}])
expect(datacite.fetch("relatedIdentifiers").count).to eq(3)
expect(datacite.fetch("relatedIdentifiers").first).to eq("relatedIdentifier"=>"10.5438/0000-00ss", "relatedIdentifierType"=>"DOI", "relationType"=>"IsPartOf", "resourceTypeGeneral"=>"Text")
# REVERT the publisher line to the commented line for the schema 4.5 release
# expect(datacite.fetch("publisher")).to eq({"name"=>"DataCite"})
expect(datacite.fetch("publisher")).to eq("DataCite")
expect(datacite.fetch("publisher")).to eq({"name"=>"DataCite"})
end

it "DataCite DOI with Schema 4.5 publisher attributes" do
input = fixture_path + "datacite-example-full-v4.5.xml"
subject = Bolognese::Metadata.new(input: input, from: "datacite")
datacite = JSON.parse(subject.datacite_json)
# REVERT the publisher line to the commented lines for the schema 4.5 release
# expect(datacite.fetch("publisher")).to eq(
# {
# "name" => "Example Publisher",
# "publisherIdentifier" => "https://ror.org/04z8jg394",
# "publisherIdentifierScheme" => "ROR",
# "schemeUri" => "https://ror.org/",
# "lang" => "en",
# },
# )
expect(datacite.fetch("publisher")).to eq("Example Publisher")
expect(datacite.fetch("publisher")).to eq(
{
"name" => "Example Publisher",
"publisherIdentifier" => "https://ror.org/04z8jg394",
"publisherIdentifierScheme" => "ROR",
"schemeUri" => "https://ror.org/",
"lang" => "en",
},
)
end
end
end

0 comments on commit 4912aaf

Please sign in to comment.