Skip to content

Commit

Permalink
Export submitted and available dates in CSL-JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
larsgw committed Oct 15, 2024
1 parent b3721a2 commit 72f6e99
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/bolognese/metadata_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ def citeproc_hsh
"author" => author,
"contributor" => to_citeproc(contributors),
"issued" => get_date(dates, "Issued") ? get_date_parts(get_date(dates, "Issued")) : get_date_parts(publication_year.to_s),
"submitted" => Array.wrap(dates).find { |d| d["dateType"] == "Submitted" }.to_h.fetch("__content__", nil),
"submitted" => get_date(dates, "Submitted") ? get_date_parts(get_date(dates, "Submitted")) : nil,
"available-date" => get_date(dates, "Available") ? get_date_parts(get_date(dates, "Available")) : nil,
"abstract" => parse_attributes(descriptions, content: "description", first: true),
"container-title" => container_title,
"DOI" => doi,
Expand Down
20 changes: 20 additions & 0 deletions spec/writers/citeproc_writer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,5 +286,25 @@
expect(json["DOI"]).to eq("10.34747/g6yb-3412")
expect(json["issued"]).to eq("date-parts"=>[[2019]])
end

it "arxiv" do
input = "https://doi.org/10.48550/arxiv.2410.00001"
subject = Bolognese::Metadata.new(input: input, from: "datacite")
json = JSON.parse(subject.citeproc)
expect(json["type"]).to eq("article")
expect(json["id"]).to eq("https://doi.org/10.48550/arxiv.2410.00001")
expect(json["DOI"]).to eq("10.48550/arxiv.2410.00001")
expect(json["URL"]).to eq("https://arxiv.org/abs/2410.00001")
expect(json["title"]).to eq("iSurgARy: A mobile augmented reality solution for ventriculostomy in resource-limited settings")
expect(json["author"]).to eq([{"family"=>"Asadi", "given"=>"Zahra"},
{"family"=>"Castillo", "given"=>"Joshua Pardillo"},
{"family"=>"Asadi", "given"=>"Mehrdad"},
{"family"=>"Sinclair", "given"=>"David S."},
{"family"=>"Kersten-Oertel", "given"=>"Marta"}])
expect(json["publisher"]).to eq("arXiv")
expect(json["issued"]).to eq("date-parts" => [[2024]])
expect(json["available-date"]).to eq("date-parts" => [[2024, 10]])
expect(json["submitted"]).to eq("date-parts" => [[2024, 9, 12]])
end
end
end

0 comments on commit 72f6e99

Please sign in to comment.