Skip to content

Commit

Permalink
use symbolize keys instead of indifferent access
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jul 14, 2020
1 parent a33dbe2 commit 3ead12e
Show file tree
Hide file tree
Showing 30 changed files with 321 additions and 321 deletions.
2 changes: 1 addition & 1 deletion lib/bolognese/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __print_version
method_option :locale, aliases: "-l", default: "en-US"
method_option :show_errors, :type => :boolean, :force => false
def convert(input)
metadata = Metadata.new(input,
metadata = Metadata.new(input: input,
from: options[:from],
regenerate: options[:regenerate],
style: options[:style],
Expand Down
28 changes: 14 additions & 14 deletions spec/author_utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
describe Bolognese::Metadata, vcr: true do
let(:input) { "https://doi.org/10.1101/097196" }

subject { Bolognese::Metadata.new(input, from: "crossref") }
subject { Bolognese::Metadata.new(input: input, from: "crossref") }

context "is_personal_name?" do
it "has type organization" do
Expand Down Expand Up @@ -46,55 +46,55 @@
context "get_one_author" do
it "has familyName" do
input = "https://doi.org/10.5438/4K3M-NYVG"
subject = Bolognese::Metadata.new(input, from: "datacite")
subject = Bolognese::Metadata.new(input: input, from: "datacite")
meta = Maremma.from_xml(subject.raw).fetch("resource", {})
response = subject.get_one_author(meta.dig("creators", "creator"))
expect(response).to eq("nameIdentifiers" => [{"nameIdentifier"=>"https://orcid.org/0000-0003-1419-2405", "nameIdentifierScheme"=>"ORCID", "schemeUri"=>"https://orcid.org"}], "name"=>"Fenner, Martin", "givenName"=>"Martin", "familyName"=>"Fenner")
end

it "has name in sort-order" do
input = "https://doi.org/10.5061/dryad.8515"
subject = Bolognese::Metadata.new(input, from: "datacite")
subject = Bolognese::Metadata.new(input: input, from: "datacite")
meta = Maremma.from_xml(subject.raw).fetch("resource", {})
response = subject.get_one_author(meta.dig("creators", "creator").first)
expect(response).to eq("nameType"=>"Personal", "name"=>"Ollomo, Benjamin", "givenName"=>"Benjamin", "familyName"=>"Ollomo", "nameIdentifiers" => [], "affiliation" => [{"affiliationIdentifier"=>"https://ror.org/01wyqb997", "affiliationIdentifierScheme"=>"ROR", "name"=>"Centre International de Recherches Médicales de Franceville"}])
end

it "has name in display-order" do
input = "https://doi.org/10.5281/ZENODO.48440"
subject = Bolognese::Metadata.new(input, from: "datacite")
subject = Bolognese::Metadata.new(input: input, from: "datacite")
meta = Maremma.from_xml(subject.raw).fetch("resource", {})
response = subject.get_one_author(meta.dig("creators", "creator"))
expect(response).to eq("nameType"=>"Personal", "name"=>"Garza, Kristian", "givenName"=>"Kristian", "familyName"=>"Garza", "nameIdentifiers" => [], "affiliation" => [])
end

it "has name in display-order with ORCID" do
input = "https://doi.org/10.6084/M9.FIGSHARE.4700788"
subject = Bolognese::Metadata.new(input, from: "datacite")
subject = Bolognese::Metadata.new(input: input, from: "datacite")
meta = Maremma.from_xml(subject.raw).fetch("resource", {})
response = subject.get_one_author(meta.dig("creators", "creator"))
expect(response).to eq("nameType"=>"Personal", "nameIdentifiers" => [{"nameIdentifier"=>"https://orcid.org/0000-0003-4881-1606", "nameIdentifierScheme"=>"ORCID", "schemeUri"=>"https://orcid.org"}], "name"=>"Bedini, Andrea", "givenName"=>"Andrea", "familyName"=>"Bedini", "affiliation" => [])
end

it "has name in Thai" do
input = "https://doi.org/10.14457/KMITL.res.2006.17"
subject = Bolognese::Metadata.new(input, from: "datacite")
subject = Bolognese::Metadata.new(input: input, from: "datacite")
meta = Maremma.from_xml(subject.raw).fetch("resource", {})
response = subject.get_one_author(meta.dig("creators", "creator"))
expect(response).to eq("name"=>"กัญจนา แซ่เตียว", "nameIdentifiers" => [], "affiliation" => [])
end

it "multiple author names in one field" do
input = "https://doi.org/10.7910/dvn/eqtqyo"
subject = Bolognese::Metadata.new(input, from: "datacite")
subject = Bolognese::Metadata.new(input: input, from: "datacite")
meta = Maremma.from_xml(subject.raw).fetch("resource", {})
response = subject.get_authors(meta.dig("creators", "creator"))
expect(response).to eq([{"name" => "Enos, Ryan (Harvard University); Fowler, Anthony (University Of Chicago); Vavreck, Lynn (UCLA)", "nameIdentifiers" => [], "affiliation" => []}])
end

it "hyper-authorship" do
input = "https://doi.org/10.17182/HEPDATA.77274.V1"
subject = Bolognese::Metadata.new(input, from: "datacite")
subject = Bolognese::Metadata.new(input: input, from: "datacite")
meta = Maremma.from_xml(subject.raw).fetch("resource", {})
response = subject.get_authors(meta.dig("creators", "creator"))
expect(response.length).to eq(1000)
Expand All @@ -109,47 +109,47 @@

it "name with affiliation" do
input = "10.11588/DIGLIT.6130"
subject = Bolognese::Metadata.new(input, from: "datacite")
subject = Bolognese::Metadata.new(input: input, from: "datacite")
meta = Maremma.from_xml(subject.raw).fetch("resource", {})
response = subject.get_one_author(meta.dig("creators", "creator"))
expect(response).to eq("nameType"=>"Organizational", "name"=>"Dr. Störi, Kunstsalon", "nameIdentifiers" => [], "affiliation" => [])
end

it "name with affiliation and country" do
input = "10.16910/jemr.9.1.2"
subject = Bolognese::Metadata.new(input, from: "datacite")
subject = Bolognese::Metadata.new(input: input, from: "datacite")
meta = Maremma.from_xml(subject.raw).fetch("resource", {})
response = subject.get_one_author(meta.dig("creators", "creator").first)
expect(response).to eq("name"=>"Eraslan, Sukru; University Of Manchester, UK, & Middle East Technical University, Northern Cyprus Campus, Kalkanli, Guzelyurt, Turkey", "nameIdentifiers" => [], "affiliation" => [])
end

it "name with role" do
input = "10.14463/GBV:873056442"
subject = Bolognese::Metadata.new(input, from: "datacite")
subject = Bolognese::Metadata.new(input: input, from: "datacite")
meta = Maremma.from_xml(subject.raw).fetch("resource", {})
response = subject.get_one_author(meta.dig("creators", "creator").first)
expect(response).to eq("nameType"=>"Personal", "name"=>"Schumacher, H. C.", "givenName"=>"H. C.", "familyName"=>"Schumacher", "nameIdentifiers" => [], "affiliation" => [])
end

it "multiple name_identifier" do
input = "10.24350/CIRM.V.19028803"
subject = Bolognese::Metadata.new(input, from: "datacite")
subject = Bolognese::Metadata.new(input: input, from: "datacite")
meta = Maremma.from_xml(subject.raw).fetch("resource", {})
response = subject.get_one_author(meta.dig("creators", "creator"))
expect(response).to eq("nameType"=>"Personal", "name"=>"Dubos, Thomas", "givenName"=>"Thomas", "familyName"=>"Dubos", "affiliation" => [{"name"=>"École Polytechnique Laboratoire de Météorologie Dynamique"}], "nameIdentifiers" => [{"nameIdentifier"=>"http://isni.org/isni/0000 0003 5752 6882", "nameIdentifierScheme"=>"ISNI", "schemeUri"=>"http://isni.org/isni/"}, {"nameIdentifier"=>"https://orcid.org/0000-0003-4514-4211", "nameIdentifierScheme"=>"ORCID", "schemeUri"=>"https://orcid.org"}])
end

it "nameType organizational" do
input = fixture_path + 'gtex.xml'
subject = Bolognese::Metadata.new(input, from: "datacite")
subject = Bolognese::Metadata.new(input: input, from: "datacite")
meta = Maremma.from_xml(subject.raw).fetch("resource", {})
response = subject.get_one_author(meta.dig("creators", "creator"))
expect(response).to eq("nameType"=>"Organizational", "name"=>"The GTEx Consortium", "nameIdentifiers" => [], "affiliation" => [])
end

it "only familyName and givenName" do
input = "https://doi.pangaea.de/10.1594/PANGAEA.836178"
subject = Bolognese::Metadata.new(input, from: "schema_org")
subject = Bolognese::Metadata.new(input: input, from: "schema_org")
expect(subject.creators.first).to eq("nameType" => "Personal", "name"=>"Johansson, Emma", "givenName"=>"Emma", "familyName"=>"Johansson")
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/datacite_utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
describe Bolognese::Metadata, vcr: true do
let(:input) { "https://doi.org/10.5061/DRYAD.8515" }

subject { Bolognese::Metadata.new(input, from: "datacite") }
subject { Bolognese::Metadata.new(input: input, from: "datacite") }

context "insert_identifier" do
it "doi" do
Expand Down Expand Up @@ -124,7 +124,7 @@
context "insert_formats" do
let(:input) { IO.read(fixture_path + 'datacite-empty-sizes.xml') }

subject { Bolognese::Metadata.new(input, from: "datacite") }
subject { Bolognese::Metadata.new(input: input, from: "datacite") }

it "insert" do
xml = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') { |xml| subject.insert_formats(xml) }.to_xml
Expand Down Expand Up @@ -169,7 +169,7 @@
context "insert_descriptions" do
it "insert" do
input = "https://doi.org/10.5438/4K3M-NYVG"
subject = Bolognese::Metadata.new(input, from: "datacite")
subject = Bolognese::Metadata.new(input: input, from: "datacite")
xml = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') { |xml| subject.insert_descriptions(xml) }.to_xml
response = Maremma.from_xml(xml)
expect(response.dig("descriptions", "description")).to eq("descriptionType" => "Abstract", "__content__" => "Eating your own dog food is a slang term to describe that an organization should itself use the products and services it provides. For DataCite this means that we should use DOIs with appropriate metadata and strategies for long-term preservation for...")
Expand Down
2 changes: 1 addition & 1 deletion spec/doi_utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
describe Bolognese::Metadata, vcr: true do
let(:input) { "https://doi.org/10.1101/097196" }

subject { Bolognese::Metadata.new(input, from: "crossref") }
subject { Bolognese::Metadata.new(input: input, from: "crossref") }

context "doi resolver" do
it "doi" do
Expand Down
6 changes: 3 additions & 3 deletions spec/metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

describe Bolognese::Metadata, vcr: true do
let(:input) { "http://doi.org/10.5438/4K3M-NYVG" }
subject { Bolognese::Metadata.new(input) }
subject { Bolognese::Metadata.new(input: input) }

context "handle input" do
it "unknown DOI prefix" do
input = "http://doi.org/10.0137/14802"
subject = Bolognese::Metadata.new(input)
subject = Bolognese::Metadata.new(input: input)
expect(subject.valid?).to be false
expect(subject.bibtex).to be_nil
end

it "DOI RA not Crossref or DataCite" do
input = "http://doi.org/10.3980/j.issn.2222-3959.2015.03.07"
subject = Bolognese::Metadata.new(input)
subject = Bolognese::Metadata.new(input: input)
expect(subject.valid?).to be false
expect(subject.bibtex).to be_nil
end
Expand Down
6 changes: 3 additions & 3 deletions spec/readers/bibtex_reader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
describe Bolognese::Metadata, vcr: true do
let(:input) { fixture_path + "crossref.bib" }

subject { Bolognese::Metadata.new(input) }
subject { Bolognese::Metadata.new(input: input) }

context "detect format" do
it "extension" do
expect(subject.valid?).to be true
end

it "string" do
Bolognese::Metadata.new(IO.read(input).strip)
Bolognese::Metadata.new(input: IO.read(input).strip)
expect(subject.valid?).to be true
expect(subject.id).to eq("https://doi.org/10.7554/elife.01567")
end
Expand Down Expand Up @@ -48,7 +48,7 @@
it "DOI does not exist" do
input = fixture_path + "pure.bib"
doi = "10.7554/elife.01567"
subject = Bolognese::Metadata.new(input, doi: doi)
subject = Bolognese::Metadata.new(input: input, doi: doi)
expect(subject.valid?).to be false
expect(subject.state).to eq("not_found")
expect(subject.id).to eq("https://doi.org/10.7554/elife.01567")
Expand Down
6 changes: 3 additions & 3 deletions spec/readers/citeproc_reader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
describe Bolognese::Metadata, vcr: true do
let(:input) { fixture_path + "citeproc.json" }

subject { Bolognese::Metadata.new(input, from: "citeproc") }
subject { Bolognese::Metadata.new(input: input, from: "citeproc") }

context "get citeproc raw" do
it "BlogPosting" do
Expand All @@ -30,7 +30,7 @@
context "get citeproc no categories" do
it "BlogPosting" do
input = fixture_path + "citeproc-no-categories.json"
subject = Bolognese::Metadata.new(input)
subject = Bolognese::Metadata.new(input: input)
expect(subject.valid?).to be true
expect(subject.id).to eq("https://doi.org/10.5072/4k3m-nyvg")
expect(subject.url).to eq("https://blog.datacite.org/eating-your-own-dog-food")
Expand All @@ -46,7 +46,7 @@
context "get citeproc no author" do
it "Journal article" do
input = fixture_path + "citeproc-no-author.json"
subject = Bolognese::Metadata.new(input)
subject = Bolognese::Metadata.new(input: input)
#expect(subject.valid?).to be true
expect(subject.id).to eq("https://doi.org/10.5438/4k3m-nyvg")
expect(subject.url).to eq("https://blog.datacite.org/eating-your-own-dog-food")
Expand Down
10 changes: 5 additions & 5 deletions spec/readers/codemeta_reader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
describe Bolognese::Metadata, vcr: true do
let(:input) { "https://github.com/datacite/maremma" }

subject { Bolognese::Metadata.new(input) }
subject { Bolognese::Metadata.new(input: input) }

context "get codemeta raw" do
it "rdataone" do
input = fixture_path + 'codemeta.json'
subject = Bolognese::Metadata.new(input)
subject = Bolognese::Metadata.new(input: input)
expect(subject.raw).to eq(IO.read(input).strip)
end
end
Expand Down Expand Up @@ -45,7 +45,7 @@

it "rdataone" do
input = fixture_path + 'codemeta.json'
subject = Bolognese::Metadata.new(input)
subject = Bolognese::Metadata.new(input: input)
expect(subject.id).to eq("https://doi.org/10.5063/f1m61h5x")
expect(subject.url).to eq("https://github.com/DataONEorg/rdataone")
expect(subject.types).to eq("bibtex"=>"misc", "citeproc"=>"article-journal", "resourceTypeGeneral"=>"Software", "ris"=>"COMP", "schemaOrg"=>"SoftwareSourceCode")
Expand Down Expand Up @@ -86,7 +86,7 @@

it "maremma" do
input = fixture_path + 'maremma/codemeta.json'
subject = Bolognese::Metadata.new(input)
subject = Bolognese::Metadata.new(input: input)
expect(subject.valid?).to be true
expect(subject.id).to eq("https://doi.org/10.5438/qeg0-3gm3")
expect(subject.url).to eq("https://github.com/datacite/maremma")
Expand Down Expand Up @@ -115,7 +115,7 @@

it "metadata_reports" do
input = "https://github.com/datacite/metadata-reports/blob/master/software/codemeta.json"
subject = Bolognese::Metadata.new(input)
subject = Bolognese::Metadata.new(input: input)
expect(subject.valid?).to be true
expect(subject.id).to eq("https://doi.org/10.5438/wr0x-e194")
expect(subject.url).to eq("https://github.com/datacite/metadata-reports")
Expand Down
4 changes: 2 additions & 2 deletions spec/readers/crosscite_reader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
describe Bolognese::Metadata, vcr: true do
let(:input) { fixture_path + "crosscite.json" }

subject { Bolognese::Metadata.new(input) }
subject { Bolognese::Metadata.new(input: input) }

context "get crosscite raw" do
it "SoftwareSourceCode" do
Expand All @@ -27,7 +27,7 @@

it "SoftwareSourceCode as string" do
input = IO.read(fixture_path + "crosscite.json")
subject = Bolognese::Metadata.new(input)
subject = Bolognese::Metadata.new(input: input)
expect(subject.valid?).to be true
expect(subject.identifiers).to eq([{"Identifier"=>"https://doi.org/10.5281/zenodo.48440", "identifierType"=>"DOI"}, {"Identifier"=>"http://zenodo.org/record/48440", "identifierType"=>"URL"}])
expect(subject.types).to eq("bibtex"=>"misc", "citeproc"=>"other", "resourceType"=>"Software", "resourceTypeGeneral"=>"Software", "ris"=>"COMP", "schemaOrg"=>"SoftwareSourceCode")
Expand Down
Loading

0 comments on commit 3ead12e

Please sign in to comment.