Skip to content

Commit

Permalink
properly support formatted software citation. #95
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jun 23, 2020
1 parent ae2b790 commit eda241a
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
bolognese (1.6.5)
bolognese (1.6.6)
activesupport (>= 4.2.5)
benchmark_methods (~> 0.7)
bibtex-ruby (>= 5.1.0)
Expand Down Expand Up @@ -56,7 +56,7 @@ GEM
namae (~> 1.0)
csl-styles (1.0.1.10)
csl (~> 1.0)
diff-lcs (1.3)
diff-lcs (1.4.1)
docile (1.3.2)
ebnf (1.2.0)
rdf (~> 3.1)
Expand Down
8 changes: 7 additions & 1 deletion lib/bolognese/metadata_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,14 @@ def citeproc_hsh
author = to_citeproc(creators)
end

if types["resourceTypeGeneral"] == "Software" && version_info.present?
type = "book"
else
type = types["citeproc"]
end

{
"type" => types["citeproc"],
"type" => type,
"id" => normalize_doi(doi),
"categories" => Array.wrap(subjects).map { |k| parse_attributes(k, content: "subject", first: true) }.presence,
"language" => language,
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.6.5"
VERSION = "1.6.6"
end

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

8 changes: 8 additions & 0 deletions spec/writers/citation_writer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,13 @@
subject = Bolognese::Metadata.new(input: input, from: "crossref")
expect(subject.citation).to eq("Alexander Kohls, &amp; Salvatore Mele. (2018). Converting the Literature of a Scientific Field to Open Access through Global Collaboration: The Experience of SCOAP3 in Particle Physics. <i>Publications</i>, <i>6</i>(2), 15. https://doi.org/10.3390/publications6020015")
end

it "software w/version" do
input = "https://doi.org/10.5281/zenodo.2598836"
subject = Bolognese::Metadata.new(input: input, from: "datacite")
expect(subject.style).to eq("apa")
expect(subject.locale).to eq("en-US")
expect(subject.citation).to eq("Lab For Exosphere And Near Space Environment Studies. (2019). <i>lenses-lab/LYAO_RT-2018JA026426: Original Release</i> (Version 1.0.0) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.2598836")
end
end
end
4 changes: 2 additions & 2 deletions spec/writers/citeproc_writer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
input = "https://doi.org/10.5281/zenodo.2598836"
subject = Bolognese::Metadata.new(input: input, from: "datacite")
json = JSON.parse(subject.citeproc)
expect(json["type"]).to eq("article")
expect(json["type"]).to eq("book")
expect(json["DOI"]).to eq("10.5281/zenodo.2598836")
expect(json["version"]).to eq("1.0.0")
expect(json["copyright"]).to eq("Open Access")
Expand All @@ -111,7 +111,7 @@
input = fixture_path + "datacite_software_version.json"
subject = Bolognese::Metadata.new(input: input, from: "datacite_json")
json = JSON.parse(subject.citeproc)
expect(json["type"]).to eq("article")
expect(json["type"]).to eq("book")
expect(json["DOI"]).to eq("10.5281/ZENODO.2598836")
expect(json["version"]).to eq("1.0.0")
expect(json["copyright"]).to eq("Open Access")
Expand Down

0 comments on commit eda241a

Please sign in to comment.