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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +8 -8
  3. data/csl-data.json +538 -0
  4. data/lib/commonmeta/author_utils.rb +103 -71
  5. data/lib/commonmeta/crossref_utils.rb +31 -25
  6. data/lib/commonmeta/metadata.rb +8 -14
  7. data/lib/commonmeta/metadata_utils.rb +4 -3
  8. data/lib/commonmeta/readers/bibtex_reader.rb +3 -3
  9. data/lib/commonmeta/readers/cff_reader.rb +7 -6
  10. data/lib/commonmeta/readers/codemeta_reader.rb +3 -3
  11. data/lib/commonmeta/readers/crossref_reader.rb +131 -124
  12. data/lib/commonmeta/readers/crossref_xml_reader.rb +7 -6
  13. data/lib/commonmeta/readers/csl_reader.rb +3 -4
  14. data/lib/commonmeta/readers/datacite_reader.rb +5 -5
  15. data/lib/commonmeta/readers/json_feed_reader.rb +8 -4
  16. data/lib/commonmeta/readers/npm_reader.rb +2 -2
  17. data/lib/commonmeta/readers/ris_reader.rb +1 -1
  18. data/lib/commonmeta/readers/schema_org_reader.rb +6 -4
  19. data/lib/commonmeta/schema_utils.rb +1 -1
  20. data/lib/commonmeta/utils.rb +4 -2
  21. data/lib/commonmeta/version.rb +1 -1
  22. data/lib/commonmeta/writers/bibtex_writer.rb +1 -1
  23. data/lib/commonmeta/writers/cff_writer.rb +5 -4
  24. data/lib/commonmeta/writers/codemeta_writer.rb +4 -2
  25. data/lib/commonmeta/writers/csv_writer.rb +4 -2
  26. data/lib/commonmeta/writers/datacite_writer.rb +1 -1
  27. data/lib/commonmeta/writers/jats_writer.rb +9 -5
  28. data/lib/commonmeta/writers/ris_writer.rb +2 -1
  29. data/lib/commonmeta/writers/schema_org_writer.rb +7 -4
  30. data/resources/{commonmeta_v0.9.3.json → commonmeta_v0.10.3.json} +138 -55
  31. data/resources/csl-citation.json +99 -0
  32. data/spec/author_utils_spec.rb +16 -16
  33. data/spec/cli_spec.rb +1 -1
  34. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_crossref_metadata/missing_contributor.yml +307 -0
  35. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_datacite_metadata/SoftwareSourceCode.yml +76 -0
  36. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_item_metadata/archived_wordpress_post.yml +119 -0
  37. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/book_oup.yml +107 -0
  38. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/journal_article_plos.yml +407 -0
  39. data/spec/metadata_spec.rb +2 -2
  40. data/spec/readers/bibtex_reader_spec.rb +5 -5
  41. data/spec/readers/cff_reader_spec.rb +127 -127
  42. data/spec/readers/codemeta_reader_spec.rb +11 -11
  43. data/spec/readers/crossref_reader_spec.rb +844 -835
  44. data/spec/readers/crossref_xml_reader_spec.rb +899 -901
  45. data/spec/readers/csl_reader_spec.rb +33 -33
  46. data/spec/readers/datacite_reader_spec.rb +106 -103
  47. data/spec/readers/json_feed_reader_spec.rb +68 -40
  48. data/spec/readers/npm_reader_spec.rb +32 -33
  49. data/spec/readers/ris_reader_spec.rb +36 -36
  50. data/spec/readers/schema_org_reader_spec.rb +289 -288
  51. data/spec/writers/codemeta_writer_spec.rb +19 -20
  52. data/spec/writers/crossref_xml_writer_spec.rb +73 -37
  53. data/spec/writers/datacite_writer_spec.rb +2 -1
  54. metadata +10 -3
@@ -5,7 +5,9 @@ module Commonmeta
5
5
  module CodemetaWriter
6
6
  def codemeta
7
7
  return nil unless valid? || show_errors
