commonmeta-ruby 3.8.3 → 3.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +10 -9
- data/LICENSE.md +1 -1
- data/lib/commonmeta/author_utils.rb +9 -5
- data/lib/commonmeta/metadata_utils.rb +2 -0
- data/lib/commonmeta/readers/commonmeta_reader.rb +20 -0
- data/lib/commonmeta/readers/datacite_reader.rb +7 -1
- data/lib/commonmeta/schema_utils.rb +1 -1
- data/lib/commonmeta/utils.rb +49 -2
- data/lib/commonmeta/version.rb +1 -1
- data/resources/{commonmeta_v0.10.4.json → commonmeta_v0.10.6.json} +12 -3
- data/resources/{datacite-v4.json → datacite-v45.json} +26 -5
- data/resources/kernel-4/include/datacite-relationType-v4.xsd +2 -0
- data/resources/kernel-4/include/datacite-resourceType-v4.xsd +2 -0
- data/resources/kernel-4/metadata.xsd +11 -7
- data/spec/fixtures/commonmeta.json +411 -0
- data/spec/fixtures/datacite-dataset_v4.5.json +736 -0
- data/spec/fixtures/datacite-instrument.json +135 -0
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_datacite_metadata/SoftwareSourceCode.yml +8 -8
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_datacite_metadata/dissertation.yml +12 -12
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_datacite_metadata/funding_references.yml +12 -12
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_datacite_metadata/subject_scheme.yml +22 -22
- data/spec/readers/commonmeta_reader_spec.rb +56 -0
- data/spec/readers/datacite_reader_spec.rb +34 -9
- data/spec/utils_spec.rb +30 -4
- data/spec/writers/datacite_writer_spec.rb +0 -1
- metadata +9 -4
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Commonmeta::Metadata, vcr: true do
|
6
|
+
subject { described_class.new(input: input) }
|
7
|
+
|
8
|
+
let(:input) { "#{fixture_path}commonmeta.json" }
|
9
|
+
|
10
|
+
context 'read commonmeta metadata' do
|
11
|
+
it "default" do
|
12
|
+
expect(subject.valid?).to be true
|
13
|
+
expect(subject.schema_version).to eq("https://commonmeta.org/commonmeta_v0.10")
|
14
|
+
expect(subject.id).to eq("https://doi.org/10.7554/elife.01567")
|
15
|
+
expect(subject.type).to eq("JournalArticle")
|
16
|
+
expect(subject.url).to eq("https://elifesciences.org/articles/01567")
|
17
|
+
expect(subject.contributors.length).to eq(5)
|
18
|
+
expect(subject.contributors.first).to eq("type" => "Person", "contributorRoles" => ["Author"],
|
19
|
+
"givenName" => "Martial", "familyName" => "Sankar", "affiliation" => [{ "name" => "Department of Plant Molecular Biology, University of Lausanne, Lausanne, Switzerland" }])
|
20
|
+
expect(subject.license).to eq("id" => "CC-BY-3.0",
|
21
|
+
"url" => "https://creativecommons.org/licenses/by/3.0/legalcode")
|
22
|
+
expect(subject.titles).to eq([{ "title" => "Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth" }])
|
23
|
+
expect(subject.date).to eq("published" => "2014-02-11", "updated" => "2022-03-26")
|
24
|
+
expect(subject.publisher).to eq("id" => "https://api.crossref.org/members/4374",
|
25
|
+
"name" => "eLife Sciences Publications, Ltd")
|
26
|
+
expect(subject.container).to eq("identifier" => "2050-084X",
|
27
|
+
"identifierType" => "ISSN", "title" => "eLife", "type" => "Journal", "volume" => "3")
|
28
|
+
expect(subject.references.length).to eq(27)
|
29
|
+
expect(subject.references.last).to eq("containerTitle" => "Nature Cell Biology",
|
30
|
+
"contributor" => "Yin",
|
31
|
+
"doi" => "https://doi.org/10.1038/ncb2764",
|
32
|
+
"firstPage" => "860",
|
33
|
+
"key" => "bib27",
|
34
|
+
"publicationYear" => "2013",
|
35
|
+
"title" => "A screen for morphological complexity identifies regulators of switch-like transitions between discrete cell shapes",
|
36
|
+
"volume" => "15")
|
37
|
+
expect(subject.funding_references).to eq([{ "funderName" => "SystemsX" },
|
38
|
+
{ "funderName" => "EMBO longterm post-doctoral fellowships" },
|
39
|
+
{ "funderName" => "Marie Heim-Voegtlin" },
|
40
|
+
{ "funderIdentifier" => "https://doi.org/10.13039/501100006390",
|
41
|
+
"funderIdentifierType" => "Crossref Funder ID",
|
42
|
+
"funderName" => "University of Lausanne" },
|
43
|
+
{ "funderName" => "SystemsX" },
|
44
|
+
{ "funderIdentifier" => "https://doi.org/10.13039/501100003043",
|
45
|
+
"funderIdentifierType" => "Crossref Funder ID",
|
46
|
+
"funderName" => "EMBO" },
|
47
|
+
{ "funderIdentifier" => "https://doi.org/10.13039/501100001711",
|
48
|
+
"funderIdentifierType" => "Crossref Funder ID",
|
49
|
+
"funderName" => "Swiss National Science Foundation" },
|
50
|
+
{ "funderIdentifier" => "https://doi.org/10.13039/501100006390",
|
51
|
+
"funderIdentifierType" => "Crossref Funder ID",
|
52
|
+
"funderName" => "University of Lausanne" }])
|
53
|
+
expect(subject.provider).to eq("Crossref")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -36,13 +36,12 @@ describe Commonmeta::Metadata, vcr: true do
|
|
36
36
|
# expect(subject.valid?).to be true
|
37
37
|
expect(subject.id).to eq("https://doi.org/10.5063/f1m61h5x")
|
38
38
|
expect(subject.type).to eq("Software")
|
39
|
-
expect(subject.contributors).to eq([{"contributorRoles"=>["Author"],
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
expect(subject.
|
44
|
-
expect(subject.
|
45
|
-
expect(subject.publisher).to eq("name"=>"KNB Data Repository")
|
39
|
+
expect(subject.contributors).to eq([{ "contributorRoles" => ["Author"],
|
40
|
+
"name" => "Jones, Matthew B.; Slaughter, Peter; Nahf, Rob; Boettiger, Carl ; Jones, Chris; Read, Jordan; Walker, Lauren; Hart, Edmund; Chamberlain, Scott",
|
41
|
+
"type" => "Organization" }])
|
42
|
+
expect(subject.titles).to eq([{ "title" => "dataone: R interface to the DataONE network of data repositories" }])
|
43
|
+
expect(subject.date).to eq("created" => "2016-03-12", "published" => "2016", "registered" => "2016-03-12", "updated" => "2020-09-18")
|
44
|
+
expect(subject.publisher).to eq("name" => "KNB Data Repository")
|
46
45
|
expect(subject.provider).to eq("DataCite")
|
47
46
|
end
|
48
47
|
|
@@ -70,8 +69,8 @@ describe Commonmeta::Metadata, vcr: true do
|
|
70
69
|
expect(subject.type).to eq("Dissertation")
|
71
70
|
expect(subject.contributors.length).to eq(3)
|
72
71
|
expect(subject.contributors.first).to eq("type" => "Person", "contributorRoles" => ["Author"],
|
73
|
-
|
74
|
-
expect(subject.contributors.last).to eq("id"=>"https://orcid.org/0000-0002-8633-8234", "type"=>"Person", "contributorRoles"=>["Supervision"], "givenName"=>"Gerhard", "familyName"=>"Gruebel", "affiliation"=>[{"name"=>"Deutsches Elektronen-Synchrotron"}])
|
72
|
+
"givenName" => "Heiko", "familyName" => "Conrad")
|
73
|
+
expect(subject.contributors.last).to eq("id" => "https://orcid.org/0000-0002-8633-8234", "type" => "Person", "contributorRoles" => ["Supervision"], "givenName" => "Gerhard", "familyName" => "Gruebel", "affiliation" => [{ "name" => "Deutsches Elektronen-Synchrotron" }])
|
75
74
|
expect(subject.titles).to eq([{ "title" => "Dynamics of colloids in molecular glass forming liquids studied via X-ray photon correlation spectroscopy" }])
|
76
75
|
expect(subject.date).to eq("created" => "2018-01-25", "published" => "2014",
|
77
76
|
"registered" => "2018-01-25", "updated" => "2020-09-19")
|
@@ -155,5 +154,31 @@ describe Commonmeta::Metadata, vcr: true do
|
|
155
154
|
expect(subject.license).to eq("id" => "CC-BY-4.0",
|
156
155
|
"url" => "https://creativecommons.org/licenses/by/4.0/legalcode")
|
157
156
|
end
|
157
|
+
|
158
|
+
it "dataset schema v4.5" do
|
159
|
+
input = "#{fixture_path}datacite-dataset_v4.5.json"
|
160
|
+
subject = described_class.new(input: input)
|
161
|
+
expect(subject.id).to eq("https://doi.org/10.82433/b09z-4k37")
|
162
|
+
expect(subject.type).to eq("Dataset")
|
163
|
+
expect(subject.contributors.length).to eq(23)
|
164
|
+
expect(subject.contributors[0]).to eq("contributorRoles" => ["Author"], "familyName" => "ExampleFamilyName", "givenName" => "ExampleGivenName", "type" => "Person")
|
165
|
+
expect(subject.contributors[2]).to eq("contributorRoles" => ["ContactPerson"], "familyName" => "ExampleFamilyName", "givenName" => "ExampleGivenName", "type" => "Person")
|
166
|
+
expect(subject.date).to eq("created"=>"2022-10-27", "published"=>"2022", "registered"=>"2022-10-27", "updated"=>"2024-01-02")
|
167
|
+
expect(subject.publisher).to eq("name" => "Example Publisher")
|
168
|
+
expect(subject.license).to eq("id"=>"CC-PDDC", "url"=>"https://creativecommons.org/licenses/publicdomain/")
|
169
|
+
end
|
170
|
+
|
171
|
+
it "instrument" do
|
172
|
+
input = "#{fixture_path}datacite-instrument.json"
|
173
|
+
subject = described_class.new(input: input)
|
174
|
+
expect(subject.valid?).to be true
|
175
|
+
expect(subject.id).to eq("https://doi.org/10.82433/08qf-ee96")
|
176
|
+
expect(subject.type).to eq("Instrument")
|
177
|
+
expect(subject.contributors.length).to eq(2)
|
178
|
+
expect(subject.contributors.first).to eq("contributorRoles" => ["Author"], "name" => "DECTRIS", "type" => "Organization", "id" => "https://www.wikidata.org/wiki/Q107529885")
|
179
|
+
expect(subject.date).to eq("created" => "2022-10-20", "published" => "2022", "registered" => "2022-10-20", "updated" => "2024-01-02")
|
180
|
+
expect(subject.publisher).to eq("name" => "Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences")
|
181
|
+
expect(subject.license).to be_nil
|
182
|
+
end
|
158
183
|
end
|
159
184
|
end
|
data/spec/utils_spec.rb
CHANGED
@@ -502,7 +502,7 @@ describe Commonmeta::Metadata do
|
|
502
502
|
links = [{ "rel" => "self", "type" => "application/atom+xml", "href" => "https://syldavia-gazette.org/atom/" },
|
503
503
|
{ "rel" => "alternate", "type" => "text/html", "href" => "https://syldavia-gazette.org" },
|
504
504
|
{ "rel" => "license", "type" => "text/html", "href" => "https://creativecommons.org/licenses/by/4.0/legalcode" }]
|
505
|
-
|
505
|
+
|
506
506
|
it "url" do
|
507
507
|
response = subject.get_link(links, "self")
|
508
508
|
expect(response).to eq("https://syldavia-gazette.org/atom/")
|
@@ -721,7 +721,7 @@ describe Commonmeta::Metadata do
|
|
721
721
|
it "decode doi to uuid" do
|
722
722
|
doi = "https://doi.org/10.53731/6315bn4-aqg82ja-4a9wxdt-29f7279"
|
723
723
|
response = subject.decode_doi(doi, uuid: true)
|
724
|
-
expect(response).to eq(
|
724
|
+
expect(response).to eq("255d48ab-c102-9288-a4f3-add092f388e9")
|
725
725
|
end
|
726
726
|
end
|
727
727
|
|
@@ -745,10 +745,36 @@ describe Commonmeta::Metadata do
|
|
745
745
|
end
|
746
746
|
end
|
747
747
|
|
748
|
-
context
|
749
|
-
it
|
748
|
+
context "json_feed_unregistered_url" do
|
749
|
+
it "all posts" do
|
750
750
|
response = subject.json_feed_unregistered_url
|
751
751
|
expect(response).to eq("https://api.rogue-scholar.org/posts/unregistered")
|
752
752
|
end
|
753
753
|
end
|
754
|
+
|
755
|
+
context "normalize_name_identifier" do
|
756
|
+
it "ORCID" do
|
757
|
+
hsh = {"schemeUri"=>"https://orcid.org", "nameIdentifier"=>"https://orcid.org/0000-0003-1419-2405", "nameIdentifierScheme"=>"ORCID"}
|
758
|
+
response = subject.normalize_name_identifier(hsh)
|
759
|
+
expect(response).to eq("https://orcid.org/0000-0003-1419-2405")
|
760
|
+
end
|
761
|
+
|
762
|
+
it "ROR" do
|
763
|
+
hsh = { "schemeUri" => "https://ror.org", "nameIdentifier" => "https://ror.org/02aj13c28", "nameIdentifierScheme" => "ROR" }
|
764
|
+
response = subject.normalize_name_identifier(hsh)
|
765
|
+
expect(response).to eq("https://ror.org/02aj13c28")
|
766
|
+
end
|
767
|
+
|
768
|
+
it "ISNI" do
|
769
|
+
hsh = { "schemeUri" => "http://isni.org/isni/", "nameIdentifier" => "0000000134596520", "nameIdentifierScheme" => "ISNI" }
|
770
|
+
response = subject.normalize_name_identifier(hsh)
|
771
|
+
expect(response).to eq("https://isni.org/isni/0000000134596520")
|
772
|
+
end
|
773
|
+
|
774
|
+
it "Wikidata" do
|
775
|
+
hsh = {"schemeUri"=>"https://www.wikidata.org/wiki/", "nameIdentifier"=>"Q107529885", "nameIdentifierScheme"=>"Wikidata"}
|
776
|
+
response = subject.normalize_name_identifier(hsh)
|
777
|
+
expect(response).to eq("https://www.wikidata.org/wiki/Q107529885")
|
778
|
+
end
|
779
|
+
end
|
754
780
|
end
|
@@ -136,7 +136,6 @@ describe Commonmeta::Metadata, vcr: true do
|
|
136
136
|
it 'from schema.org' do
|
137
137
|
input = 'https://blog.front-matter.io/posts/eating-your-own-dog-food/'
|
138
138
|
subject = described_class.new(input: input, from: 'schema_org')
|
139
|
-
puts subject.errors
|
140
139
|
expect(subject.valid?).to be true
|
141
140
|
datacite = JSON.parse(subject.datacite)
|
142
141
|
expect(datacite.fetch('titles')).to eq([{ 'title' => 'Eating your own Dog Food' }])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: commonmeta-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Fenner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -663,6 +663,7 @@ files:
|
|
663
663
|
- lib/commonmeta/readers/bibtex_reader.rb
|
664
664
|
- lib/commonmeta/readers/cff_reader.rb
|
665
665
|
- lib/commonmeta/readers/codemeta_reader.rb
|
666
|
+
- lib/commonmeta/readers/commonmeta_reader.rb
|
666
667
|
- lib/commonmeta/readers/crossref_reader.rb
|
667
668
|
- lib/commonmeta/readers/crossref_xml_reader.rb
|
668
669
|
- lib/commonmeta/readers/csl_reader.rb
|
@@ -693,7 +694,7 @@ files:
|
|
693
694
|
- lib/commonmeta/xml_converter.rb
|
694
695
|
- resources/2008/09/xsd.xsl
|
695
696
|
- resources/cff.json
|
696
|
-
- resources/commonmeta_v0.10.
|
697
|
+
- resources/commonmeta_v0.10.6.json
|
697
698
|
- resources/crossref/AccessIndicators.xsd
|
698
699
|
- resources/crossref/JATS-journalpublishing1-3d2-mathml3-elements.xsd
|
699
700
|
- resources/crossref/JATS-journalpublishing1-3d2-mathml3.xsd
|
@@ -719,7 +720,7 @@ files:
|
|
719
720
|
- resources/datacite-resourceType-v4.xsd
|
720
721
|
- resources/datacite-titleType-v4.xsd
|
721
722
|
- resources/datacite-v3.json
|
722
|
-
- resources/datacite-
|
723
|
+
- resources/datacite-v45.json
|
723
724
|
- resources/kernel-3.0/include/datacite-contributorType-v3.xsd
|
724
725
|
- resources/kernel-3.0/include/datacite-dateType-v3.xsd
|
725
726
|
- resources/kernel-3.0/include/datacite-descriptionType-v3.xsd
|
@@ -763,11 +764,14 @@ files:
|
|
763
764
|
- spec/fixtures/citeproc.json
|
764
765
|
- spec/fixtures/codemeta.json
|
765
766
|
- spec/fixtures/codemeta_v2.json
|
767
|
+
- spec/fixtures/commonmeta.json
|
766
768
|
- spec/fixtures/crosscite.json
|
767
769
|
- spec/fixtures/crossref.bib
|
768
770
|
- spec/fixtures/crossref.json
|
769
771
|
- spec/fixtures/crossref.ris
|
770
772
|
- spec/fixtures/crossref.xml
|
773
|
+
- spec/fixtures/datacite-dataset_v4.5.json
|
774
|
+
- spec/fixtures/datacite-instrument.json
|
771
775
|
- spec/fixtures/datacite.json
|
772
776
|
- spec/fixtures/datacite_software.json
|
773
777
|
- spec/fixtures/datacite_software_missing_comma.json
|
@@ -1045,6 +1049,7 @@ files:
|
|
1045
1049
|
- spec/readers/bibtex_reader_spec.rb
|
1046
1050
|
- spec/readers/cff_reader_spec.rb
|
1047
1051
|
- spec/readers/codemeta_reader_spec.rb
|
1052
|
+
- spec/readers/commonmeta_reader_spec.rb
|
1048
1053
|
- spec/readers/crossref_reader_spec.rb
|
1049
1054
|
- spec/readers/crossref_xml_reader_spec.rb
|
1050
1055
|
- spec/readers/csl_reader_spec.rb
|