require 'spec_helper' describe Bolognese::Metadata, vcr: true do context "write metadata as bibtex" do it "with data citation" do input = "10.7554/eLife.01567" subject = Bolognese::Metadata.new(input: input, from: "crossref") bibtex = BibTeX.parse(subject.bibtex).to_a(quotes: '').first expect(bibtex[:bibtex_type].to_s).to eq("article") expect(bibtex[:bibtex_key]).to eq("https://doi.org/10.7554/elife.01567") expect(bibtex[:doi]).to eq("10.7554/eLife.01567") expect(bibtex[:url]).to eq("http://elifesciences.org/lookup/doi/10.7554/eLife.01567") expect(bibtex[:title]).to eq("Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth") expect(bibtex[:author]).to eq("Sankar, Martial and Nieminen, Kaisa and Ragni, Laura and Xenarios, Ioannis and Hardtke, Christian S") expect(bibtex[:journal]).to eq("eLife") expect(bibtex[:year]).to eq("2014") end it "with pages" do input = "https://doi.org/10.1155/2012/291294" subject = Bolognese::Metadata.new(input: input, from: "crossref") bibtex = BibTeX.parse(subject.bibtex).to_a(quotes: '').first expect(bibtex[:bibtex_type].to_s).to eq("article") expect(bibtex[:bibtex_key]).to eq("https://doi.org/10.1155/2012/291294") expect(bibtex[:doi]).to eq("10.1155/2012/291294") expect(bibtex[:url]).to eq("http://www.hindawi.com/journals/pm/2012/291294/") expect(bibtex[:title]).to eq("Delineating a Retesting Zone Using Receiver Operating Characteristic Analysis on Serial QuantiFERON Tuberculosis Test Results in US Healthcare Workers") expect(bibtex[:author]).to eq("Thanassi, Wendy and Noda, Art and Hernandez, Beatriz and Newell, Jeffery and Terpeluk, Paul and Marder, David and Yesavage, Jerome A.") expect(bibtex[:journal]).to eq("Pulmonary Medicine") expect(bibtex[:pages]).to eq("1-7") expect(bibtex[:year]).to eq("2012") end it "text" do input = "https://doi.org/10.17173/PRETEST8" subject = Bolognese::Metadata.new(input: input, from: "datacite") bibtex = BibTeX.parse(subject.bibtex).to_a(quotes: '').first expect(bibtex[:bibtex_type].to_s).to eq("article") expect(bibtex[:bibtex_key]).to eq("https://doi.org/10.17173/pretest8") expect(bibtex[:doi]).to eq("10.17173/pretest8") expect(bibtex[:title]).to eq("PIAAC-Longitudinal (PIAAC-L) 2015") end it "maremma" do input = "https://github.com/datacite/maremma" subject = Bolognese::Metadata.new(input: input, from: "codemeta") bibtex = BibTeX.parse(subject.bibtex).to_a(quotes: '').first expect(bibtex[:bibtex_type].to_s).to eq("misc") expect(bibtex[:bibtex_key]).to eq("https://doi.org/10.5438/qeg0-3gm3") expect(bibtex[:doi]).to eq("10.5438/qeg0-3gm3") expect(bibtex[:url]).to eq("https://github.com/datacite/maremma") expect(bibtex[:title]).to eq("Maremma: a Ruby library for simplified network calls") expect(bibtex[:author]).to eq("Fenner, Martin") expect(bibtex[:publisher]).to eq("DataCite") expect(bibtex[:keywords]).to eq("faraday, excon, net/http") expect(bibtex[:year]).to eq("2017") end it "BlogPosting from string" do input = fixture_path + "datacite.json" subject = Bolognese::Metadata.new(input: input, from: "datacite_json") bibtex = BibTeX.parse(subject.bibtex).to_a(quotes: '').first expect(bibtex[:bibtex_type].to_s).to eq("article") expect(bibtex[:bibtex_key]).to eq("https://doi.org/10.5438/4k3m-nyvg") expect(bibtex[:doi]).to eq("10.5438/4K3M-NYVG") expect(bibtex[:title]).to eq("Eating your own Dog Food") expect(bibtex[:author]).to eq("Fenner, Martin") expect(bibtex[:publisher]).to eq("DataCite") expect(bibtex[:year]).to eq("2016") end it "BlogPosting" do input = "https://doi.org/10.5438/4K3M-NYVG" subject = Bolognese::Metadata.new(input: input, from: "datacite") bibtex = BibTeX.parse(subject.bibtex).to_a(quotes: '').first expect(bibtex[:bibtex_type].to_s).to eq("article") expect(bibtex[:bibtex_key]).to eq("https://doi.org/10.5438/4k3m-nyvg") expect(bibtex[:doi]).to eq("10.5438/4k3m-nyvg") expect(bibtex[:title]).to eq("Eating your own Dog Food") expect(bibtex[:author]).to eq("Fenner, Martin") expect(bibtex[:publisher]).to eq("DataCite") expect(bibtex[:year]).to eq("2016") end it "Dataset" do input = "https://doi.org/10.5061/dryad.8515" subject = Bolognese::Metadata.new(input: input, from: "datacite") bibtex = BibTeX.parse(subject.bibtex).to_a(quotes: '').first expect(bibtex[:bibtex_type].to_s).to eq("misc") expect(bibtex[:bibtex_key]).to eq("https://doi.org/10.5061/dryad.8515") expect(bibtex[:doi]).to eq("10.5061/dryad.8515") expect(bibtex[:title]).to eq("Data from: A new malaria agent in African hominids.") expect(bibtex[:author]).to eq("Ollomo, Benjamin and Durand, Patrick and Prugnolle, Franck and Douzery, Emmanuel J. P. and Arnathau, Céline and Nkoghe, Dieudonné and Leroy, Eric and Renaud, François") expect(bibtex[:publisher]).to eq("Dryad Digital Repository") expect(bibtex[:year]).to eq("2011") end it "from schema_org" do input = "https://blog.datacite.org/eating-your-own-dog-food/" subject = Bolognese::Metadata.new(input: input, from: "schema_org") bibtex = BibTeX.parse(subject.bibtex).to_a(quotes: '').first expect(bibtex[:bibtex_type].to_s).to eq("article") expect(bibtex[:bibtex_key]).to eq("https://doi.org/10.5438/4k3m-nyvg") expect(bibtex[:doi]).to eq("10.5438/4k3m-nyvg") expect(bibtex[:title]).to eq("Eating your own Dog Food") expect(bibtex[:author]).to eq("Fenner, Martin") expect(bibtex[:publisher]).to eq("DataCite") expect(bibtex[:keywords]).to eq("datacite, doi, metadata, featured") expect(bibtex[:year]).to eq("2016") end end end