8
-
8
+
9
+ authors = Array.wrap(contributors).select { |c| c['contributorRoles'] == ['Author'] }
10
+
9
11
  hsh = {
10
12
  '@context' => id.present? ? 'https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld' : nil,
11
13
  '@type' => Commonmeta::Utils::CM_TO_SO_TRANSLATIONS.fetch(type, 'SoftwareSourceCode'),
@@ -13,7 +15,7 @@ module Commonmeta
13
15
  'identifier' => to_schema_org_identifiers(alternate_identifiers),
14
16
  'codeRepository' => url,
15
17
  'name' => parse_attributes(titles, content: 'title', first: true),
16
- 'authors' => creators,
18
+ 'authors' => to_schema_org(authors),
17
19
  'description' => parse_attributes(descriptions, content: 'description', first: true),
18
20
  'version' => version,
19
21
  'tags' => if subjects.present?
@@ -7,7 +7,9 @@ module Commonmeta
7
7
 
8
8
  def csv
9
9
  return nil unless valid?
10
-
10
+
11
+ authors = contributors.select { |c| c['contributorRoles'] == ['Author'] }
12
+
11
13
  bib = {
12
14
  doi: doi_from_url(id),
13
15
  url: url,
@@ -15,7 +17,7 @@ module Commonmeta
15
17
  state: state,
16
18
  type: Commonmeta::Utils::CM_TO_BIB_TRANSLATIONS.fetch(type, 'misc'),
17
19
  title: parse_attributes(titles, content: 'title', first: true),
18
- author: authors_as_string(creators),
20
+ author: authors_as_string(authors),
19
21
  publisher: publisher['name']
20
22
  }.values
21
23
 
@@ -22,7 +22,7 @@ module Commonmeta
22
22
  'doi' => doi_from_url(id),
23
23
  'url' => url,
24
24
  'types' => types,
25
- 'creators' => Array.wrap(creators).map { |c| datacite_contributor(c) },
25
+ 'creators' => Array.wrap(contributors).map { |c| datacite_contributor(c) },
26
26
  'titles' => titles,
27
27
  'publisher' => publisher.to_h['name'],
28
28
  'container' => container,
@@ -39,10 +39,12 @@ module Commonmeta
39
39
  end
40
40
 
41
41
  def insert_authors(xml)
42
- return unless creators.present?
43
-
42
+ authors = contributors.select { |c| c['contributorRoles'] == ['Author'] }
43
+
44
+ return unless authors.present?
45
+
44
46
  xml.send(:'person-group', 'person-group-type' => 'author') do
45
- Array.wrap(creators).each do |au|
47
+ Array.wrap(authors).each do |au|
46
48
  xml.name do
47
49
  insert_contributor(xml, au)
48
50
  end
@@ -51,10 +53,12 @@ module Commonmeta
51
53
  end
52
54
 
53
55
  def insert_editors(xml)
54
- return unless contributors.present?
56
+ editors = contributors.select { |c| c['contributorRoles'] == ['Editor'] }
57
+
58
+ return unless editors.present?
55
59
 
56
60
  xml.send(:'person-group', 'person-group-type' => 'editor') do
57
- Array.wrap(contributors).each do |con|
61
+ Array.wrap(editors).each do |con|
58
62
  xml.name do
59
63
  insert_contributor(xml, con)
60
64
  end
@@ -4,13 +4,14 @@ module Commonmeta
4
4
  module Writers
5
5
  module RisWriter
6
6
  def ris
7
+ authors = contributors.select { |c| c['contributorRoles'] == ['Author'] }
7
8
  sn = container.to_h['identifier']
8
9
  sn = sn.downcase if sn.present? && container.to_h['identifierType'] == 'DOI'
9
10
  {
10
11
  'TY' => Commonmeta::Utils::CM_TO_RIS_TRANSLATIONS.fetch(type, 'GEN'),
11
12
  'T1' => parse_attributes(titles, content: 'title', first: true),
12
13
  'T2' => container.to_h['title'],
13
- 'AU' => to_ris(creators),
14
+ 'AU' => to_ris(authors),
14
15
  'DO' => doi_from_url(id),
15
16
  'UR' => url,
16
17
  'AB' => parse_attributes(descriptions, content: 'description', first: true),
@@ -2,8 +2,11 @@
2
2
 
3
3
  module Commonmeta
4
4
  module Writers
5
- module SchemaOrgWriter
5
+ module SchemaOrgWriter
6
6
  def schema_hsh
7
+ authors = contributors.select { |c| c['contributorRoles'] == ['Author'] }
8
+ editors = contributors.select { |c| c['contributorRoles'] == ['Editor'] }
9
+
7
10
  { '@context' => 'http://schema.org',
8
11
  '@type' => Commonmeta::Utils::CM_TO_SO_TRANSLATIONS.fetch(type, 'CreativeWork'),
9
12
  '@id' => id,
@@ -11,8 +14,8 @@ module Commonmeta
11
14
  'url' => url,
12
15
  'additionalType' => additional_type,
13
16
  'name' => parse_attributes(titles, content: 'title', first: true),
14
- 'author' => to_schema_org(creators),
15
- 'editor' => to_schema_org(contributors),
17
+ 'author' => to_schema_org(authors),
18
+ 'editor' => to_schema_org(editors),
16
19
  'description' => parse_attributes(descriptions, content: 'description', first: true),
17
20
  'license' => license.to_h['url'],
18
21
  'version' => version,
@@ -32,7 +35,7 @@ module Commonmeta
32
35
  'spatialCoverage' => to_schema_org_spatial_coverage(geo_locations),
33
36
  'citation' => Array.wrap(references).map { |r| to_schema_org_citation(r) },
34
37
  '@reverse' => reverse.presence,
35
- 'contentUrl' => Array.wrap(content_url).unwrap,
38
+ 'contentUrl' => Array.wrap(files).map { |f| f["url"] }.unwrap,
36
39
  'schemaVersion' => schema_version,
37
40
  'periodical' => if type == 'Dataset'
38
41
  nil
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://commonmeta.org/commonmeta_v0.9.3.json",
4
- "title": "Commonmeta v0.9.3",
3
+ "$id": "https://commonmeta.org/commonmeta_v0.10.3.json",
4
+ "title": "Commonmeta v0.10.3",
5
5
  "description": "JSON representation of the Commonmeta schema.",
6
6
  "additionalProperties": false,
7
7
  "definitions": {
@@ -24,6 +24,53 @@
24
24
  },
25
25
  "uniqueItems": true
26
26
  },
27
+ "contributorRole": {
28
+ "description": "The type of contribution made by a contributor",
29
+ "enum": [
30
+ "Author",
31
+ "Editor",
32
+ "Chair",
33
+ "Reviewer",
34
+ "ReviewAssistant",
35
+ "StatsReviewer",
36
+ "ReviewerExternal",
37
+ "Reader",
38
+ "Translator",
39
+ "ContactPerson",
40
+ "DataManager",
41
+ "Distributor",
42
+ "HostingInstitution",
43
+ "Producer",
44
+ "ProjectLeader",
45
+ "ProjectManager",
46
+ "ProjectMember",
47
+ "RegistrationAgency",
48
+ "RegistrationAuthority",
49
+ "RelatedPerson",
50
+ "ResearchGroup",
51
+ "RightsHolder",
52
+ "Researcher",
53
+ "Sponsor",
54
+ "WorkPackageLeader",
55
+ "Conceptualization",
56
+ "DataCuration",
57
+ "FormalAnalysis",
58
+ "FundingAcquisition",
59
+ "Investigation",
60
+ "Methodology",
61
+ "ProjectAdministration",
62
+ "Resources",
63
+ "Software",
64
+ "Supervision",
65
+ "Validation",
66
+ "Visualization",
67
+ "WritingOriginalDraft",
68
+ "WritingReviewEditing",
69
+ "Maintainer",
70
+ "Other"
71
+ ],
72
+ "type": "string"
73
+ },
27
74
  "latitude": {
28
75
  "type": "number",
29
76
  "minimum": -90,
@@ -91,36 +138,52 @@
91
138
  "type": "string",
92
139
  "format": "uri"
93
140
  },
94
- "creators": {
95
- "description": "The creators of the resource.",
141
+ "contributors": {
142
+ "description": "The contributors to the resource.",
96
143
  "type": "array",
97
144
  "items": {
98
145
  "type": "object",
99
146
  "properties": {
100
147
  "id": {
101
- "description": "The unique identifier for the creator.",
102
- "type": "string",
103
- "format": "uri"
148
+ "description": "The unique identifier for the contributor.",
149
+ "type": "string"
104
150
  },
105
151
  "type": {
106
- "description": "The type of the creator.",
152
+ "description": "The type of the contributor.",
107
153
  "type": "string",
108
154
  "enum": ["Organization", "Person"]
109
155
  },
156
+ "contributorRoles": {
157
+ "description": "List of roles assumed by the contributor when working on the resource.",
158
+ "items": {
159
+ "$ref": "#/definitions/contributorRole"
160
+ },
161
+ "type": "array",
162
+ "uniqueItems": true
163
+ },
110
164
  "name": {
111
- "description": "The name of the creator.",
165
+ "description": "The name of the contributor.",
112
166
  "type": "string"
113
167
  },
114
168
  "givenName": {
115
- "description": "The given name of the creator.",
169
+ "description": "The given name of the contributor.",
116
170
  "type": "string"
117
171
  },
118
172
  "familyName": {
119
- "description": "The family name of the creator.",
173
+ "description": "The family name of the contributor.",
120
174
  "type": "string"
121
175
  },
122
176
  "affiliation": { "$ref": "#/definitions/affiliations" }
123
- }
177
+ },
178
+ "anyOf": [
179
+ {
180
+ "required": ["familyName"]
181
+ },
182
+ {
183
+ "required": ["name"]
184
+ }
185
+ ],
186
+ "required": ["type", "contributorRoles"]
124
187
  },
125
188
  "minItems": 1,
126
189
  "uniqueItems": true
@@ -142,8 +205,38 @@
142
205
  },
143
206
  "date": {
144
207
  "description": "The dates for the resource.",
208
+ "$comment": "The date fields are not required. Dates should be formatted as ISO 8601 dates.",
145
209
  "type": "object",
146
- "format": "date"
210
+ "properties": {
211
+ "created": {
212
+ "description": "The date the resource was created.",
213
+ "type": "string"
214
+ },
215
+ "submitted": {
216
+ "description": "The date the resource was submitted.",
217
+ "type": "string"
218
+ },
219
+ "accepted": {
220
+ "description": "The date the resource was accepted.",
221
+ "type": "string"
222
+ },
223
+ "published": {
224
+ "description": "The date the resource was published.",
225
+ "type": "string"
226
+ },
227
+ "updated": {
228
+ "description": "The date the resource was updated.",
229
+ "type": "string"
230
+ },
231
+ "available": {
232
+ "description": "The date the resource was made available.",
233
+ "type": "string"
234
+ },
235
+ "withdrawn": {
236
+ "description": "The date the resource was withdrawn.",
237
+ "type": "string"
238
+ }
239
+ }
147
240
  },
148
241
  "titles": {
149
242
  "description": "The titles of the resource.",
@@ -178,9 +271,11 @@
178
271
  "enum": [
179
272
  "Book",
180
273
  "BookSeries",
274
+ "DataCatalog",
181
275
  "Journal",
182
276
  "Periodical",
183
277
  "ProceedingsSeries",
278
+ "Repository",
184
279
  "Series"
185
280
  ]
186
281
  },
@@ -190,37 +285,6 @@
190
285
  }
191
286
  }
