Skip to content

Commit

Permalink
format crossref xml
Browse files Browse the repository at this point in the history
  • Loading branch information
mfenner committed Jan 9, 2024
1 parent 4503b62 commit 18c8904
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 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:
commonmeta-ruby (3.8.1)
commonmeta-ruby (3.8.2)
activesupport (>= 4.2.5, < 8.0)
addressable (~> 2.8.1, < 2.8.2)
base32-url (>= 0.7.0, < 1)
Expand Down
6 changes: 4 additions & 2 deletions lib/commonmeta/crossref_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,10 @@ def insert_doi_data(xml)
xml.collection("property" => "text-mining") do
xml.item do
xml.resource(url, "mime_type" => "text/html")
if is_rogue_scholar_doi?(doi)
Array.wrap(files).each do |file|
end
if is_rogue_scholar_doi?(doi)
Array.wrap(files).each do |file|
xml.item do
# Crossref schema currently doesn't support text/markdown
file["mimeType"] = "text/plain" if file["mimeType"] == "text/markdown"
xml.resource(file["url"], "mime_type" => file["mimeType"])
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.8.1'
VERSION = '3.8.2'
end
33 changes: 16 additions & 17 deletions spec/writers/crossref_xml_writer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,8 @@
"title")).to eq("Attempts at automating journal subject classification")
expect(crossref_xml.dig("item_number")).to eq("__content__" => "5d14ffacb9ac4e20bdc0d9248df4e80d", "item_number_type" => "uuid")
expect(crossref_xml.dig("group_title")).to eq("Humanities")
expect(crossref_xml.dig("doi_data", "collection", "item", "resource").length).to eq(4)
expect(crossref_xml.dig("doi_data", "collection", "item", "resource", 2)).to eq("__content__" => "https://api.rogue-scholar.org/posts/10.54900/n6dnt-xpq48.pdf", "mime_type" => "application/pdf")

expect(crossref_xml.dig("doi_data", "collection", "item").length).to eq(4)
expect(crossref_xml.dig("doi_data", "collection", "item", 2, "resource")).to eq("__content__" => "https://api.rogue-scholar.org/posts/10.54900/n6dnt-xpq48.pdf", "mime_type" => "application/pdf")
end

it "json_feed_item with references" do
Expand Down Expand Up @@ -267,8 +266,8 @@
expect(crossref_xml.dig("citation_list", "citation").last).to eq("article_title" => "The Research Software Alliance (ReSA) and the community landscape", "cYear" => "2020", "doi" => "10.5281/zenodo.3699950", "key" => "ref11")
expect(crossref_xml.dig("item_number")).to eq("__content__" => "954f81380ecd409087c5cef1297f1470", "item_number_type" => "uuid")
expect(crossref_xml.dig("group_title")).to eq("Humanities")
expect(crossref_xml.dig("doi_data", "collection", "item", "resource").length).to eq(4)
expect(crossref_xml.dig("doi_data", "collection", "item", "resource", 2)).to eq("__content__" => "https://api.rogue-scholar.org/posts/10.54900/zwm7q-vet94.pdf", "mime_type" => "application/pdf")
expect(crossref_xml.dig("doi_data", "collection", "item").length).to eq(4)
expect(crossref_xml.dig("doi_data", "collection", "item", 2, "resource")).to eq("__content__" => "https://api.rogue-scholar.org/posts/10.54900/zwm7q-vet94.pdf", "mime_type" => "application/pdf")
end

it "json_feed_item from rogue scholar with doi" do
Expand Down Expand Up @@ -298,8 +297,8 @@
"title")).to eq("EU-Mitgliedstaaten betonen die Rolle von wissenschaftsgeleiteten Open-Access-Modellen jenseits von APCs")
expect(crossref_xml.dig("item_number")).to eq("__content__" => "1c57855813244493b8af84c49eabc52f", "item_number_type" => "uuid")
expect(crossref_xml.dig("group_title")).to eq("Social sciences")
expect(crossref_xml.dig("doi_data", "collection", "item", "resource").length).to eq(4)
expect(crossref_xml.dig("doi_data", "collection", "item", "resource", 2)).to eq("__content__" => "https://api.rogue-scholar.org/posts/10.59350/9ry27-7cz42.pdf", "mime_type" => "application/pdf")
expect(crossref_xml.dig("doi_data", "collection", "item").length).to eq(4)
expect(crossref_xml.dig("doi_data", "collection", "item", 2, "resource")).to eq("__content__" => "https://api.rogue-scholar.org/posts/10.59350/9ry27-7cz42.pdf", "mime_type" => "application/pdf")
end

