commonmeta-ruby 3.4.5 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +8 -8
- data/csl-data.json +538 -0
- data/lib/commonmeta/author_utils.rb +103 -71
- data/lib/commonmeta/crossref_utils.rb +31 -25
- data/lib/commonmeta/metadata.rb +8 -14
- data/lib/commonmeta/metadata_utils.rb +4 -3
- data/lib/commonmeta/readers/bibtex_reader.rb +3 -3
- data/lib/commonmeta/readers/cff_reader.rb +7 -6
- data/lib/commonmeta/readers/codemeta_reader.rb +3 -3
- data/lib/commonmeta/readers/crossref_reader.rb +131 -124
- data/lib/commonmeta/readers/crossref_xml_reader.rb +7 -6
- data/lib/commonmeta/readers/csl_reader.rb +3 -4
- data/lib/commonmeta/readers/datacite_reader.rb +5 -5
- data/lib/commonmeta/readers/json_feed_reader.rb +8 -4
- data/lib/commonmeta/readers/npm_reader.rb +2 -2
- data/lib/commonmeta/readers/ris_reader.rb +1 -1
- data/lib/commonmeta/readers/schema_org_reader.rb +6 -4
- data/lib/commonmeta/schema_utils.rb +1 -1
- data/lib/commonmeta/utils.rb +4 -2
- data/lib/commonmeta/version.rb +1 -1
- data/lib/commonmeta/writers/bibtex_writer.rb +1 -1
- data/lib/commonmeta/writers/cff_writer.rb +5 -4
- data/lib/commonmeta/writers/codemeta_writer.rb +4 -2
- data/lib/commonmeta/writers/csv_writer.rb +4 -2
- data/lib/commonmeta/writers/datacite_writer.rb +1 -1
- data/lib/commonmeta/writers/jats_writer.rb +9 -5
- data/lib/commonmeta/writers/ris_writer.rb +2 -1
- data/lib/commonmeta/writers/schema_org_writer.rb +7 -4
- data/resources/{commonmeta_v0.9.3.json → commonmeta_v0.10.3.json} +138 -55
- data/resources/csl-citation.json +99 -0
- data/spec/author_utils_spec.rb +16 -16
- data/spec/cli_spec.rb +1 -1
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_crossref_metadata/missing_contributor.yml +307 -0
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_datacite_metadata/SoftwareSourceCode.yml +76 -0
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_item_metadata/archived_wordpress_post.yml +119 -0
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/book_oup.yml +107 -0
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/journal_article_plos.yml +407 -0
- data/spec/metadata_spec.rb +2 -2
- data/spec/readers/bibtex_reader_spec.rb +5 -5
- data/spec/readers/cff_reader_spec.rb +127 -127
- data/spec/readers/codemeta_reader_spec.rb +11 -11
- data/spec/readers/crossref_reader_spec.rb +844 -835
- data/spec/readers/crossref_xml_reader_spec.rb +899 -901
- data/spec/readers/csl_reader_spec.rb +33 -33
- data/spec/readers/datacite_reader_spec.rb +106 -103
- data/spec/readers/json_feed_reader_spec.rb +68 -40
- data/spec/readers/npm_reader_spec.rb +32 -33
- data/spec/readers/ris_reader_spec.rb +36 -36
- data/spec/readers/schema_org_reader_spec.rb +289 -288
- data/spec/writers/codemeta_writer_spec.rb +19 -20
- data/spec/writers/crossref_xml_writer_spec.rb +73 -37
- data/spec/writers/datacite_writer_spec.rb +2 -1
- metadata +10 -3
@@ -1,61 +1,61 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe Commonmeta::Metadata, vcr: true do
|
6
|
-
subject { described_class.new(input: input, from:
|
6
|
+
subject { described_class.new(input: input, from: "csl") }
|
7
7
|
|
8
8
|
let(:input) { "#{fixture_path}citeproc.json" }
|
9
9
|
|
10
|
-
context
|
11
|
-
it
|
10
|
+
context "get citeproc raw" do
|
11
|
+
it "BlogPosting" do
|
12
12
|
expect(subject.raw).to eq(File.read(input).strip)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
context
|
17
|
-
it
|
16
|
+
context "get citeproc metadata" do
|
17
|
+
it "BlogPosting" do
|
18
18
|
expect(subject.valid?).to be true
|
19
|
-
expect(subject.id).to eq(
|
20
|
-
expect(subject.url).to eq(
|
21
|
-
expect(subject.type).to eq(
|
22
|
-
expect(subject.
|
23
|
-
|
24
|
-
expect(subject.titles).to eq([{
|
25
|
-
expect(subject.descriptions.first[
|
26
|
-
expect(subject.date).to eq(
|
19
|
+
expect(subject.id).to eq("https://doi.org/10.5438/4k3m-nyvg")
|
20
|
+
expect(subject.url).to eq("https://blog.datacite.org/eating-your-own-dog-food")
|
21
|
+
expect(subject.type).to eq("Article")
|
22
|
+
expect(subject.contributors).to eq([{ "familyName" => "Fenner", "givenName" => "Martin",
|
23
|
+
"type" => "Person", "contributorRoles" => ["Author"] }])
|
24
|
+
expect(subject.titles).to eq([{ "title" => "Eating your own Dog Food" }])
|
25
|
+
expect(subject.descriptions.first["description"]).to start_with("Eating your own dog food")
|
26
|
+
expect(subject.date).to eq("published" => "2016-12-20")
|
27
27
|
expect(subject.license).to be_nil
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
context
|
32
|
-
it
|
31
|
+
context "get citeproc no categories" do
|
32
|
+
it "BlogPosting" do
|
33
33
|
input = "#{fixture_path}citeproc-no-categories.json"
|
34
34
|
subject = described_class.new(input: input)
|
35
35
|
expect(subject.valid?).to be true
|
36
|
-
expect(subject.id).to eq(
|
37
|
-
expect(subject.url).to eq(
|
38
|
-
expect(subject.type).to eq(
|
39
|
-
expect(subject.
|
40
|
-
|
41
|
-
expect(subject.titles).to eq([{
|
42
|
-
expect(subject.descriptions.first[
|
43
|
-
expect(subject.date).to eq(
|
36
|
+
expect(subject.id).to eq("https://doi.org/10.5072/4k3m-nyvg")
|
37
|
+
expect(subject.url).to eq("https://blog.datacite.org/eating-your-own-dog-food")
|
38
|
+
expect(subject.type).to eq("Article")
|
39
|
+
expect(subject.contributors).to eq([{ "familyName" => "Fenner", "givenName" => "Martin",
|
40
|
+
"type" => "Person", "contributorRoles" => ["Author"] }])
|
41
|
+
expect(subject.titles).to eq([{ "title" => "Eating your own Dog Food" }])
|
42
|
+
expect(subject.descriptions.first["description"]).to start_with("Eating your own dog food")
|
43
|
+
expect(subject.date).to eq("published" => "2016-12-20")
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
context
|
48
|
-
it
|
47
|
+
context "get citeproc no author" do
|
48
|
+
it "Journal article" do
|
49
49
|
input = "#{fixture_path}citeproc-no-author.json"
|
50
50
|
subject = described_class.new(input: input)
|
51
51
|
# expect(subject.valid?).to be true
|
52
|
-
expect(subject.id).to eq(
|
53
|
-
expect(subject.url).to eq(
|
54
|
-
expect(subject.type).to eq(
|
55
|
-
expect(subject.
|
56
|
-
expect(subject.titles).to eq([{
|
57
|
-
expect(subject.descriptions.first[
|
58
|
-
expect(subject.date).to eq(
|
52
|
+
expect(subject.id).to eq("https://doi.org/10.5438/4k3m-nyvg")
|
53
|
+
expect(subject.url).to eq("https://blog.datacite.org/eating-your-own-dog-food")
|
54
|
+
expect(subject.type).to eq("Article")
|
55
|
+
expect(subject.contributors).to eq([{ "name" => ":(unav)", "type" => "Organization", "contributorRoles" => ["Author"] }])
|
56
|
+
expect(subject.titles).to eq([{ "title" => "Eating your own Dog Food" }])
|
57
|
+
expect(subject.descriptions.first["description"]).to start_with("Eating your own dog food")
|
58
|
+
expect(subject.date).to eq("published" => "2016-12-20")
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
@@ -1,156 +1,159 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe Commonmeta::Metadata, vcr: true do
|
6
|
-
context
|
7
|
-
it
|
6
|
+
context "get datacite raw" do
|
7
|
+
it "BlogPosting" do
|
8
8
|
input = "#{fixture_path}datacite.json"
|
9
9
|
subject = described_class.new(input: input)
|
10
10
|
expect(subject.raw).to eq(File.read(input).strip)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
context
|
15
|
-
it
|
14
|
+
context "get datacite metadata" do
|
15
|
+
it "BlogPosting" do
|
16
16
|
input = "#{fixture_path}datacite.json"
|
17
17
|
subject = described_class.new(input: input)
|
18
18
|
# expect(subject.valid?).to be true
|
19
|
-
expect(subject.type).to eq(
|
20
|
-
expect(subject.
|
21
|
-
|
22
|
-
expect(subject.titles).to eq([{
|
19
|
+
expect(subject.type).to eq("Article")
|
20
|
+
expect(subject.contributors).to eq([{ "type" => "Person", "contributorRoles" => ["Author"], "givenName" => "Martin", "familyName" => "Fenner",
|
21
|
+
"id" => "https://orcid.org/0000-0003-1419-2405" }])
|
22
|
+
expect(subject.titles).to eq([{ "title" => "Eating your own Dog Food" }])
|
23
23
|
expect(subject.alternate_identifiers).to be_nil
|
24
|
-
expect(subject.date).to eq(
|
25
|
-
|
26
|
-
|
24
|
+
expect(subject.date).to eq("created" => "2016-12-20",
|
25
|
+
"published" => "2016-12-20",
|
26
|
+
"updated" => "2016-12-20")
|
27
27
|
expect(subject.references.length).to eq(2)
|
28
|
-
expect(subject.references.first).to eq(
|
29
|
-
|
30
|
-
expect(subject.provider).to eq(
|
28
|
+
expect(subject.references.first).to eq("doi" => "https://doi.org/10.5438/0012",
|
29
|
+
"key" => "10.5438/0012")
|
30
|
+
expect(subject.provider).to eq("DataCite")
|
31
31
|
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
33
|
+
it "SoftwareSourceCode" do
|
34
|
+
input = "10.5063/f1m61h5x"
|
35
|
+
subject = Commonmeta::Metadata.new(input: input, from: "datacite")
|
36
|
+
# expect(subject.valid?).to be true
|
37
|
+
expect(subject.id).to eq("https://doi.org/10.5063/f1m61h5x")
|
38
|
+
expect(subject.type).to eq("Software")
|
39
|
+
expect(subject.contributors).to eq([{"contributorRoles"=>["Author"],
|
40
|
+
"name"=>
|
41
|
+
"Jones, Matthew B.; Slaughter, Peter; Nahf, Rob; Boettiger, Carl ; Jones, Chris; Read, Jordan; Walker, Lauren; Hart, Edmund; Chamberlain, Scott",
|
42
|
+
"type"=>"Organization"}])
|
43
|
+
expect(subject.titles).to eq([{"title"=>"dataone: R interface to the DataONE network of data repositories"}])
|
44
|
+
expect(subject.date).to eq("created"=>"2016-03-12", "published"=>"2016", "registered"=>"2016-03-12", "updated"=>"2020-09-18")
|
45
|
+
expect(subject.publisher).to eq("name"=>"KNB Data Repository")
|
46
|
+
expect(subject.provider).to eq("DataCite")
|
47
|
+
end
|
45
48
|
|
46
|
-
it
|
49
|
+
it "SoftwareSourceCode missing_comma" do
|
47
50
|
input = "#{fixture_path}datacite_software_missing_comma.json"
|
48
|
-
subject = described_class.new(input: input, from:
|
51
|
+
subject = described_class.new(input: input, from: "datacite", show_errors: true)
|
49
52
|
# expect(subject.valid?).to be false
|
50
|
-
expect(subject.errors).to eq([
|
53
|
+
expect(subject.errors).to eq(["expected comma, not a string (after doi) at line 4, column 11 [parse.c:416]"])
|
51
54
|
expect(subject.codemeta.nil?).to be(true)
|
52
55
|
end
|
53
56
|
|
54
|
-
it
|
57
|
+
it "SoftwareSourceCode overlapping_keys" do
|
55
58
|
input = "#{fixture_path}datacite_software_overlapping_keys.json"
|
56
|
-
subject = described_class.new(input: input, from:
|
59
|
+
subject = described_class.new(input: input, from: "datacite", show_errors: true)
|
57
60
|
expect(subject.valid?).to be false
|
58
|
-
expect(subject.errors).to eq([
|
61
|
+
expect(subject.errors).to eq(["The same key is defined more than once: id"])
|
59
62
|
expect(subject.codemeta.nil?).to be(true)
|
60
63
|
end
|
61
64
|
|
62
|
-
it
|
63
|
-
input =
|
65
|
+
it "dissertation" do
|
66
|
+
input = "10.3204/desy-2014-01645"
|
64
67
|
subject = described_class.new(input: input)
|
65
68
|
# expect(subject.valid?).to be true
|
66
|
-
expect(subject.id).to eq(
|
67
|
-
expect(subject.type).to eq(
|
68
|
-
expect(subject.
|
69
|
-
|
70
|
-
|
71
|
-
expect(subject.
|
72
|
-
|
69
|
+
expect(subject.id).to eq("https://doi.org/10.3204/desy-2014-01645")
|
70
|
+
expect(subject.type).to eq("Dissertation")
|
71
|
+
expect(subject.contributors.length).to eq(3)
|
72
|
+
expect(subject.contributors.first).to eq("type" => "Person", "contributorRoles" => ["Author"],
|
73
|
+
"givenName" => "Heiko", "familyName" => "Conrad")
|
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"}])
|
75
|
+
expect(subject.titles).to eq([{ "title" => "Dynamics of colloids in molecular glass forming liquids studied via X-ray photon correlation spectroscopy" }])
|
76
|
+
expect(subject.date).to eq("created" => "2018-01-25", "published" => "2014",
|
77
|
+
"registered" => "2018-01-25", "updated" => "2020-09-19")
|
73
78
|
expect(subject.license).to be_nil
|
74
|
-
expect(subject.publisher).to eq(
|
75
|
-
expect(subject.provider).to eq(
|
79
|
+
expect(subject.publisher).to eq("name" => "Deutsches Elektronen-Synchrotron, DESY, Hamburg")
|
80
|
+
expect(subject.provider).to eq("DataCite")
|
76
81
|
end
|
77
82
|
|
78
|
-
it
|
79
|
-
input =
|
83
|
+
it "funding references" do
|
84
|
+
input = "10.26102/2310-6018/2019.24.1.006"
|
80
85
|
subject = described_class.new(input: input)
|
81
86
|
# expect(subject.valid?).to be true
|
82
|
-
expect(subject.id).to eq(
|
83
|
-
expect(subject.type).to eq(
|
84
|
-
expect(subject.
|
85
|
-
expect(subject.
|
86
|
-
|
87
|
+
expect(subject.id).to eq("https://doi.org/10.26102/2310-6018/2019.24.1.006")
|
88
|
+
expect(subject.type).to eq("Document")
|
89
|
+
expect(subject.contributors.length).to eq(2)
|
90
|
+
expect(subject.contributors.first).to eq(
|
91
|
+
"affiliation" => [{ "name" => "Тверская государственная сельскохозяйственная академия" }], "familyName" => "Ганичева", "givenName" => "А.В.", "type" => "Person", "contributorRoles" => ["Author"],
|
87
92
|
)
|
88
|
-
expect(subject.titles.last).to eq(
|
89
|
-
|
90
|
-
expect(subject.date).to eq(
|
91
|
-
|
92
|
-
expect(subject.publisher).to eq(
|
93
|
+
expect(subject.titles.last).to eq("title" => "MODEL OF SYSTEM DYNAMICS OF PROCESS OF TRAINING",
|
94
|
+
"titleType" => "TranslatedTitle")
|
95
|
+
expect(subject.date).to eq("created" => "2019-02-12", "published" => "2019",
|
96
|
+
"registered" => "2019-02-12", "updated" => "2022-08-23")
|
97
|
+
expect(subject.publisher).to eq("name" => "МОДЕЛИРОВАНИЕ, ОПТИМИЗАЦИЯ И ИНФОРМАЦИОННЫЕ ТЕХНОЛОГИИ")
|
93
98
|
expect(subject.license).to be_nil
|
94
99
|
expect(subject.funding_references.count).to eq(1)
|
95
|
-
expect(subject.funding_references.first).to eq(
|
96
|
-
|
97
|
-
expect(subject.provider).to eq(
|
100
|
+
expect(subject.funding_references.first).to eq("awardNumber" => "проект № 170100728",
|
101
|
+
"funderName" => "РФФИ")
|
102
|
+
expect(subject.provider).to eq("DataCite")
|
98
103
|
end
|
99
104
|
|
100
|
-
it
|
101
|
-
input =
|
105
|
+
it "subject scheme" do
|
106
|
+
input = "https://doi.org/10.4232/1.2745"
|
102
107
|
subject = described_class.new(input: input)
|
103
108
|
# expect(subject.valid?).to be true
|
104
|
-
expect(subject.id).to eq(
|
105
|
-
expect(subject.alternate_identifiers).to eq([{
|
106
|
-
{
|
107
|
-
|
108
|
-
expect(subject.type).to eq(
|
109
|
-
expect(subject.
|
110
|
-
'type' => 'Organization' }])
|
111
|
-
expect(subject.contributors.length).to eq(18)
|
109
|
+
expect(subject.id).to eq("https://doi.org/10.4232/1.2745")
|
110
|
+
expect(subject.alternate_identifiers).to eq([{ "alternateIdentifier" => "ZA2745", "alternateIdentifierType" => "ZA-No." },
|
111
|
+
{ "alternateIdentifier" => "Internationale Umfrageprogramme",
|
112
|
+
"alternateIdentifierType" => "FDZ" }])
|
113
|
+
expect(subject.type).to eq("Dataset")
|
114
|
+
expect(subject.contributors.length).to eq(19)
|
112
115
|
expect(subject.contributors.first).to eq(
|
113
|
-
|
116
|
+
"name" => "Europäische Kommission", "contributorRoles" => ["Author"], "type" => "Organization",
|
114
117
|
)
|
115
118
|
expect(subject.titles).to eq([
|
116
|
-
{
|
117
|
-
|
119
|
+
{ "lang" => "de",
|
120
|
+
"title" => "Flash Eurobarometer 54 (Madrid Summit)" }, { "lang" => "en", "title" => "Flash Eurobarometer 54 (Madrid Summit)" }, { "titleType" => "Subtitle", "lang" => "de", "title" => "The Common European Currency" }, { "titleType" => "Subtitle", "lang" => "en", "title" => "The Common European Currency" },
|
118
121
|
])
|
119
|
-
expect(subject.subjects).to eq([{
|
120
|
-
|
121
|
-
|
122
|
-
{
|
123
|
-
|
124
|
-
|
125
|
-
{
|
126
|
-
|
127
|
-
|
128
|
-
{
|
129
|
-
|
130
|
-
|
131
|
-
{
|
132
|
-
|
133
|
-
|
134
|
-
expect(subject.date).to eq(
|
135
|
-
|
122
|
+
expect(subject.subjects).to eq([{ "lang" => "en",
|
123
|
+
"subject" => "KAT12 International Institutions, Relations, Conditions",
|
124
|
+
"subjectScheme" => "ZA" },
|
125
|
+
{ "lang" => "de",
|
126
|
+
"subject" => "Internationale Politik und Internationale Organisationen",
|
127
|
+
"subjectScheme" => "CESSDA Topic Classification" },
|
128
|
+
{ "lang" => "de",
|
129
|
+
"subject" => "Wirtschaftssysteme und wirtschaftliche Entwicklung",
|
130
|
+
"subjectScheme" => "CESSDA Topic Classification" },
|
131
|
+
{ "lang" => "en",
|
132
|
+
"subject" => "International politics and organisations",
|
133
|
+
"subjectScheme" => "CESSDA Topic Classification" },
|
134
|
+
{ "lang" => "en",
|
135
|
+
"subject" => "Economic systems and development",
|
136
|
+
"subjectScheme" => "CESSDA Topic Classification" }])
|
137
|
+
expect(subject.date).to eq("created" => "2012-01-10", "published" => "1996",
|
138
|
+
"registered" => "2010-07-22", "updated" => "2023-02-02")
|
136
139
|
expect(subject.license).to be_nil
|
137
|
-
expect(subject.publisher).to eq(
|
138
|
-
expect(subject.provider).to eq(
|
140
|
+
expect(subject.publisher).to eq("name" => "GESIS Data Archive")
|
141
|
+
expect(subject.provider).to eq("DataCite")
|
139
142
|
end
|
140
143
|
|
141
|
-
it
|
142
|
-
input =
|
144
|
+
it "subject scheme" do
|
145
|
+
input = "https://doi.org/10.6084/m9.figshare.3475223.v1"
|
143
146
|
subject = described_class.new(input: input)
|
144
|
-
expect(subject.id).to eq(
|
145
|
-
expect(subject.type).to eq(
|
146
|
-
expect(subject.
|
147
|
-
|
148
|
-
expect(subject.date).to eq(
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
expect(subject.license).to eq(
|
153
|
-
|
147
|
+
expect(subject.id).to eq("https://doi.org/10.6084/m9.figshare.3475223.v1")
|
148
|
+
expect(subject.type).to eq("Image")
|
149
|
+
expect(subject.contributors).to eq([{ "familyName" => "Franklund", "givenName" => "Clifton",
|
150
|
+
"type" => "Person", "contributorRoles" => ["Author"] }])
|
151
|
+
expect(subject.date).to eq("created" => "2016-07-08",
|
152
|
+
"published" => "2016",
|
153
|
+
"registered" => "2016-07-08",
|
154
|
+
"updated" => "2020-09-04")
|
155
|
+
expect(subject.license).to eq("id" => "CC-BY-4.0",
|
156
|
+
"url" => "https://creativecommons.org/licenses/by/4.0/legalcode")
|
154
157
|
end
|
155
158
|
end
|
156
159
|
end
|