192
287
  },
193
- "contributors": {
194
- "description": "The contributors to the resource.",
195
- "type": "array",
196
- "items": {
197
- "type": "object",
198
- "properties": {
199
- "id": {
200
- "description": "The unique identifier for the contributor.",
201
- "type": "string"
202
- },
203
- "type": {
204
- "description": "The type of the contributor.",
205
- "type": "string",
206
- "enum": ["Organization", "Person"]
207
- },
208
- "name": {
209
- "description": "The name of the contributor.",
210
- "type": "string"
211
- },
212
- "givenName": {
213
- "description": "The given name of the contributor.",
214
- "type": "string"
215
- },
216
- "familyName": {
217
- "description": "The family name of the contributor.",
218
- "type": "string"
219
- },
220
- "affiliation": { "$ref": "#/definitions/affiliations" }
221
- }
222
- }
223
- },
224
288
  "subjects": {
225
289
  "type": "array",
226
290
  "items": {
@@ -271,7 +335,7 @@
271
335
  "properties": {
272
336
  "key": { "type": "string" },
273
337
  "doi": { "type": "string" },
274
- "creator": { "type": "string" },
338
+ "contributor": { "type": "string" },
275
339
  "title": { "type": "string" },
276
340
  "publisher": { "type": "string" },
277
341
  "publicationYear": { "type": "string" },
@@ -281,7 +345,6 @@
281
345
  "lastPage": { "type": "string" },
282
346
  "containerTitle": { "type": "string" },
283
347
  "edition": { "type": "string" },
284
- "contributor": { "type": "string" },
285
348
  "unstructured": { "type": "string" }
286
349
  },
287
350
  "required": ["key"]
@@ -300,17 +363,21 @@
300
363
  "type": {
301
364
  "type": "string",
302
365
  "enum": [
303
- "IsIdenticalTo",
304
366
  "IsNewVersionOf",
305
367
  "IsPreviousVersionOf",
368
+ "IsVersionOf",
369
+ "HasVersion",
306
370
  "IsPartOf",
307
371
  "HasPart",
308
372
  "IsVariantFormOf",
373
+ "IsOriginalFormOf",
374
+ "IsIdenticalTo",
309
375
  "IsTranslationOf",
310
- "IsVersionOf",
311
- "IsReviewOf",
376
+ "IsReviewedBy",
377
+ "Reviews",
312
378
  "IsPreprintOf",
313
- "HasPreprint"
379
+ "HasPreprint",
380
+ "isSupplementTo"
314
381
  ]
315
382
  }
316
383
  },
@@ -421,12 +488,20 @@
421
488
  "required": ["alternateIdentifier", "alternateIdentifierType"]
422
489
  }
