Skip to content

Commit

Permalink
Merge pull request #89 from datacite/version-info
Browse files Browse the repository at this point in the history
rename internal property version_info to version
  • Loading branch information
Martin Fenner authored May 16, 2020
2 parents 959f3b7 + 10fbe9a commit f0344d4
Show file tree
Hide file tree
Showing 21 changed files with 38 additions and 32 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@ coverage/
.env.*
!.env.example
!.env.travis

.vscode
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/bolognese/datacite_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
11 changes: 7 additions & 4 deletions lib/bolognese/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -106,7 +106,7 @@ def initialize(input: nil, from: nil, **options)
:publication_year,
:descriptions,
:rights_list,
:version_info,
:version,
:subjects,
:language,
:geo_locations,
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/bolognese/metadata_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/bolognese/readers/citeproc_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/bolognese/readers/codemeta_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/bolognese/readers/crossref_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/bolognese/readers/datacite_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/bolognese/readers/npm_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/bolognese/readers/schema_org_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/bolognese/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Bolognese
VERSION = "1.5.21"
VERSION = "1.6"
end
2 changes: 1 addition & 1 deletion lib/bolognese/writers/codemeta_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
4 changes: 2 additions & 2 deletions lib/bolognese/writers/jats_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/bolognese/writers/schema_org_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion spec/readers/codemeta_reader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion spec/readers/datacite_json_reader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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("<version>v0.3.2</version>")
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")
Expand Down
2 changes: 1 addition & 1 deletion spec/readers/datacite_reader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down
6 changes: 3 additions & 3 deletions spec/readers/npm_reader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/readers/schema_org_reader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions spec/writers/datacite_writer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit f0344d4

Please sign in to comment.