From c2766dcf4db8a144939ba146c9356e3f746734f6 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Tue, 14 Jul 2020 16:36:08 +0200 Subject: [PATCH] indifferent access for doi creaation options --- Gemfile.lock | 4 ++-- lib/bolognese/metadata.rb | 1 + lib/bolognese/version.rb | 2 +- spec/metadata_spec.rb | 2 +- spec/readers/datacite_json_reader_spec.rb | 2 +- spec/readers/datacite_reader_spec.rb | 4 +++- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 30282513..ae1cd83b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - bolognese (1.7.3) + bolognese (1.7.4) activesupport (>= 4.2.5) benchmark_methods (~> 0.7) bibtex-ruby (>= 5.1.0) @@ -119,7 +119,7 @@ GEM namae (1.0.1) nokogiri (1.10.10) mini_portile2 (~> 2.4.0) - oj (3.10.6) + oj (3.10.7) oj_mimic_json (1.0.1) optimist (3.0.1) postrank-uri (1.0.24) diff --git a/lib/bolognese/metadata.rb b/lib/bolognese/metadata.rb index 10b341ab..77a7423c 100644 --- a/lib/bolognese/metadata.rb +++ b/lib/bolognese/metadata.rb @@ -16,6 +16,7 @@ class Metadata :types, :content_url, :related_identifiers, :style, :locale, :date_registered def initialize(input: nil, from: nil, **options) + options = HashWithIndifferentAccess.new(options) id = normalize_id(input, options) ra = nil diff --git a/lib/bolognese/version.rb b/lib/bolognese/version.rb index 0c42d3f1..19c715d8 100644 --- a/lib/bolognese/version.rb +++ b/lib/bolognese/version.rb @@ -1,3 +1,3 @@ module Bolognese - VERSION = "1.7.3" + VERSION = "1.7.4" end diff --git a/spec/metadata_spec.rb b/spec/metadata_spec.rb index 6ffd3d2e..1d92766a 100644 --- a/spec/metadata_spec.rb +++ b/spec/metadata_spec.rb @@ -153,7 +153,7 @@ it "missing_comma" do json = IO.read(fixture_path + "datacite_software_missing_comma.json") response = subject.jsonlint(json) - expect(response).to eq(["expected comma, not a string (doi) at line 4, column 11 [parse.c:373]"]) + expect(response).to eq(["expected comma, not a string (after doi) at line 4, column 11 [parse.c:373]"]) end it "overlapping_keys" do diff --git a/spec/readers/datacite_json_reader_spec.rb b/spec/readers/datacite_json_reader_spec.rb index 2aef558f..8909325c 100644 --- a/spec/readers/datacite_json_reader_spec.rb +++ b/spec/readers/datacite_json_reader_spec.rb @@ -46,7 +46,7 @@ input = fixture_path + "datacite_software_missing_comma.json" subject = Bolognese::Metadata.new(input: input, from: "datacite_json", show_errors: true) expect(subject.valid?).to be false - expect(subject.errors).to eq(["expected comma, not a string (doi) at line 4, column 11 [parse.c:373]"]) + expect(subject.errors).to eq(["expected comma, not a string (after doi) at line 4, column 11 [parse.c:373]"]) expect(subject.codemeta).to be_nil end diff --git a/spec/readers/datacite_reader_spec.rb b/spec/readers/datacite_reader_spec.rb index a7022a6f..9b1b6e79 100644 --- a/spec/readers/datacite_reader_spec.rb +++ b/spec/readers/datacite_reader_spec.rb @@ -340,7 +340,8 @@ "funderIdentifier"=>"https://doi.org/10.13039/501100000780", "funderIdentifierType"=>"Crossref Funder ID", "funderName"=>"European Commission"}], - types: { "resourceTypeGeneral" => "Dataset", "schemaOrg" => "Dataset" }) + types: { "resourceTypeGeneral" => "Dataset", "schemaOrg" => "Dataset" }, + "identifiers" => [{ "identifierType"=>"Repository ID", "identifier"=>"123" }]) expect(subject.valid?).to be true expect(subject.doi).to eq("10.5281/zenodo.1239") @@ -359,6 +360,7 @@ "funderIdentifier"=>"https://doi.org/10.13039/501100000780", "funderIdentifierType"=>"Crossref Funder ID", "funderName"=>"European Commission"}]) + expect(subject.identifiers).to eq([{"identifier"=>"123", "identifierType"=>"Repository ID"}]) expect(subject.agency).to eq("DataCite") expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-4") expect(subject.state).to eq("findable")