423
490
  },
424
- "content_url": {
425
- "description": "The URL of the content of the resource.",
491
+ "files": {
492
+ "description": "The downloadable files for the resource.",
426
493
  "type": "array",
427
494
  "items": {
428
- "type": "string",
429
- "format": "uri"
495
+ "type": "object",
496
+ "properties": {
497
+ "bucket": { "type": "string" },
498
+ "key": { "type": "string" },
499
+ "checksum": { "type": "string" },
500
+ "url": { "type": "string", "format": "uri" },
501
+ "size": { "type": "integer" },
502
+ "mimeType": { "type": "string" }
503
+ },
504
+ "required": ["url"]
430
505
  }
431
506
  },
432
507
  "schema_version": {
@@ -443,5 +518,13 @@
443
518
  "enum": ["findable", "not_found"]
444
519
  }
445
520
  },
446
- "required": ["id", "type", "url", "creators", "titles", "publisher", "date"]
521
+ "required": [
522
+ "id",
523
+ "type",
524
+ "url",
525
+ "contributors",
526
+ "titles",
527
+ "publisher",
528
+ "date"
529
+ ]
447
530
  }
@@ -0,0 +1,99 @@
1
+ {
2
+ "description": "JSON schema for CSL citation objects",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "$id": "https://resource.citationstyles.org/schema/latest/input/json/csl-citation.json",
5
+ "type": "object",
6
+ "properties": {
7
+ "schema": {
8
+ "type": "string",
9
+ "enum": [
10
+ "https://resource.citationstyles.org/schema/latest/input/json/csl-citation.json"
11
+ ]
12
+ },
13
+ "citationID": {
14
+ "type": ["string", "number"]
15
+ },
16
+ "citationItems": {
17
+ "type": "array",
18
+ "items": {
19
+ "type": "object",
20
+ "properties": {
21
+ "id": {
22
+ "type": ["string", "number"]
23
+ },
24
+ "itemData": {
25
+ "$ref": "https://resource.citationstyles.org/schema/v1.0/input/json/csl-data.json#/items"
26
+ },
27
+ "prefix": {
28
+ "type": "string"
29
+ },
30
+ "suffix": {
31
+ "type": "string"
32
+ },
33
+ "locator": {
34
+ "type": "string"
35
+ },
36
+ "label": {
37
+ "type": "string",
38
+ "enum": [
39
+ "act",
40
+ "appendix",
41
+ "article-locator",
42
+ "book",
43
+ "canon",
44
+ "chapter",
45
+ "column",
46
+ "elocation",
47
+ "equation",
48
+ "figure",
49
+ "folio",
50
+ "issue",
51
+ "line",
52
+ "note",
53
+ "opus",
54
+ "page",
55
+ "paragraph",
56
+ "part",
57
+ "rule",
58
+ "scene",
59
+ "section",
60
+ "sub-verbo",
61
+ "supplement",
62
+ "table",
63
+ "timestamp",
64
+ "title-locator",
65
+ "verse",
66
+ "version",
67
+ "volume"
68
+ ]
69
+ },
70
+ "suppress-author": {
71
+ "type": ["string", "number", "boolean"]
72
+ },
73
+ "author-only": {
74
+ "type": ["string", "number", "boolean"]
75
+ },
76
+ "uris": {
77
+ "type": "array",
78
+ "items": {
79
+ "type": "string"
80
+ }
81
+ }
82
+ },
83
+ "required": ["id"],
84
+ "additionalProperties": false
85
+ }
86
+ },
87
+ "properties": {
88
+ "type": "object",
89
+ "properties": {
90
+ "noteIndex": {
91
+ "type": "number"
92
+ }
93
+ },
94
+ "additionalProperties": false
95
+ }
96
+ },
97
+ "required": ["schema", "citationID"],
98
+ "additionalProperties": false
99
+ }
@@ -87,7 +87,7 @@ describe Commonmeta::Metadata, vcr: true do
87
87
  author = { "email" => "info@ucop.edu", "name" => "University of California, Santa Barbara",
88
88
  "role" => { "namespace" => "http://www.ngdc.noaa.gov/metadata/published/xsd/schema/resources/Codelist/gmxCodelists.xml#CI_RoleCode", "roleCode" => "copyrightHolder" }, "type" => "Organization" }