it "json_feed_item from rogue scholar with organizational author" do
Expand Down Expand Up @@ -328,8 +327,8 @@
"title")).to eq("KU Leuven supports ResearchEquals")
expect(crossref_xml.dig("item_number")).to eq("__content__" => "5561f8e42ff14186a8d58dacb3afe414", "item_number_type" => "uuid")
expect(crossref_xml.dig("group_title")).to eq("Social sciences")
expect(crossref_xml.dig("doi_data", "collection", "item", "resource").length).to eq(4)
expect(crossref_xml.dig("doi_data", "collection", "item", "resource", 2)).to eq("__content__" => "https://api.rogue-scholar.org/posts/10.59350/9ry27-7cz42.pdf", "mime_type" => "application/pdf")
expect(crossref_xml.dig("doi_data", "collection", "item").length).to eq(4)
expect(crossref_xml.dig("doi_data", "collection", "item", 2, "resource")).to eq("__content__" => "https://api.rogue-scholar.org/posts/10.59350/9ry27-7cz42.pdf", "mime_type" => "application/pdf")
end

it "json_feed_item from rogue scholar with archived content" do
Expand Down Expand Up @@ -369,8 +368,8 @@
"title")).to eq("ORCID Integration Series: PANGAEA")
expect(crossref_xml.dig("item_number")).to eq("__content__" => "570c8129e86749e68517bd783627e76e", "item_number_type" => "uuid")
expect(crossref_xml.dig("group_title")).to eq("Computer and information sciences")
expect(crossref_xml.dig("doi_data", "collection", "item", "resource").length).to eq(4)
expect(crossref_xml.dig("doi_data", "collection", "item", "resource", 2)).to eq("__content__" => "https://api.rogue-scholar.org/posts/10.59350/faeph-x4x84.pdf", "mime_type" => "application/pdf")
expect(crossref_xml.dig("doi_data", "collection", "item").length).to eq(4)
expect(crossref_xml.dig("doi_data", "collection", "item", 2, "resource")).to eq("__content__" => "https://api.rogue-scholar.org/posts/10.59350/faeph-x4x84.pdf", "mime_type" => "application/pdf")
end

it "json_feed_item from rogue scholar with relations" do
Expand Down Expand Up @@ -408,8 +407,8 @@
"title")).to eq("Differences between ORCID and DataCite Metadata")
expect(crossref_xml.dig("item_number")).to eq("__content__" => "8a4de44333474b82b57de3c82b6485fc", "item_number_type" => "uuid")
expect(crossref_xml.dig("group_title")).to eq("Computer and information sciences")
expect(crossref_xml.dig("doi_data", "collection", "item", "resource").length).to eq(4)
expect(crossref_xml.dig("doi_data", "collection", "item", "resource", 2)).to eq("__content__" => "https://api.rogue-scholar.org/posts/10.53731/r79v4e1-97aq74v-ag578.pdf", "mime_type" => "application/pdf")
expect(crossref_xml.dig("doi_data", "collection", "item").length).to eq(4)
expect(crossref_xml.dig("doi_data", "collection", "item", 2, "resource")).to eq("__content__" => "https://api.rogue-scholar.org/posts/10.53731/r79v4e1-97aq74v-ag578.pdf", "mime_type" => "application/pdf")
end

it "json_feed_item from rogue scholar with relations and funding" do
Expand Down Expand Up @@ -446,8 +445,8 @@
"title")).to eq("Tracking the Growth of the PID Graph")
expect(crossref_xml.dig("item_number")).to eq("__content__" => "e58dc9c8b8704db28896238b3246c551", "item_number_type" => "uuid")
expect(crossref_xml.dig("group_title")).to eq("Computer and information sciences")
expect(crossref_xml.dig("doi_data", "collection", "item", "resource").length).to eq(4)
expect(crossref_xml.dig("doi_data", "collection", "item", "resource", 2)).to eq("__content__" => "https://api.rogue-scholar.org/posts/10.53731/r79s4nh-97aq74v-ag4t1.pdf", "mime_type" => "application/pdf")
expect(crossref_xml.dig("doi_data", "collection", "item").length).to eq(4)
expect(crossref_xml.dig("doi_data", "collection", "item", 2, "resource")).to eq("__content__" => "https://api.rogue-scholar.org/posts/10.53731/r79s4nh-97aq74v-ag4t1.pdf", "mime_type" => "application/pdf")
end

it "json_feed_item from rogue scholar with anonymous author" do
Expand Down Expand Up @@ -481,8 +480,8 @@
"title")).to eq("Welcome to the Lab")
expect(crossref_xml.dig("item_number")).to eq("__content__" => "a163e3405b3c47369ab08c54fdff6a3c", "item_number_type" => "uuid")
expect(crossref_xml.dig("group_title")).to eq("Computer and information sciences")
expect(crossref_xml.dig("doi_data", "collection", "item", "resource").length).to eq(4)
expect(crossref_xml.dig("doi_data", "collection", "item", "resource", 2)).to eq("__content__" => "https://api.rogue-scholar.org/posts/10.59350/9ry27-7cz42.pdf", "mime_type" => "application/pdf")
expect(crossref_xml.dig("doi_data", "collection", "item").length).to eq(4)
expect(crossref_xml.dig("doi_data", "collection", "item", 2, "resource")).to eq("__content__" => "https://api.rogue-scholar.org/posts/10.59350/9ry27-7cz42.pdf", "mime_type" => "application/pdf")
end
end
end

0 comments on commit 18c8904

Please sign in to comment.