Skip to content

Commit

Permalink
support publisher for posted content #100
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jul 29, 2020
1 parent ca6bfd3 commit b59b2fd
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 6 deletions.
7 changes: 4 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
bolognese (1.8.2)
bolognese (1.8.3)
activesupport (>= 4.2.5)
benchmark_methods (~> 0.7)
bibtex-ruby (>= 5.1.0)
Expand Down Expand Up @@ -58,7 +58,8 @@ GEM
csl (~> 1.0)
diff-lcs (1.4.4)
docile (1.3.2)
ebnf (2.1.0)
ebnf (2.1.1)
htmlentities (~> 4.3)
rdf (~> 3.1)
scanf (~> 1.0)
sxp (~> 1.1)
Expand Down Expand Up @@ -120,7 +121,7 @@ GEM
namae (1.0.1)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
oj (3.10.7)
oj (3.10.8)
oj_mimic_json (1.0.1)
optimist (3.0.1)
postrank-uri (1.0.24)
Expand Down
3 changes: 2 additions & 1 deletion lib/bolognese/readers/crossref_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def read_crossref(string: nil, **options)
journal_issue = {}
journal_metadata = nil
publisher = query.dig("crm_item", 0)
publisher = nil unless publisher.is_a?(String)

case model
when "book"
Expand Down Expand Up @@ -69,7 +70,7 @@ def read_crossref(string: nil, **options)
end
when "posted_content"
bibliographic_metadata = meta.dig("crossref", "posted_content").to_h
publisher = bibliographic_metadata.dig("institution", "institution_name")
publisher ||= bibliographic_metadata.dig("institution", "institution_name")
when "sa_component"
bibliographic_metadata = meta.dig("crossref", "sa_component", "component_list", "component").to_h
related_identifier = Array.wrap(query.to_h["crm_item"]).find { |cr| cr["name"] == "relation" }
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.8.2"
VERSION = "1.8.3"
end

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

23 changes: 22 additions & 1 deletion spec/readers/crossref_reader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
expect(subject.descriptions.first["description"]).to start_with("This article presents a practical roadmap")
expect(subject.dates).to include({"date"=>"2017-10-09", "dateType"=>"Issued"})
expect(subject.publication_year).to eq("2017")
expect(subject.publisher).to eq("bioRxiv")
expect(subject.publisher).to eq("Cold Spring Harbor Laboratory")
expect(subject.agency).to eq("Crossref")
end

Expand Down Expand Up @@ -602,6 +602,27 @@
expect(subject.date_registered).to eq("2019-11-02T09:30:06Z")
end

it "posted content copernicus" do
input = "https://doi.org/10.5194/CP-2020-95"
subject = Bolognese::Metadata.new(input: input)
expect(subject.valid?).to be true
expect(subject.url).to eq("https://cp.copernicus.org/preprints/cp-2020-95/")
expect(subject.types).to eq("bibtex"=>"article", "citeproc"=>"article-journal", "resourceType"=>"PostedContent", "resourceTypeGeneral"=>"Text", "ris"=>"JOUR", "schemaOrg"=>"ScholarlyArticle")
expect(subject.creators.count).to eq(6)
expect(subject.creators.first).to eq("nameType" => "Personal", "familyName" => "Shao",
"givenName" => "Jun",
"name" => "Shao, Jun",
"nameIdentifiers" => [{"nameIdentifier"=>"https://orcid.org/0000-0001-6130-6474", "nameIdentifierScheme"=>"ORCID", "schemeUri"=>"https://orcid.org"}])
expect(subject.titles).to eq([{"title"=>"The Atmospheric Bridge Communicated the δ<sup>13</sup>C Declineduring the Last Deglaciation to the Global Upper Ocean"}])
expect(subject.id).to eq("https://doi.org/10.5194/cp-2020-95")
expect(subject.identifiers).to be_empty
expect(subject.descriptions.first["description"]).to start_with("Abstract. During the early last glacial termination")
expect(subject.dates).to include({"date"=>"2020-07-28", "dateType"=>"Issued"})
expect(subject.publication_year).to eq("2020")
expect(subject.publisher).to eq("Copernicus GmbH")
expect(subject.agency).to eq("Crossref")
end

it "journal issue" do
input = "https://doi.org/10.6002/ect.2015.0371"
subject = Bolognese::Metadata.new(input: input)
Expand Down

0 comments on commit b59b2fd

Please sign in to comment.