89
89
  response = subject.get_one_author(author)
90
- expect(response).to eq("name" => "University of California, Santa Barbara", "type" => "Organization")
90
+ expect(response).to eq("name" => "University of California, Santa Barbara", "type" => "Organization", "contributorRoles" => ["Author"])
91
91
  end
92
92
 
93
93
  it "has familyName" do
@@ -97,14 +97,14 @@ describe Commonmeta::Metadata, vcr: true do
97
97
  response = subject.get_one_author(meta.dig("creators").first)
98
98
  expect(response).to eq(
99
99
  "id" => "https://orcid.org/0000-0003-1419-2405",
100
- "givenName" => "Martin", "familyName" => "Fenner", "type" => "Person",
100
+ "givenName" => "Martin", "familyName" => "Fenner", "type" => "Person", "contributorRoles" => ["Author"],
101
101
  )
102
102
  end
103
103
 
104
104
  it "has name with title" do
105
105
  author = { "name" => "Tejas S. Sathe, MD" }
106
106
  response = subject.get_one_author(author)
107
- expect(response).to eq("givenName" => "Tejas S.", "familyName" => "Sathe", "type" => "Person")
107
+ expect(response).to eq("givenName" => "Tejas S.", "familyName" => "Sathe", "type" => "Person", "contributorRoles" => ["Author"])
108
108
  end
