diff --git a/.gitignore b/.gitignore index 66990e4a..4e1028b4 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,5 @@ coverage/ .env.* !.env.example !.env.travis + +.vscode diff --git a/Gemfile.lock b/Gemfile.lock index 15d5929e..8fc41c06 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - bolognese (1.5.21) + bolognese (1.6) activesupport (>= 4.2.5) benchmark_methods (~> 0.7) bibtex-ruby (>= 5.1.0) @@ -30,12 +30,12 @@ PATH GEM remote: https://rubygems.org/ specs: - activesupport (6.0.2.2) + activesupport (6.0.3) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - zeitwerk (~> 2.2) + zeitwerk (~> 2.2, >= 2.2.2) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) benchmark_methods (0.7) @@ -105,7 +105,7 @@ GEM oj (>= 2.8.3) oj_mimic_json (~> 1.0, >= 1.0.1) mini_portile2 (2.4.0) - minitest (5.14.0) + minitest (5.14.1) multi_json (1.14.1) multipart-post (2.1.1) namae (1.0.1) @@ -150,7 +150,7 @@ GEM rspec-mocks (~> 3.9.0) rspec-core (3.9.2) rspec-support (~> 3.9.3) - rspec-expectations (3.9.1) + rspec-expectations (3.9.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.9.0) rspec-mocks (3.9.1) diff --git a/lib/bolognese/datacite_utils.rb b/lib/bolognese/datacite_utils.rb index af45eb9d..ec17c7bf 100644 --- a/lib/bolognese/datacite_utils.rb +++ b/lib/bolognese/datacite_utils.rb @@ -172,9 +172,9 @@ def insert_subjects(xml) end def insert_version(xml) - return xml unless version_info.present? + return xml unless version.present? - xml.version(version_info) + xml.version(version) end diff --git a/lib/bolognese/metadata.rb b/lib/bolognese/metadata.rb index 4a7df5ad..e8f873e8 100644 --- a/lib/bolognese/metadata.rb +++ b/lib/bolognese/metadata.rb @@ -9,7 +9,7 @@ class Metadata attr_accessor :string, :from, :sandbox, :meta, :regenerate, :issue, :show_errors attr_reader :doc, :page_start, :page_end attr_writer :id, :provider_id, :client_id, :doi, :identifiers, :creators, :contributors, :titles, :publisher, - :rights_list, :dates, :publication_year, :volume, :url, :version_info, + :rights_list, :dates, :publication_year, :volume, :url, :version, :subjects, :contributor, :descriptions, :language, :sizes, :formats, :schema_version, :meta, :container, :agency, :format, :funding_references, :state, :geo_locations, @@ -106,7 +106,7 @@ def initialize(input: nil, from: nil, **options) :publication_year, :descriptions, :rights_list, - :version_info, + :version, :subjects, :language, :geo_locations, @@ -189,10 +189,13 @@ def url @url ||= meta.fetch("url", nil) end - def version_info - @version_info ||= meta.fetch("version_info", nil) || meta.fetch("version", nil) + def version + @version ||= meta.fetch("version", nil) end + # for backwards compatibility + alias_attribute :version_info, :version + def publication_year @publication_year ||= meta.fetch("publication_year", nil) end diff --git a/lib/bolognese/metadata_utils.rb b/lib/bolognese/metadata_utils.rb index b5feeec9..88ca0133 100644 --- a/lib/bolognese/metadata_utils.rb +++ b/lib/bolognese/metadata_utils.rb @@ -158,7 +158,7 @@ def citeproc_hsh "publisher" => publisher, "title" => parse_attributes(titles, content: "title", first: true), "URL" => url, - "version" => version_info + "version" => version }.compact.symbolize_keys end @@ -180,7 +180,7 @@ def crosscite_hsh "identifiers" => identifiers, "sizes" => sizes, "formats" => formats, - "version" => version_info, + "version" => version, "rights_list" => rights_list, "descriptions" => descriptions, "geo_locations" => geo_locations, diff --git a/lib/bolognese/readers/citeproc_reader.rb b/lib/bolognese/readers/citeproc_reader.rb index f158e8a2..658d0a2c 100644 --- a/lib/bolognese/readers/citeproc_reader.rb +++ b/lib/bolognese/readers/citeproc_reader.rb @@ -119,7 +119,7 @@ def read_citeproc(string: nil, **options) "publication_year" => publication_year, "descriptions" => meta.fetch("abstract", nil).present? ? [{ "description" => sanitize(meta.fetch("abstract")), "descriptionType" => "Abstract" }] : [], "rights_list" => rights_list, - "version_info" => meta.fetch("version", nil), + "version" => meta.fetch("version", nil), "subjects" => subjects, "state" => state }.merge(read_options) diff --git a/lib/bolognese/readers/codemeta_reader.rb b/lib/bolognese/readers/codemeta_reader.rb index 687f138d..78a0e997 100644 --- a/lib/bolognese/readers/codemeta_reader.rb +++ b/lib/bolognese/readers/codemeta_reader.rb @@ -79,7 +79,7 @@ def read_codemeta(string: nil, **options) "publication_year" => publication_year, "descriptions" => meta.fetch("description", nil).present? ? [{ "description" => sanitize(meta.fetch("description")), "descriptionType" => "Abstract" }] : nil, "rights_list" => [{ "rightsUri" => meta.fetch("license", nil) }.compact], - "version_info" => meta.fetch("version", nil), + "version" => meta.fetch("version", nil), "subjects" => subjects, "state" => state }.merge(read_options) diff --git a/lib/bolognese/readers/crossref_reader.rb b/lib/bolognese/readers/crossref_reader.rb index 5d67ac55..a4032a8d 100644 --- a/lib/bolognese/readers/crossref_reader.rb +++ b/lib/bolognese/readers/crossref_reader.rb @@ -172,7 +172,7 @@ def read_crossref(string: nil, **options) "publication_year" => publication_year, "descriptions" => crossref_description(bibliographic_metadata), "rights_list" => crossref_license(program_metadata), - "version_info" => nil, + "version" => nil, "subjects" => nil, "language" => nil, "sizes" => nil, diff --git a/lib/bolognese/readers/datacite_reader.rb b/lib/bolognese/readers/datacite_reader.rb index 01026bb1..42bcc95b 100644 --- a/lib/bolognese/readers/datacite_reader.rb +++ b/lib/bolognese/readers/datacite_reader.rb @@ -230,7 +230,7 @@ def read_datacite(string: nil, **options) "publication_year" => parse_attributes(meta.fetch("publicationYear", nil), first: true).to_s.strip.presence, "descriptions" => descriptions, "rights_list" => Array.wrap(rights_list), - "version_info" => meta.fetch("version", nil).to_s.presence, + "version" => meta.fetch("version", nil).to_s.presence, "subjects" => subjects, "language" => parse_attributes(meta.fetch("language", nil), first: true).to_s.strip.presence, "geo_locations" => geo_locations, diff --git a/lib/bolognese/readers/npm_reader.rb b/lib/bolognese/readers/npm_reader.rb index 6d312144..c4b4ea61 100644 --- a/lib/bolognese/readers/npm_reader.rb +++ b/lib/bolognese/readers/npm_reader.rb @@ -105,7 +105,7 @@ def read_npm(string: nil, **options) #"publication_year" => publication_year, "descriptions" => meta.fetch("description", nil).present? ? [{ "description" => sanitize(meta.fetch("description")), "descriptionType" => "Abstract" }] : [], "rights_list" => rights_list, - "version_info" => meta.fetch("version", nil), + "version" => meta.fetch("version", nil), "subjects" => subjects #"state" => state }.merge(read_options) diff --git a/lib/bolognese/readers/schema_org_reader.rb b/lib/bolognese/readers/schema_org_reader.rb index 8b9b81e9..63ff8ed4 100644 --- a/lib/bolognese/readers/schema_org_reader.rb +++ b/lib/bolognese/readers/schema_org_reader.rb @@ -173,7 +173,7 @@ def read_schema_org(string: nil, **options) "dates" => dates, "descriptions" => meta.fetch("description", nil).present? ? [{ "description" => sanitize(meta.fetch("description")), "descriptionType" => "Abstract" }] : nil, "rights_list" => rights_list, - "version_info" => meta.fetch("version", nil).to_s.presence, + "version" => meta.fetch("version", nil).to_s.presence, "subjects" => subjects, "state" => state, "schema_version" => meta.fetch("schemaVersion", nil).to_s.presence, diff --git a/lib/bolognese/version.rb b/lib/bolognese/version.rb index 8e81b807..bf10a754 100644 --- a/lib/bolognese/version.rb +++ b/lib/bolognese/version.rb @@ -1,3 +1,3 @@ module Bolognese - VERSION = "1.5.21" + VERSION = "1.6" end diff --git a/lib/bolognese/writers/codemeta_writer.rb b/lib/bolognese/writers/codemeta_writer.rb index cd238900..e1012734 100644 --- a/lib/bolognese/writers/codemeta_writer.rb +++ b/lib/bolognese/writers/codemeta_writer.rb @@ -15,7 +15,7 @@ def codemeta "name" => parse_attributes(titles, content: "title", first: true), "authors" => creators, "description" => parse_attributes(descriptions, content: "description", first: true), - "version" => version_info, + "version" => version, "tags" => subjects.present? ? Array.wrap(subjects).map { |k| parse_attributes(k, content: "subject", first: true) } : nil, "datePublished" => get_date(dates, "Issued"), "dateModified" => get_date(dates, "Updated"), diff --git a/lib/bolognese/writers/jats_writer.rb b/lib/bolognese/writers/jats_writer.rb index ce859152..8355627e 100644 --- a/lib/bolognese/writers/jats_writer.rb +++ b/lib/bolognese/writers/jats_writer.rb @@ -22,7 +22,7 @@ def insert_citation(xml) insert_issue(xml) if container.to_h["issue"].present? insert_fpage(xml) if container.to_h["firstPage"].present? insert_lpage(xml) if container.to_h["lastPage"].present? - insert_version(xml) if version_info.present? + insert_version(xml) if version.present? insert_pub_id(xml) end @@ -112,7 +112,7 @@ def insert_lpage(xml) end def insert_version(xml) - xml.version(version_info) + xml.version(version) end def insert_pub_id(xml) diff --git a/lib/bolognese/writers/schema_org_writer.rb b/lib/bolognese/writers/schema_org_writer.rb index 2fb1c3bd..359cf138 100644 --- a/lib/bolognese/writers/schema_org_writer.rb +++ b/lib/bolognese/writers/schema_org_writer.rb @@ -15,7 +15,7 @@ def schema_hsh "editor" => to_schema_org_contributors(contributors), "description" => parse_attributes(descriptions, content: "description", first: true), "license" => Array.wrap(rights_list).map { |l| l["rightsUri"] }.compact.unwrap, - "version" => version_info, + "version" => version, "keywords" => subjects.present? ? Array.wrap(subjects).map { |k| parse_attributes(k, content: "subject", first: true) }.join(", ") : nil, "inLanguage" => language, "contentSize" => Array.wrap(sizes).unwrap, diff --git a/spec/readers/codemeta_reader_spec.rb b/spec/readers/codemeta_reader_spec.rb index 64303cda..c02b79ca 100644 --- a/spec/readers/codemeta_reader_spec.rb +++ b/spec/readers/codemeta_reader_spec.rb @@ -68,7 +68,7 @@ expect(subject.titles).to eq([{"title"=>"R Interface to the DataONE REST API"}]) expect(subject.descriptions.first["description"]).to start_with("Provides read and write access to data and metadata") expect(subject.subjects).to eq([{"subject"=>"data sharing"}, {"subject"=>"data repository"}, {"subject"=>"DataONE"}]) - expect(subject.version_info).to eq("2.0.0") + expect(subject.version).to eq("2.0.0") expect(subject.dates).to eq([{"date"=>"2016-05-27", "dateType"=>"Issued"}, {"date"=>"2016-05-27", "dateType"=>"Created"}, {"date"=>"2016-05-27", "dateType"=>"Updated"}]) expect(subject.publication_year).to eq("2016") expect(subject.publisher).to eq("https://cran.r-project.org") diff --git a/spec/readers/datacite_json_reader_spec.rb b/spec/readers/datacite_json_reader_spec.rb index 6a9006f9..8d16ab93 100644 --- a/spec/readers/datacite_json_reader_spec.rb +++ b/spec/readers/datacite_json_reader_spec.rb @@ -69,7 +69,7 @@ expect(subject.identifiers).to eq([{"identifier"=>"https://doi.org/10.5281/zenodo.28518", "identifierType"=>"DOI"}, {"identifier"=>"https://zenodo.org/record/28518", "identifierType"=>"URL"}]) expect(subject.dates).to eq([{"date"=>"2015-08-19", "dateType"=>"Issued"}]) expect(subject.publication_year).to eq("2015") - expect(subject.version_info).to eq("v0.3.2") + expect(subject.version).to eq("v0.3.2") expect(subject.datacite).to include("v0.3.2") expect(subject.related_identifiers.length).to eq(2) expect(subject.related_identifiers.first).to eq("relatedIdentifier"=>"https://github.com/jakevdp/supersmoother/tree/v0.3.2", "relatedIdentifierType"=>"URL", "relationType"=>"IsSupplementTo") diff --git a/spec/readers/datacite_reader_spec.rb b/spec/readers/datacite_reader_spec.rb index 72fff98a..501dc2e0 100644 --- a/spec/readers/datacite_reader_spec.rb +++ b/spec/readers/datacite_reader_spec.rb @@ -867,7 +867,7 @@ "nameIdentifiers"=> [{"nameIdentifier"=>"https://orcid.org/0000-0002-8743-4455", "nameIdentifierScheme"=>"ORCID", "schemeUri"=>"https://orcid.org"}], "affiliation"=>[{"name"=>"Royal Netherlands Meteorological Institute (KNMI)"}]}]) expect(subject.titles).to eq([{"title"=>"Multi-Sensor Reanalysis (MSR) of total ozone, version 2"}]) - expect(subject.version_info).to eq("2") + expect(subject.version).to eq("2") expect(subject.dates).to eq([{"date"=>"2014-04-25", "dateType"=>"Available"}, {"date"=>"2015", "dateType"=>"Issued"}]) expect(subject.publication_year).to eq("2015") expect(subject.publisher).to eq("Royal Netherlands Meteorological Institute (KNMI)") diff --git a/spec/readers/npm_reader_spec.rb b/spec/readers/npm_reader_spec.rb index f26b8766..0063c149 100644 --- a/spec/readers/npm_reader_spec.rb +++ b/spec/readers/npm_reader_spec.rb @@ -24,7 +24,7 @@ expect(subject.titles).to eq([{"title"=>"fullstack_app"}]) expect(subject.descriptions).to be_empty expect(subject.rights_list).to eq([{"rights"=>"ISC"}]) - expect(subject.version_info).to eq("1.0.0") + expect(subject.version).to eq("1.0.0") #expect(subject.dates).to eq([{"date"=>"2016-12-20", "dateType"=>"Issued"}]) #expect(subject.publication_year).to eq("2016") end @@ -40,7 +40,7 @@ expect(subject.creators).to eq([{"name"=>":(unav)", "nameType"=>"Organizational"}]) expect(subject.titles).to eq([{"title"=>"CITapp"}]) expect(subject.descriptions).to eq([{"description"=>"Concealed Information Test app", "descriptionType"=>"Abstract"}]) - expect(subject.version_info).to eq("1.1.0") + expect(subject.version).to eq("1.1.0") #expect(subject.dates).to eq([{"date"=>"2016-12-20", "dateType"=>"Issued"}]) #expect(subject.publication_year).to eq("2016") end @@ -58,7 +58,7 @@ expect(subject.descriptions).to eq([{"description"=> + "The EDAM Browser is a client-side web-based visualization javascript widget. Its goals are to help describing bio-related resources and service with EDAM, and to facilitate and foster community contributions to EDAM.", "descriptionType"=>"Abstract"}]) - expect(subject.version_info).to eq("1.0.0") + expect(subject.version).to eq("1.0.0") #expect(subject.dates).to eq([{"date"=>"2016-12-20", "dateType"=>"Issued"}]) #expect(subject.publication_year).to eq("2016") end diff --git a/spec/readers/schema_org_reader_spec.rb b/spec/readers/schema_org_reader_spec.rb index 476a85cf..f6dc27c0 100644 --- a/spec/readers/schema_org_reader_spec.rb +++ b/spec/readers/schema_org_reader_spec.rb @@ -165,7 +165,7 @@ expect(subject.types).to eq("bibtex"=>"misc", "citeproc"=>"dataset", "resourceType"=>"Gene expression matrices", "resourceTypeGeneral"=>"Dataset", "ris"=>"DATA", "schemaOrg"=>"Dataset") expect(subject.creators).to eq([{"name"=>"The GTEx Consortium", "nameType"=>"Organizational", "nameIdentifiers"=>[], "affiliation" => []}]) expect(subject.titles).to eq([{"title"=>"Fully processed, filtered and normalized gene expression matrices (in BED format) for each tissue, which were used as input into FastQTL for eQTL discovery"}]) - expect(subject.version_info).to eq("v7") + expect(subject.version).to eq("v7") expect(subject.subjects).to eq([{"subject"=>"gtex"}, {"subject"=>"annotation"}, {"subject"=>"phenotype"}, {"subject"=>"gene regulation"}, {"subject"=>"transcriptomics"}]) expect(subject.dates).to eq([{"date"=>"2017", "dateType"=>"Issued"}]) expect(subject.publication_year).to eq("2017") @@ -275,7 +275,7 @@ expect(subject.types).to eq("bibtex"=>"misc", "citeproc"=>"dataset", "resourceTypeGeneral"=>"Dataset", "ris"=>"DATA", "schemaOrg"=>"Dataset") # expect(subject.creators).to eq([{"familyName"=>"Lindman", "givenName"=>"Karin", "name"=>"Lindman, Karin", "nameIdentifiers"=>[{"nameIdentifier"=> "https://orcid.org/0000-0003-1298-517X", "nameIdentifierScheme"=>"ORCID", "schemeUri"=>"https://orcid.org"}], "nameType"=>"Personal"}]) expect(subject.titles).to eq([{"title"=>"Ovary data from the Visual Sweden project DROID"}]) - expect(subject.version_info).to eq("1.0") + expect(subject.version).to eq("1.0") expect(subject.subjects).to eq([{"subject"=>"pathology"}, {"subject"=>"whole slide imaging"}, {"subject"=>"annotated"}]) expect(subject.dates).to eq([{"date"=>"2019-01-09", "dateType"=>"Issued"}, {"date"=>"2019-01-09", "dateType"=>"Created"}, {"date"=>"2019-01-09", "dateType"=>"Updated"}]) expect(subject.publication_year).to eq("2019") diff --git a/spec/writers/datacite_writer_spec.rb b/spec/writers/datacite_writer_spec.rb index 03debf59..e5223c71 100644 --- a/spec/writers/datacite_writer_spec.rb +++ b/spec/writers/datacite_writer_spec.rb @@ -145,6 +145,7 @@ expect(subject.dates).to eq([{"date"=>"2015-08-19", "dateType"=>"Issued"}]) expect(subject.publication_year).to eq("2015") expect(subject.version_info).to eq("v0.3.2") + expect(subject.version).to eq("v0.3.2") expect(subject.publisher).to eq("Zenodo") expect(subject.agency).to eq("DataCite") expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-4")