commonmeta-ruby 3.0.10 → 3.2.0
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 +37 -36
- data/commonmeta.gemspec +1 -1
- data/lib/commonmeta/metadata_utils.rb +2 -0
- data/lib/commonmeta/readers/json_post_reader.rb +78 -0
- data/lib/commonmeta/utils.rb +19 -0
- data/lib/commonmeta/version.rb +1 -1
- data/spec/author_utils_spec.rb +10 -0
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_item_metadata/blogger_post.yml +94 -0
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_item_metadata/ghost_post.yml +117 -0
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_item_metadata/ghost_post_with_doi.yml +117 -0
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_item_metadata/jekyll_post.yml +170 -0
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_item_metadata/wordpress_post.yml +163 -0
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_post_metadata/blogger_post.yml +94 -0
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_post_metadata/ghost_post_with_doi.yml +117 -0
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_post_metadata/jekyll_post.yml +87 -0
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_post_metadata/wordpress_post.yml +163 -0
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_link/license.yml +221 -0
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_link/url.yml +221 -0
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/json_item_from_rogue_scholar_with_doi.yml +163 -0
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/json_item_from_upstream_blog.yml +243 -0
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/json_post_from_rogue_scholar_with_doi.yml +163 -0
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/json_post_from_upstream_blog.yml +243 -0
- data/spec/readers/json_post_reader_spec.rb +89 -0
- data/spec/utils_spec.rb +330 -314
- data/spec/writers/crossref_xml_writer_spec.rb +183 -137
- metadata +22 -5
@@ -1,173 +1,219 @@
|
|
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 "write metadata as crossref" do
|
7
|
+
it "journal article" do
|
8
8
|
input = "#{fixture_path}crossref.xml"
|
9
9
|
subject = described_class.new(input: input)
|
10
10
|
expect(subject.valid?).to be true
|
11
|
-
expect(subject.id).to eq(
|
12
|
-
expect(subject.url).to eq(
|
13
|
-
crossref_xml = Hash.from_xml(subject.crossref_xml).dig(
|
14
|
-
|
15
|
-
expect(crossref_xml.dig(
|
16
|
-
expect(crossref_xml.dig(
|
17
|
-
expect(crossref_xml.dig(
|
18
|
-
expect(crossref_xml.dig(
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
11
|
+
expect(subject.id).to eq("https://doi.org/10.7554/elife.01567")
|
12
|
+
expect(subject.url).to eq("https://elifesciences.org/articles/01567")
|
13
|
+
crossref_xml = Hash.from_xml(subject.crossref_xml).dig("crossref_result", "query_result",
|
14
|
+
"body", "query", "doi_record", "crossref", "journal")
|
15
|
+
expect(crossref_xml.dig("journal_metadata", "full_title")).to eq("eLife")
|
16
|
+
expect(crossref_xml.dig("journal_article", "doi_data", "doi")).to eq("10.7554/eLife.01567")
|
17
|
+
expect(crossref_xml.dig("journal_article", "citation_list", "citation").length).to eq(27)
|
18
|
+
expect(crossref_xml.dig("journal_article", "citation_list",
|
19
|
+
"citation").first).to eq("article_title" => "APL regulates vascular tissue identity in Arabidopsis",
|
20
|
+
"author" => "Bonke",
|
21
|
+
"cYear" => "2003",
|
22
|
+
"doi" => "10.1038/nature02100",
|
23
|
+
"first_page" => "181",
|
24
|
+
"journal_title" => "Nature",
|
25
|
+
"key" => "bib1",
|
26
|
+
"volume" => "426")
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
30
|
-
subject = described_class.new(input:
|
29
|
+
it "posted_content" do
|
30
|
+
subject = described_class.new(input: "10.1101/2020.12.01.406702", depositor: "test", email: "info@example.org", registrant: "test")
|
31
31
|
expect(subject.valid?).to be true
|
32
|
-
expect(subject.id).to eq(
|
33
|
-
expect(subject.url).to eq(
|
34
|
-
crossref_xml = Hash.from_xml(subject.crossref_xml).dig(
|
35
|
-
expect(crossref_xml.dig(
|
36
|
-
expect(crossref_xml.dig(
|
32
|
+
expect(subject.id).to eq("https://doi.org/10.1101/2020.12.01.406702")
|
33
|
+
expect(subject.url).to eq("http://biorxiv.org/lookup/doi/10.1101/2020.12.01.406702")
|
34
|
+
crossref_xml = Hash.from_xml(subject.crossref_xml).dig("doi_batch", "body", "posted_content")
|
35
|
+
expect(crossref_xml.dig("doi_data", "doi")).to eq("10.1101/2020.12.01.406702")
|
36
|
+
expect(crossref_xml.dig("doi_data", "resource")).to eq("http://biorxiv.org/lookup/doi/10.1101/2020.12.01.406702")
|
37
37
|
end
|
38
38
|
|
39
|
-
it
|
40
|
-
input =
|
41
|
-
subject = described_class.new(input: input, from:
|
39
|
+
it "journal article from datacite" do
|
40
|
+
input = "10.2312/geowissenschaften.1989.7.181"
|
41
|
+
subject = described_class.new(input: input, from: "datacite")
|
42
42
|
expect(subject.valid?).to be false
|
43
43
|
expect(subject.errors).to eq(["property '/descriptions/0' is missing required keys: description"])
|
44
|
-
expect(subject.id).to eq(
|
45
|
-
expect(subject.url).to eq(
|
46
|
-
expect(subject.type).to eq(
|
47
|
-
expect(subject.titles).to eq([{
|
48
|
-
expect(subject.publisher).to eq(
|
49
|
-
crossref_xml = Hash.from_xml(subject.crossref_xml).dig(
|
50
|
-
|
51
|
-
expect(Array.wrap(crossref_xml.dig(
|
52
|
-
expect(Array.wrap(crossref_xml.dig(
|
53
|
-
|
54
|
-
|
55
|
-
expect(crossref_xml.dig(
|
56
|
-
|
44
|
+
expect(subject.id).to eq("https://doi.org/10.2312/geowissenschaften.1989.7.181")
|
45
|
+
expect(subject.url).to eq("https://www.tib.eu/suchen/id/awi:7058a56c5e43afd705af945d01536b9aaeeee491")
|
46
|
+
expect(subject.type).to eq("JournalArticle")
|
47
|
+
expect(subject.titles).to eq([{ "title" => "An Overview of the Geology of Canadian Gold Occurrences" }])
|
48
|
+
expect(subject.publisher).to eq("name" => "VCH Verlagsgesellschaft mbH")
|
49
|
+
crossref_xml = Hash.from_xml(subject.crossref_xml).dig("doi_batch", "body", "journal",
|
50
|
+
"journal_article")
|
51
|
+
expect(Array.wrap(crossref_xml.dig("contributors", "person_name")).length).to eq(1)
|
52
|
+
expect(Array.wrap(crossref_xml.dig("contributors",
|
53
|
+
"person_name")).first).to eq("contributor_role" => "author", "given_name" => "David J",
|
54
|
+
"sequence" => "first", "surname" => "Mossman")
|
55
|
+
expect(crossref_xml.dig("titles",
|
56
|
+
"title")).to eq("An Overview of the Geology of Canadian Gold Occurrences")
|
57
57
|
end
|
58
58
|
|
59
|
-
it
|
60
|
-
input =
|
61
|
-
subject = described_class.new(input: input, from:
|
59
|
+
it "schema.org from front matter" do
|
60
|
+
input = "https://blog.front-matter.io/posts/editorial-by-more-than-200-call-for-emergency-action-to-limit-global-temperature-increases-restore-biodiversity-and-protect-health"
|
61
|
+
subject = described_class.new(input: input, from: "schema_org")
|
62
62
|
expect(subject.valid?).to be true
|
63
|
-
expect(subject.id).to eq(
|
64
|
-
expect(subject.url).to eq(
|
65
|
-
expect(subject.type).to eq(
|
66
|
-
expect(subject.titles).to eq([{
|
67
|
-
expect(subject.creators).to eq([{
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
expect(subject.subjects).to eq([{
|
72
|
-
expect(subject.language).to eq(
|
73
|
-
expect(subject.license).to eq(
|
74
|
-
|
75
|
-
crossref_xml = Hash.from_xml(subject.crossref_xml).dig(
|
76
|
-
expect(crossref_xml.dig(
|
77
|
-
|
63
|
+
expect(subject.id).to eq("https://doi.org/10.53731/r9nqx6h-97aq74v-ag7bw")
|
64
|
+
expect(subject.url).to eq("https://blog.front-matter.io/posts/editorial-by-more-than-200-call-for-emergency-action-to-limit-global-temperature-increases-restore-biodiversity-and-protect-health")
|
65
|
+
expect(subject.type).to eq("Article")
|
66
|
+
expect(subject.titles).to eq([{ "title" => "Editorial by more than 200 health journals: Call for emergency action to limit global temperature increases, restore biodiversity, and protect health" }])
|
67
|
+
expect(subject.creators).to eq([{ "familyName" => "Fenner",
|
68
|
+
"givenName" => "Martin",
|
69
|
+
"id" => "https://orcid.org/0000-0003-1419-2405",
|
70
|
+
"type" => "Person" }])
|
71
|
+
expect(subject.subjects).to eq([{ "subject" => "news" }])
|
72
|
+
expect(subject.language).to eq("en")
|
73
|
+
expect(subject.license).to eq("id" => "CC-BY-4.0",
|
74
|
+
"url" => "https://creativecommons.org/licenses/by/4.0/legalcode")
|
75
|
+
crossref_xml = Hash.from_xml(subject.crossref_xml).dig("doi_batch", "body", "posted_content")
|
76
|
+
expect(crossref_xml.dig("titles",
|
77
|
+
"title")).to eq("Editorial by more than 200 health journals: Call for emergency action to limit global temperature increases, restore biodiversity, and protect health")
|
78
78
|
end
|
79
79
|
|
80
|
-
it
|
81
|
-
input =
|
82
|
-
subject = described_class.new(input: input, from:
|
80
|
+
it "another schema.org from front-matter" do
|
81
|
+
input = "https://blog.front-matter.io/posts/dryad-interview-jen-gibson"
|
82
|
+
subject = described_class.new(input: input, from: "schema_org")
|
83
83
|
expect(subject.valid?).to be true
|
84
|
-
expect(subject.id).to eq(
|
85
|
-
expect(subject.url).to eq(
|
86
|
-
expect(subject.type).to eq(
|
87
|
-
expect(subject.titles).to eq([{
|
88
|
-
expect(subject.creators).to eq([{
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
expect(subject.subjects).to eq([{
|
93
|
-
expect(subject.container).to eq(
|
94
|
-
|
95
|
-
expect(subject.language).to eq(
|
96
|
-
expect(subject.license).to eq(
|
97
|
-
|
98
|
-
crossref_xml = Hash.from_xml(subject.crossref_xml).dig(
|
99
|
-
expect(crossref_xml.dig(
|
84
|
+
expect(subject.id).to eq("https://doi.org/10.53731/rceh7pn-tzg61kj-7zv63")
|
85
|
+
expect(subject.url).to eq("https://blog.front-matter.io/posts/dryad-interview-jen-gibson")
|
86
|
+
expect(subject.type).to eq("Article")
|
87
|
+
expect(subject.titles).to eq([{ "title" => "Dryad: Interview with Jen Gibson" }])
|
88
|
+
expect(subject.creators).to eq([{ "familyName" => "Fenner",
|
89
|
+
"givenName" => "Martin",
|
90
|
+
"id" => "https://orcid.org/0000-0003-1419-2405",
|
91
|
+
"type" => "Person" }])
|
92
|
+
expect(subject.subjects).to eq([{ "subject" => "interview" }])
|
93
|
+
expect(subject.container).to eq("identifier" => "2749-9952", "identifierType" => "ISSN",
|
94
|
+
"title" => "Front Matter", "type" => "Periodical")
|
95
|
+
expect(subject.language).to eq("en")
|
96
|
+
expect(subject.license).to eq("id" => "CC-BY-4.0",
|
97
|
+
"url" => "https://creativecommons.org/licenses/by/4.0/legalcode")
|
98
|
+
crossref_xml = Hash.from_xml(subject.crossref_xml).dig("doi_batch", "body", "posted_content")
|
99
|
+
expect(crossref_xml.dig("titles", "title")).to eq("Dryad: Interview with Jen Gibson")
|
100
100
|
end
|
101
101
|
|
102
|
-
it
|
102
|
+
it "embedded schema.org from front matter" do
|
103
103
|
input = "#{fixture_path}schema_org_front-matter.json"
|
104
|
-
subject = described_class.new(input: input, from:
|
104
|
+
subject = described_class.new(input: input, from: "schema_org")
|
105
105
|
expect(subject.valid?).to be true
|
106
|
-
expect(subject.id).to eq(
|
107
|
-
expect(subject.url).to eq(
|
108
|
-
expect(subject.type).to eq(
|
109
|
-
expect(subject.container).to eq(
|
110
|
-
|
111
|
-
expect(subject.titles).to eq([{
|
112
|
-
crossref_xml = Hash.from_xml(subject.crossref_xml).dig(
|
113
|
-
expect(Array.wrap(crossref_xml.dig(
|
114
|
-
expect(Array.wrap(crossref_xml.dig(
|
115
|
-
|
116
|
-
|
117
|
-
expect(crossref_xml.dig(
|
118
|
-
|
106
|
+
expect(subject.id).to eq("https://doi.org/10.53731/r9nqx6h-97aq74v-ag7bw")
|
107
|
+
expect(subject.url).to eq("https://blog.front-matter.io/posts/editorial-by-more-than-200-call-for-emergency-action-to-limit-global-temperature-increases-restore-biodiversity-and-protect-health")
|
108
|
+
expect(subject.type).to eq("Article")
|
109
|
+
expect(subject.container).to eq("identifier" => "2749-9952", "identifierType" => "ISSN",
|
110
|
+
"title" => "Front Matter", "type" => "Periodical")
|
111
|
+
expect(subject.titles).to eq([{ "title" => "Editorial by more than 200 health journals: Call for emergency action to limit global temperature increases, restore biodiversity, and protect health" }])
|
112
|
+
crossref_xml = Hash.from_xml(subject.crossref_xml).dig("doi_batch", "body", "posted_content")
|
113
|
+
expect(Array.wrap(crossref_xml.dig("contributors", "person_name")).length).to eq(1)
|
114
|
+
expect(Array.wrap(crossref_xml.dig("contributors",
|
115
|
+
"person_name")).first).to eq("ORCID" => "https://orcid.org/0000-0003-1419-2405",
|
116
|
+
"contributor_role" => "author", "given_name" => "Martin", "sequence" => "first", "surname" => "Fenner")
|
117
|
+
expect(crossref_xml.dig("titles",
|
118
|
+
"title")).to eq("Editorial by more than 200 health journals: Call for emergency action to limit global temperature increases, restore biodiversity, and protect health")
|
119
119
|
end
|
120
120
|
|
121
|
-
it
|
122
|
-
input =
|
123
|
-
subject = described_class.new(input: input, from:
|
121
|
+
it "schema.org from another science blog" do
|
122
|
+
input = "https://donnywinston.com/posts/implementing-the-fair-principles-through-fair-enabling-artifacts-and-services/"
|
123
|
+
subject = described_class.new(input: input, from: "schema_org")
|
124
124
|
expect(subject.valid?).to be true
|
125
|
-
expect(subject.id).to eq(
|
126
|
-
expect(subject.url).to eq(
|
127
|
-
expect(subject.type).to eq(
|
128
|
-
expect(subject.titles).to eq([{
|
129
|
-
expect(subject.creators).to eq([{
|
130
|
-
|
131
|
-
|
132
|
-
|
125
|
+
expect(subject.id).to eq("https://doi.org/10.57099/11h5yt3819")
|
126
|
+
expect(subject.url).to eq("https://donnywinston.com/posts/implementing-the-fair-principles-through-fair-enabling-artifacts-and-services")
|
127
|
+
expect(subject.type).to eq("Article")
|
128
|
+
expect(subject.titles).to eq([{ "title" => "Implementing the FAIR Principles Through FAIR-Enabling Artifacts and Services" }])
|
129
|
+
expect(subject.creators).to eq([{ "familyName" => "Winston",
|
130
|
+
"givenName" => "Donny",
|
131
|
+
"id" => "https://orcid.org/0000-0002-8424-0604",
|
132
|
+
"type" => "Person" }])
|
133
133
|
expect(subject.subjects).to eq([])
|
134
|
-
expect(subject.container).to eq(
|
135
|
-
|
136
|
-
expect(subject.language).to eq(
|
137
|
-
expect(subject.date).to eq(
|
138
|
-
|
139
|
-
|
140
|
-
expect(subject.license).to eq(
|
141
|
-
|
142
|
-
crossref_xml = Hash.from_xml(subject.crossref_xml).dig(
|
143
|
-
expect(crossref_xml.dig(
|
144
|
-
|
134
|
+
expect(subject.container).to eq("identifier" => "https://www.polyneme.xyz",
|
135
|
+
"identifierType" => "URL", "type" => "Periodical")
|
136
|
+
expect(subject.language).to eq("en-US")
|
137
|
+
expect(subject.date).to eq("created" => "2022-10-21",
|
138
|
+
"published" => "2022-10-21",
|
139
|
+
"updated" => "2022-10-21")
|
140
|
+
expect(subject.license).to eq("id" => "CC-BY-4.0",
|
141
|
+
"url" => "https://creativecommons.org/licenses/by/4.0/legalcode")
|
142
|
+
crossref_xml = Hash.from_xml(subject.crossref_xml).dig("doi_batch", "body", "posted_content")
|
143
|
+
expect(crossref_xml.dig("titles",
|
144
|
+
"title")).to eq("Implementing the FAIR Principles Through FAIR-Enabling Artifacts and Services")
|
145
145
|
end
|
146
146
|
|
147
|
-
it
|
148
|
-
input =
|
149
|
-
subject = described_class.new(input: input, from:
|
147
|
+
it "schema.org from upstream blog" do
|
148
|
+
input = "https://upstream.force11.org/deep-dive-into-ethics-of-contributor-roles/"
|
149
|
+
subject = described_class.new(input: input, from: "schema_org")
|
150
150
|
|
151
151
|
expect(subject.valid?).to be true
|
152
|
-
expect(subject.id).to eq(
|
153
|
-
expect(subject.url).to eq(
|
154
|
-
expect(subject.type).to eq(
|
155
|
-
expect(subject.titles).to eq([{
|
152
|
+
expect(subject.id).to eq("https://doi.org/10.54900/rf84ag3-98f00rt-0phta")
|
153
|
+
expect(subject.url).to eq("https://upstream.force11.org/deep-dive-into-ethics-of-contributor-roles")
|
154
|
+
expect(subject.type).to eq("Article")
|
155
|
+
expect(subject.titles).to eq([{ "title" => "Deep dive into ethics of Contributor Roles: report of a FORCE11 workshop" }])
|
156
156
|
expect(subject.creators.length).to eq(4)
|
157
|
-
expect(subject.creators.first).to eq(
|
158
|
-
|
159
|
-
|
160
|
-
expect(subject.subjects).to eq([{
|
161
|
-
expect(subject.language).to eq(
|
162
|
-
expect(subject.license).to eq(
|
163
|
-
|
164
|
-
crossref_xml = Hash.from_xml(subject.crossref_xml).dig(
|
165
|
-
expect(Array.wrap(crossref_xml.dig(
|
166
|
-
expect(Array.wrap(crossref_xml.dig(
|
167
|
-
|
168
|
-
|
169
|
-
expect(crossref_xml.dig(
|
170
|
-
|
157
|
+
expect(subject.creators.first).to eq("familyName" => "Hosseini",
|
158
|
+
"givenName" => "Mohammad",
|
159
|
+
"type" => "Person")
|
160
|
+
expect(subject.subjects).to eq([{ "subject" => "news" }])
|
161
|
+
expect(subject.language).to eq("en")
|
162
|
+
expect(subject.license).to eq("id" => "CC-BY-4.0",
|
163
|
+
"url" => "https://creativecommons.org/licenses/by/4.0/legalcode")
|
164
|
+
crossref_xml = Hash.from_xml(subject.crossref_xml).dig("doi_batch", "body", "posted_content")
|
165
|
+
expect(Array.wrap(crossref_xml.dig("contributors", "person_name")).length).to eq(4)
|
166
|
+
expect(Array.wrap(crossref_xml.dig("contributors",
|
167
|
+
"person_name")).first).to eq("contributor_role" => "author", "given_name" => "Mohammad",
|
168
|
+
"sequence" => "first", "surname" => "Hosseini")
|
169
|
+
expect(crossref_xml.dig("titles",
|
170
|
+
"title")).to eq("Deep dive into ethics of Contributor Roles: report of a FORCE11 workshop")
|
171
|
+
end
|
172
|
+
|
173
|
+
it "json_post from upstream blog" do
|
174
|
+
input = "https://rogue-scholar.org/api/posts/wve6rep4"
|
175
|
+
subject = described_class.new(input: input)
|
176
|
+
|
177
|
+
expect(subject.valid?).to be true
|
178
|
+
expect(subject.id).to eq("https://doi.org/10.54900/g0qks-tcz98")
|
179
|
+
expect(subject.url).to eq("https://upstream.force11.org/attempts-at-automating-journal-subject-classification")
|
180
|
+
expect(subject.type).to eq("Article")
|
181
|
+
expect(subject.titles).to eq([{ "title" => "Attempts at automating journal subject classification" }])
|
182
|
+
expect(subject.creators.length).to eq(1)
|
183
|
+
expect(subject.creators.first).to eq("familyName" => "Datta", "givenName" => "Esha", "id" => "https://orcid.org/0000-0001-9165-2757", "type" => "Person")
|
184
|
+
expect(subject.subjects).to eq([{ "subject" => "original research" }])
|
185
|
+
expect(subject.language).to eq("en")
|
186
|
+
expect(subject.license).to eq("id" => "CC-BY-4.0",
|
187
|
+
"url" => "https://creativecommons.org/licenses/by/4.0/legalcode")
|
188
|
+
crossref_xml = Hash.from_xml(subject.crossref_xml).dig("doi_batch", "body", "posted_content")
|
189
|
+
expect(Array.wrap(crossref_xml.dig("contributors", "person_name")).length).to eq(1)
|
190
|
+
expect(Array.wrap(crossref_xml.dig("contributors",
|
191
|
+
"person_name")).first).to eq("ORCID" => "https://orcid.org/0000-0001-9165-2757", "contributor_role" => "author", "given_name" => "Esha", "sequence" => "first", "surname" => "Datta")
|
192
|
+
expect(crossref_xml.dig("titles",
|
193
|
+
"title")).to eq("Attempts at automating journal subject classification")
|
194
|
+
end
|
195
|
+
|
196
|
+
it "json_post from rogue scholar with doi" do
|
197
|
+
input = "https://rogue-scholar.org/api/posts/zkevlyd3"
|
198
|
+
subject = described_class.new(input: input, doi: "10.59350/9ry27-7cz42")
|
199
|
+
|
200
|
+
expect(subject.valid?).to be true
|
201
|
+
expect(subject.id).to eq("https://doi.org/10.59350/9ry27-7cz42")
|
202
|
+
expect(subject.url).to eq("https://wisspub.net/2023/05/23/eu-mitgliedstaaten-betonen-die-rolle-von-wissenschaftsgeleiteten-open-access-modellen-jenseits-von-apcs")
|
203
|
+
expect(subject.type).to eq("Article")
|
204
|
+
expect(subject.titles).to eq([{ "title" => "EU-Mitgliedstaaten betonen die Rolle von wissenschaftsgeleiteten Open-Access-Modellen jenseits von APCs" }])
|
205
|
+
expect(subject.creators.length).to eq(1)
|
206
|
+
expect(subject.creators.first).to eq("familyName"=>"Pampel", "givenName"=>"Heinz", "id"=>"https://orcid.org/0000-0003-3334-2771", "type"=>"Person")
|
207
|
+
expect(subject.subjects).to eq([{"subject"=>"open access"}, {"subject"=>"open access transformation"}, {"subject"=>"open science"}, {"subject"=>"eu"}])
|
208
|
+
expect(subject.language).to eq("de")
|
209
|
+
expect(subject.license).to eq("id" => "CC-BY-4.0",
|
210
|
+
"url" => "https://creativecommons.org/licenses/by/4.0/legalcode")
|
211
|
+
crossref_xml = Hash.from_xml(subject.crossref_xml).dig("doi_batch", "body", "posted_content")
|
212
|
+
expect(Array.wrap(crossref_xml.dig("contributors", "person_name")).length).to eq(1)
|
213
|
+
expect(Array.wrap(crossref_xml.dig("contributors",
|
214
|
+
"person_name")).first).to eq("ORCID"=>"https://orcid.org/0000-0003-3334-2771", "contributor_role"=>"author", "given_name"=>"Heinz", "sequence"=>"first", "surname"=>"Pampel")
|
215
|
+
expect(crossref_xml.dig("titles",
|
216
|
+
"title")).to eq("EU-Mitgliedstaaten betonen die Rolle von wissenschaftsgeleiteten Open-Access-Modellen jenseits von APCs")
|
171
217
|
end
|
172
218
|
end
|
173
219
|
end
|
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.0
|
4
|
+
version: 3.2.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: 2023-04
|
11
|
+
date: 2023-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -226,14 +226,14 @@ dependencies:
|
|
226
226
|
requirements:
|
227
227
|
- - "~>"
|
228
228
|
- !ruby/object:Gem::Version
|
229
|
-
version: 0.
|
229
|
+
version: 1.0.1
|
230
230
|
type: :runtime
|
231
231
|
prerelease: false
|
232
232
|
version_requirements: !ruby/object:Gem::Requirement
|
233
233
|
requirements:
|
234
234
|
- - "~>"
|
235
235
|
- !ruby/object:Gem::Version
|
236
|
-
version: 0.
|
236
|
+
version: 1.0.1
|
237
237
|
- !ruby/object:Gem::Dependency
|
238
238
|
name: loofah
|
239
239
|
requirement: !ruby/object:Gem::Requirement
|
@@ -596,6 +596,7 @@ files:
|
|
596
596
|
- lib/commonmeta/readers/crossref_xml_reader.rb
|
597
597
|
- lib/commonmeta/readers/csl_reader.rb
|
598
598
|
- lib/commonmeta/readers/datacite_reader.rb
|
599
|
+
- lib/commonmeta/readers/json_post_reader.rb
|
599
600
|
- lib/commonmeta/readers/npm_reader.rb
|
600
601
|
- lib/commonmeta/readers/ris_reader.rb
|
601
602
|
- lib/commonmeta/readers/schema_org_reader.rb
|
@@ -1149,6 +1150,17 @@ files:
|
|
1149
1150
|
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_datetime_from_time/nil.yml
|
1150
1151
|
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_datetime_from_time/past.yml
|
1151
1152
|
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_datetime_from_time/present.yml
|
1153
|
+
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_item_metadata/blogger_post.yml
|
1154
|
+
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_item_metadata/ghost_post.yml
|
1155
|
+
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_item_metadata/ghost_post_with_doi.yml
|
1156
|
+
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_item_metadata/jekyll_post.yml
|
1157
|
+
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_item_metadata/wordpress_post.yml
|
1158
|
+
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_post_metadata/blogger_post.yml
|
1159
|
+
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_post_metadata/ghost_post_with_doi.yml
|
1160
|
+
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_post_metadata/jekyll_post.yml
|
1161
|
+
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_post_metadata/wordpress_post.yml
|
1162
|
+
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_link/license.yml
|
1163
|
+
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_link/url.yml
|
1152
1164
|
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_one_author/has_familyName.yml
|
1153
1165
|
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_one_author/has_name_in_display-order_with_ORCID.yml
|
1154
1166
|
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_one_author/name_with_affiliation_crossref.yml
|
@@ -1256,6 +1268,10 @@ files:
|
|
1256
1268
|
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/another_schema_org_from_front-matter.yml
|
1257
1269
|
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/journal_article.yml
|
1258
1270
|
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/journal_article_from_datacite.yml
|
1271
|
+
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/json_item_from_rogue_scholar_with_doi.yml
|
1272
|
+
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/json_item_from_upstream_blog.yml
|
1273
|
+
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/json_post_from_rogue_scholar_with_doi.yml
|
1274
|
+
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/json_post_from_upstream_blog.yml
|
1259
1275
|
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/posted_content.yml
|
1260
1276
|
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/schema_org_from_another_science_blog.yml
|
1261
1277
|
- spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/schema_org_from_front_matter.yml
|
@@ -1338,6 +1354,7 @@ files:
|
|
1338
1354
|
- spec/readers/crossref_xml_reader_spec.rb
|
1339
1355
|
- spec/readers/csl_reader_spec.rb
|
1340
1356
|
- spec/readers/datacite_reader_spec.rb
|
1357
|
+
- spec/readers/json_post_reader_spec.rb
|
1341
1358
|
- spec/readers/npm_reader_spec.rb
|
1342
1359
|
- spec/readers/ris_reader_spec.rb
|
1343
1360
|
- spec/readers/schema_org_reader_spec.rb
|
@@ -1377,7 +1394,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1377
1394
|
- !ruby/object:Gem::Version
|
1378
1395
|
version: '0'
|
1379
1396
|
requirements: []
|
1380
|
-
rubygems_version: 3.4.
|
1397
|
+
rubygems_version: 3.4.13
|
1381
1398
|
signing_key:
|
1382
1399
|
specification_version: 4
|
1383
1400
|
summary: Ruby client library for conversion of scholarly metadata
|