109
109
 
110
110
  it "has name in display-order with ORCID" do
@@ -112,7 +112,7 @@ describe Commonmeta::Metadata, vcr: true do
112
112
  subject = described_class.new(input: input)
113
113
  meta = JSON.parse(subject.raw).dig("data", "attributes")
114
114
  response = subject.get_one_author(meta.dig("creators").first)
115
- expect(response).to eq("type" => "Person",
115
+ expect(response).to eq("type" => "Person", "contributorRoles" => ["Author"],
116
116
  "id" => "https://orcid.org/0000-0003-4881-1606",
117
117
  "givenName" => "Andrea", "familyName" => "Bedini")
118
118
  end
@@ -123,43 +123,43 @@ describe Commonmeta::Metadata, vcr: true do
123
123
  "type" => "Organization", "role" => { "namespace" => "http://www.ngdc.noaa.gov/metadata/published/xsd/schema/resources/Codelist/gmxCodelists.xml#CI_RoleCode", "roleCode" => "copyrightHolder" } }
124
124
  response = subject.get_one_author(author)
125
125
  expect(response).to eq("name" => "University of California, Santa Barbara",
126
- "type" => "Organization")
126
+ "type" => "Organization", "contributorRoles" => ["Author"])
127
127
  end
128
128
 
129
129
  it "is another organization" do
130
130
  author = { "name" => "University of California, Santa Barbara",
131
131
  "id" => "https://ror.org/02t274463" }
132
132
  response = subject.get_one_author(author)
133
- expect(response).to eq("id" => "https://ror.org/02t274463", "name" => "University of California, Santa Barbara", "type" => "Organization")
133
+ expect(response).to eq("id" => "https://ror.org/02t274463", "name" => "University of California, Santa Barbara", "type" => "Organization", "contributorRoles" => ["Author"])
134
134
  end
135
135
 
136
136
  it "is anonymous" do
137
137
  author = { "id" => "https://ror.org/05745n787" }
138
138
  response = subject.get_one_author(author)
139
- expect(response).to eq("type" => "Person", "affiliation" => [{"id"=>"https://ror.org/05745n787"}])
139
+ expect(response).to eq("type" => "Person", "contributorRoles" => ["Author"], "affiliation" => [{ "id" => "https://ror.org/05745n787" }])
140
140
  end
141
141
 
142
142
  it "name with affiliation crossref" do
143
143
  input = "10.7554/elife.01567"
144
144
  subject = described_class.new(input: input, from: "crossref")
145
- response = subject.get_one_author(subject.creators.first)
145
+ response = subject.get_one_author(subject.contributors.first)
146
146
  expect(response).to eq("affiliation" => [{ "name" => "Department of Plant Molecular Biology, University of Lausanne, Lausanne, Switzerland" }], "familyName" => "Sankar",
147
147
  "givenName" => "Martial",
148
- "type" => "Person")
148
+ "type" => "Person", "contributorRoles" => ["Author"])
149
149
  end
150
150
 
151
151
  it "only familyName and givenName" do
152
152
  input = "https://doi.pangaea.de/10.1594/PANGAEA.836178"
153
153
  subject = described_class.new(input: input, from: "schema_org")
154
- response = subject.get_one_author(subject.creators.first)
155
- expect(response).to eq("type" => "Person", "givenName" => "Emma", "familyName" => "Johansson")
154
+ response = subject.get_one_author(subject.contributors.first)
155
+ expect(response).to eq("type" => "Person", "contributorRoles" => ["Author"], "givenName" => "Emma", "familyName" => "Johansson")
156
156
  end
157
157
 
158
158
  it "affiliation is space" do
159
159
  input = "10.1177/0042098011428175"
160
160
  subject = described_class.new(input: input)
161
- response = subject.get_one_author(subject.creators.first)
162
- expect(response).to eq("familyName"=>"Petrovici", "givenName"=>"Norbert", "type"=>"Person")
161
+ response = subject.get_one_author(subject.contributors.first)
162
+ expect(response).to eq("familyName" => "Petrovici", "givenName" => "Norbert", "type" => "Person", "contributorRoles" => ["Author"])
163
163
  end
164
164
  end
165
165
 
@@ -201,9 +201,9 @@ describe Commonmeta::Metadata, vcr: true do
201
201
 
202
202
  context "get_affiliations" do
203
203
  it "name" do
204
- affiliation = [{ 'name' => 'University of Zurich, Zurich, Switzerland' }]
204
+ affiliation = [{ "name" => "University of Zurich, Zurich, Switzerland" }]
205
205
  response = subject.get_affiliations(affiliation)
206
- expect(response).to eq([{ 'name' => 'University of Zurich, Zurich, Switzerland' }])
206
+ expect(response).to eq([{ "name" => "University of Zurich, Zurich, Switzerland" }])
207
207
  end
208
208
 
209
209
  it "name and ROR ID" do
@@ -216,7 +216,7 @@ describe Commonmeta::Metadata, vcr: true do
216
216
  it "only ROR ID" do
217
217
  affiliation = { "affiliationIdentifier" => "https://ror.org/02t274463" }
218
218
  response = subject.get_affiliations(affiliation)
219
- expect(response).to eq([{"id"=>"https://ror.org/02t274463"}])
219
+ expect(response).to eq([{ "id" => "https://ror.org/02t274463" }])
220
220
  end
221
221
  end
222
222
  end
data/spec/cli_spec.rb CHANGED
@@ -269,7 +269,7 @@ describe Commonmeta::CLI do
269
269
  it 'to datacite invalid' do
270
270
  file = fixture_path + "datacite_missing_creator.xml"
271
271
  subject.options = { to: "datacite", show_errors: "true" }
272
- expect { subject.convert file }.to output(/root is missing required keys: id, type, url, creators, titles, publisher, date/).to_stderr
272
+ expect { subject.convert file }.to output(/root is missing required keys: id, type, url, contributors, titles, publisher, date/).to_stderr
273
273
  end
274
274
 
275
275
  it 'to datacite invalid ignore errors' do