commonmeta-ruby 3.3.7 → 3.3.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a142d529ddbead4512d9a66531983b5dc8849631ccb28a0cc12b9801af7c7e6e
4
- data.tar.gz: 77b47a7afa4e7aa2b0cb82d6dad99da9b01cfaedb0ee6aba90d03187aa8691f5
3
+ metadata.gz: 39731365147aea3875a44db36625a0cd825826f7f0f94755601634b2716fcef9
4
+ data.tar.gz: 7591e80c87796e20933352f49079437a9faac148e47889009a5ee3298471ee4c
5
5
  SHA512:
6
- metadata.gz: 0a672da90701e5d53ba7a91ac095e8577dac584150aa4ca58c095e757d47a9fd473638a662a5402c334e1399574d9596a7dc0d2bb2354f08f4c25cd73992c7d2
7
- data.tar.gz: 69c7a71c0dd770cd0685e792e639cc4d78f02196ce0dbad596107257557b1d4ff5e18e8caefc956d72fabbb45071432004c0653550eb94df6769ef2b8e21e5b6
6
+ metadata.gz: c9c3593d73cadfd1697163801d0505a74c536a93e2a40c2bcaac5e12e7c6e703970a4a207f9282331fe065257ec26856db4e214342926019334e64229b920059
7
+ data.tar.gz: 69a053002420f6aa808b15c6a77344fa02e7a7c26e208a00b7be68d489540356beb47481e8f7565e102905233b51830a1dbd591a4a6435d5bc4c646a3f632d01
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- commonmeta-ruby (3.3.7)
4
+ commonmeta-ruby (3.3.9)
5
5
  activesupport (>= 4.2.5, < 8.0)
6
6
  addressable (~> 2.8.1, < 2.8.2)
7
7
  base32-url (>= 0.7.0, < 1)
@@ -27,7 +27,7 @@ PATH
27
27
  GEM
28
28
  remote: https://rubygems.org/
29
29
  specs:
30
- activesupport (7.0.5)
30
+ activesupport (7.0.5.1)
31
31
  concurrent-ruby (~> 1.0, >= 1.0.2)
32
32
  i18n (>= 1.6, < 2)
33
33
  minitest (>= 5.1)
@@ -113,6 +113,7 @@ GEM
113
113
  oj (~> 3)
114
114
  optimist (~> 3)
115
115
  jwt (2.7.1)
116
+ language_server-protocol (3.17.0.3)
116
117
  latex-decode (0.4.0)
117
118
  link_header (0.0.8)
118
119
  llhttp-ffi (0.4.0)
@@ -186,12 +187,13 @@ GEM
186
187
  rspec-mocks (3.12.5)
187
188
  diff-lcs (>= 1.2.0, < 2.0)
188
189
  rspec-support (~> 3.12.0)
189
- rspec-support (3.12.0)
190
+ rspec-support (3.12.1)
190
191
  rspec-xsd (0.1.0)
191
192
  nokogiri (~> 1.6)
192
193
  rspec (~> 3)
193
- rubocop (1.52.1)
194
+ rubocop (1.53.1)
194
195
  json (~> 2.3)
196
+ language_server-protocol (>= 3.17.0)
195
197
  parallel (~> 1.10)
196
198
  parser (>= 3.2.2.3)
197
199
  rainbow (>= 2.2.2, < 4.0)
@@ -245,7 +247,7 @@ GEM
245
247
  unicode-display_width (2.4.2)
246
248
  unicode-types (1.8.0)
247
249
  uuidtools (2.2.0)
248
- vcr (6.1.0)
250
+ vcr (6.2.0)
249
251
  webmock (3.18.1)
250
252
  addressable (>= 2.8.0)
251
253
  crack (>= 0.3.2)
@@ -49,7 +49,11 @@ module Commonmeta
49
49
  # DataCite metadata
50
50
  type = type[0..-3] if type.is_a?(String) && type.end_with?('al')
51
51
 
52
- if type.blank? && id.is_a?(String) && URI.parse(id).host == 'ror.org'
52
+ if type.blank? && name.blank? && id.is_a?(String) && URI.parse(id).host == 'ror.org'
53
+ type = 'Person'
54
+ author['affiliation'] = { 'affiliationIdentifier' => id }
55
+ id = nil
56
+ elsif type.blank? && id.is_a?(String) && URI.parse(id).host == 'ror.org'
53
57
  type = 'Organization'
54
58
  elsif type.blank? && author['type'] == 'Organization'
55
59
  type = 'Organization'
@@ -59,13 +63,15 @@ module Commonmeta
59
63
  type = 'Person'
60
64
  elsif type.blank? && is_personal_name?(name: name) && name.to_s.exclude?(';')
61
65
  type = 'Person'
66
+ elsif type.blank? && name.present? && !is_personal_name?(name: name)
67
+ type = 'Organization'
62
68
  end
63
69
 
64
70
  # parse author contributor role
65
71
  contributor_type = parse_attributes(author.fetch('contributorType', nil))
66
72
 
67
73
  # split name for type Person into given/family name if not already provided
68
- if type == 'Person' && given_name.blank? && family_name.blank?
74
+ if type == 'Person' && name.present? && given_name.blank? && family_name.blank?
69
75
  Namae.options[:include_particle_in_family] = true
70
76
  names = Namae.parse(name)
71
77
  parsed_name = names.first
@@ -123,8 +129,8 @@ module Commonmeta
123
129
  def is_personal_name?(name: nil)
124
130
  return true if name_exists?(name.to_s.split.first) || name_exists?(name.to_s.split(', ').last)
125
131
 
126
- # check if a name has only one word, e.g. "FamousOrganization"
127
- return false if name.to_s.split(' ').size == 1
132
+ # check if a name has only one word, e.g. "FamousOrganization", not including commas
133
+ return false if name.to_s.split(' ').size == 1 && name.to_s.exclude?(',')
128
134
 
129
135
  # check for suffixes, e.g. "John Smith, MD"
130
136
  return true if %w[MD PhD].include? name.split(', ').last
@@ -181,9 +187,7 @@ module Commonmeta
181
187
  name = (a['name'] || a['__content__']).to_s.squish.presence
182
188
  end
183
189
 
184
- next unless name.present?
185
-
186
- { 'id' => affiliation_identifier, 'name' => name }.compact
190
+ { 'id' => affiliation_identifier, 'name' => name }.compact.presence
187
191
  end.compact.presence
188
192
  end
189
193
 
@@ -95,21 +95,22 @@ module Commonmeta
95
95
  def insert_crossref_creators(xml)
96
96
  xml.contributors do
97
97
  Array.wrap(creators).each_with_index do |creator, index|
98
- if creator["type"] == "Organization"
99
- xml.organization("contributor_role" => "author",
100
- "sequence" => index.zero? ? "first" : "additional") do
101
- insert_crossref_organization(xml, creator)
102
- end
98
+ if creator["type"] == "Organization" && creator["name"].present?
99
+ xml.organization(creator["name"], "contributor_role" => "author",
100
+ "sequence" => index.zero? ? "first" : "additional")
103
101
  elsif creator["givenName"].present? || creator["familyName"].present?
104
102
  xml.person_name("contributor_role" => "author",
105
103
  "sequence" => index.zero? ? "first" : "additional") do
106
104
  insert_crossref_person(xml, creator)
107
105
  end
108
- else
109
- xml.unknown("contributor_role" => "author",
110
- "sequence" => index.zero? ? "first" : "additional") do
106
+ elsif creator["affiliation"].present?
107
+ xml.anonymous("contributor_role" => "author",
108
+ "sequence" => index.zero? ? "first" : "additional") do
111
109
  insert_crossref_anonymous(xml, creator)
112
110
  end
111
+ else
112
+ xml.anonymous("contributor_role" => "author",
113
+ "sequence" => index.zero? ? "first" : "additional")
113
114
  end
114
115
  end
115
116
  end
@@ -125,36 +126,18 @@ module Commonmeta
125
126
  xml.affiliations do
126
127
  xml.institution do
127
128
  xml.institution_name(creator.dig("affiliation", 0, "name")) if creator.dig("affiliation", 0, "name").present?
128
- xml.institution_id(creator.dig("affiliation", 0, "affiliationIdentifier"), "type" => creator.dig("affiliation", 0, "affiliationIdentifierScheme")) if creator.dig("affiliation", 0, "affiliationIdentifier").present?
129
- end
130
- end
131
- end
132
- end
133
-
134
- def insert_crossref_organization(xml, creator)
135
- xml.name(creator["name"]) if creator["name"].present?
136
- if creator["affiliation"].present?
137
- xml.affiliations do
138
- xml.institution do
139
- xml.institution_name(creator.dig("affiliation", 0, "name")) if creator.dig("affiliation", 0, "name").present?
140
- xml.institution_id(creator.dig("affiliation", 0, "affiliationIdentifier"), "type" => creator.dig("affiliation", 0, "affiliationIdentifierScheme")) if creator.dig("affiliation", 0, "affiliationIdentifier").present?
129
+ xml.institution_id(creator.dig("affiliation", 0, "id"), 'type' => "ror") if creator.dig("affiliation", 0, "id").present?
141
130
  end
142
131
  end
143
132
  end
144
133
  end
145
134
 
146
135
  def insert_crossref_anonymous(xml, creator)
147
- if person["affiliation"].present?
148
- xml.anonymous do
149
- xml.affiliations do
150
- xml.institution do
151
- xml.institution_name(creator.dig("affiliation", 0, "name")) if creator.dig("affiliation", 0, "name").present?
152
- xml.institution_id(creator.dig("affiliation", 0, "affiliationIdentifier"), "type" => creator.dig("affiliation", 0, "affiliationIdentifierScheme")) if creator.dig("affiliation", 0, "affiliationIdentifier").present?
153
- end
154
- end
136
+ xml.affiliations do
137
+ xml.institution do
138
+ xml.institution_name(creator.dig("affiliation", 0, "name")) if creator.dig("affiliation", 0, "name").present?
139
+ xml.institution_id(creator.dig("affiliation", 0, "id"), 'type' => "ror") if creator.dig("affiliation", 0, "id").present?
155
140
  end
156
- else
157
- xml.anonymous
158
141
  end
159
142
  end
160
143
 
@@ -5,7 +5,7 @@ require "pathname"
5
5
 
6
6
  module Commonmeta
7
7
  module SchemaUtils
8
- COMMONMETA = File.read(File.expand_path("../../resources/commonmeta_v0.9.1.json",
8
+ COMMONMETA = File.read(File.expand_path("../../resources/commonmeta_v0.9.2.json",
9
9
  __dir__))
10
10
 
11
11
  def json_schema_errors
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Commonmeta
4
- VERSION = '3.3.7'
4
+ VERSION = '3.3.9'
5
5
  end
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://commonmeta.org/commonmeta_v0.9.1.json",
4
- "title": "Commonmeta v0.9.1",
3
+ "$id": "https://commonmeta.org/commonmeta_v0.9.2.json",
4
+ "title": "Commonmeta v0.9.2",
5
5
  "description": "JSON representation of the Commonmeta schema.",
6
6
  "additionalProperties": false,
7
7
  "definitions": {
@@ -13,7 +13,14 @@
13
13
  "id": { "type": "string", "format": "uri" },
14
14
  "name": { "type": "string" }
15
15
  },
16
- "required": ["name"]
16
+ "anyOf": [
17
+ {
18
+ "required": ["id"]
19
+ },
20
+ {
21
+ "required": ["name"]
22
+ }
23
+ ]
17
24
  },
18
25
  "uniqueItems": true
19
26
  },
@@ -78,7 +85,7 @@
78
85
  "description": "The additional type of the resource.",
79
86
  "type": "string"
80
87
  },
81
-
88
+
82
89
  "url": {
83
90
  "description": "The URL of the resource.",
84
91
  "type": "string",
@@ -168,7 +175,14 @@
168
175
  "type": {
169
176
  "description": "The type of the container.",
170
177
  "type": "string",
171
- "enum": ["Book", "BookSeries", "Journal", "Periodical", "ProceedingsSeries", "Series"]
178
+ "enum": [
179
+ "Book",
180
+ "BookSeries",
181
+ "Journal",
182
+ "Periodical",
183
+ "ProceedingsSeries",
184
+ "Series"
185
+ ]
172
186
  },
173
187
  "title": {
174
188
  "description": "The title of the container.",
@@ -1,181 +1,222 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Commonmeta::Metadata, vcr: true do
6
6
  let(:subject) do
7
7
  described_class.new
8
8
  end
9
9
 
10
- context 'is_personal_name?' do
11
- it 'has id' do
12
- author = { 'id' => 'http://orcid.org/0000-0003-1419-2405', 'givenName' => 'Martin', 'familyName' => 'Fenner', 'name' => 'Martin Fenner' }
13
- expect(subject.is_personal_name?(name: author['name'])).to be true
10
+ context "is_personal_name?" do
11
+ it "has id" do
12
+ author = { "id" => "http://orcid.org/0000-0003-1419-2405", "givenName" => "Martin", "familyName" => "Fenner", "name" => "Martin Fenner" }
13
+ expect(subject.is_personal_name?(name: author["name"])).to be true
14
14
  end
15
15
 
16
- it 'has orcid id' do
17
- author = { 'creatorName' => 'Fenner, Martin', 'givenName' => 'Martin', 'familyName' => 'Fenner',
18
- 'nameIdentifier' => { 'schemeURI' => 'http://orcid.org/', 'nameIdentifierScheme' => 'ORCID', '__content__' => '0000-0003-1419-2405' } }
19
- expect(subject.is_personal_name?(name: author['creatorName'])).to be true
16
+ it "has orcid id" do
17
+ author = { "creatorName" => "Fenner, Martin", "givenName" => "Martin", "familyName" => "Fenner",
18
+ "nameIdentifier" => { "schemeURI" => "http://orcid.org/", "nameIdentifierScheme" => "ORCID", "__content__" => "0000-0003-1419-2405" } }
19
+ expect(subject.is_personal_name?(name: author["creatorName"])).to be true
20
20
  end
21
21
 
22
- it 'has family name' do
23
- author = { 'givenName' => 'Martin', 'familyName' => 'Fenner', 'name' => 'Martin Fenner' }
24
- expect(subject.is_personal_name?(name: author['name'])).to be true
22
+ it "has family name" do
23
+ author = { "givenName" => "Martin", "familyName" => "Fenner", "name" => "Martin Fenner" }
24
+ expect(subject.is_personal_name?(name: author["name"])).to be true
25
25
  end
26
26
 
27
- it 'has comma' do
28
- author = { 'name' => 'Fenner, Martin' }
29
- expect(subject.is_personal_name?(name: author['name'])).to be true
27
+ it "has comma" do
28
+ author = { "name" => "Fenner, Martin" }
29
+ expect(subject.is_personal_name?(name: author["name"])).to be true
30
30
  end
31
31
 
32
- it 'has known given name' do
33
- author = { 'name' => 'Martin Fenner' }
34
- expect(subject.is_personal_name?(name: author['name'])).to be true
32
+ it "has known given name" do
33
+ author = { "name" => "Martin Fenner" }
34
+ expect(subject.is_personal_name?(name: author["name"])).to be true
35
35
  end
36
36
 
37
- it 'has unknown given name' do
38
- author = { 'name' => 'Rintze Zelle' }
39
- expect(subject.is_personal_name?(name: author['name'])).to be true
37
+ it "has unknown given name" do
38
+ author = { "name" => "Rintze Zelle" }
39
+ expect(subject.is_personal_name?(name: author["name"])).to be true
40
40
  end
41
41
 
42
- it 'has middle initial' do
43
- author = { 'name' => 'Martin H. Fenner' }
44
- expect(subject.is_personal_name?(name: author['name'])).to be true
42
+ it "has middle initial" do
43
+ author = { "name" => "Martin H. Fenner" }
44
+ expect(subject.is_personal_name?(name: author["name"])).to be true
45
45
  end
46
46
 
47
- it 'has unknown given name and middle initial' do
48
- author = { 'name' => 'Tejas S. Sathe' }
49
- expect(subject.is_personal_name?(name: author['name'])).to be true
47
+ it "has unknown given name and middle initial" do
48
+ author = { "name" => "Tejas S. Sathe" }
49
+ expect(subject.is_personal_name?(name: author["name"])).to be true
50
50
  end
51
51
 
52
- it 'has no info' do
53
- author = { 'name' => 'M Fenner' }
54
- expect(subject.is_personal_name?(name: author['name'])).to be true
52
+ it "has no info" do
53
+ author = { "name" => "M Fenner" }
54
+ expect(subject.is_personal_name?(name: author["name"])).to be true
55
55
  end
56
56
 
57
- it 'name with title' do
58
- author = { 'name' => 'Tejas S. Sathe, MD' }
59
- expect(subject.is_personal_name?(name: author['name'])).to be true
57
+ it "name with title" do
58
+ author = { "name" => "Tejas S. Sathe, MD" }
59
+ expect(subject.is_personal_name?(name: author["name"])).to be true
60
60
  end
61
61
  end
62
62
 
63
- context 'cleanup_author' do
64
- it 'Smith J.' do
65
- author = 'Smith J.'
66
- expect(subject.cleanup_author(author)).to eq('Smith, J.')
63
+ context "cleanup_author" do
64
+ it "Smith J." do
65
+ author = "Smith J."
66
+ expect(subject.cleanup_author(author)).to eq("Smith, J.")
67
67
  end
68
68
 
69
- it 'Smith, John' do
70
- author = 'Smith, John'
71
- expect(subject.cleanup_author(author)).to eq('Smith, John')
69
+ it "Smith, John" do
70
+ author = "Smith, John"
71
+ expect(subject.cleanup_author(author)).to eq("Smith, John")
72
72
  end
73
73
 
74
- it 'John Smith' do
75
- author = 'John Smith'
76
- expect(subject.cleanup_author(author)).to eq('John Smith')
74
+ it "John Smith" do
75
+ author = "John Smith"
76
+ expect(subject.cleanup_author(author)).to eq("John Smith")
77
77
  end
78
78
 
79
- it 'with email' do
80
- author = 'noreply@blogger.com (Roderic Page)'
81
- expect(subject.cleanup_author(author)).to eq('Roderic Page')
79
+ it "with email" do
80
+ author = "noreply@blogger.com (Roderic Page)"
81
+ expect(subject.cleanup_author(author)).to eq("Roderic Page")
82
82
  end
83
83
  end
84
84
 
85
- context 'get_one_author' do
86
- it 'has type organization' do
87
- author = { 'email' => 'info@ucop.edu', 'name' => 'University of California, Santa Barbara',
88
- 'role' => { 'namespace' => 'http://www.ngdc.noaa.gov/metadata/published/xsd/schema/resources/Codelist/gmxCodelists.xml#CI_RoleCode', 'roleCode' => 'copyrightHolder' }, 'type' => 'Organization' }
85
+ context "get_one_author" do
86
+ it "has type organization" do
87
+ author = { "email" => "info@ucop.edu", "name" => "University of California, Santa Barbara",
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")
91
91
  end
92
92
 
93
- it 'has familyName' do
94
- input = 'https://doi.org/10.5438/4K3M-NYVG'
93
+ it "has familyName" do
94
+ input = "https://doi.org/10.5438/4K3M-NYVG"
95
95
  subject = described_class.new(input: input)
96
- meta = JSON.parse(subject.raw).dig('data', 'attributes')
97
- response = subject.get_one_author(meta.dig('creators').first)
96
+ meta = JSON.parse(subject.raw).dig("data", "attributes")
97
+ response = subject.get_one_author(meta.dig("creators").first)
98
98
  expect(response).to eq(
99
- 'id' => 'https://orcid.org/0000-0003-1419-2405',
100
- 'givenName' => 'Martin', 'familyName' => 'Fenner', 'type' => 'Person'
99
+ "id" => "https://orcid.org/0000-0003-1419-2405",
100
+ "givenName" => "Martin", "familyName" => "Fenner", "type" => "Person",
101
101
  )
102
102
  end
103
103
 
104
- it 'has name with title' do
105
- author = { 'name' => "Tejas S. Sathe, MD" }
104
+ it "has name with title" do
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")
108
108
  end
109
109
 
110
- it 'has name in display-order with ORCID' do
111
- input = 'https://doi.org/10.6084/M9.FIGSHARE.4700788'
110
+ it "has name in display-order with ORCID" do
111
+ input = "https://doi.org/10.6084/M9.FIGSHARE.4700788"
112
112
  subject = described_class.new(input: input)
113
- meta = JSON.parse(subject.raw).dig('data', 'attributes')
114
- response = subject.get_one_author(meta.dig('creators').first)
115
- expect(response).to eq('type' => 'Person',
116
- 'id' => 'https://orcid.org/0000-0003-4881-1606',
117
- 'givenName' => 'Andrea', 'familyName' => 'Bedini')
113
+ meta = JSON.parse(subject.raw).dig("data", "attributes")
114
+ response = subject.get_one_author(meta.dig("creators").first)
115
+ expect(response).to eq("type" => "Person",
116
+ "id" => "https://orcid.org/0000-0003-4881-1606",
117
+ "givenName" => "Andrea", "familyName" => "Bedini")
118
118
  end
119
119
 
120
- it 'is organization' do
121
- author = { 'email' => 'info@ucop.edu',
122
- 'name' => { '__content__' => 'University of California, Santa Barbara' },
123
- 'type' => 'Organization', 'role' => { 'namespace' => 'http://www.ngdc.noaa.gov/metadata/published/xsd/schema/resources/Codelist/gmxCodelists.xml#CI_RoleCode', 'roleCode' => 'copyrightHolder' } }
120
+ it "is organization" do
121
+ author = { "email" => "info@ucop.edu",
122
+ "name" => { "__content__" => "University of California, Santa Barbara" },
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
- expect(response).to eq('name' => 'University of California, Santa Barbara',
126
- 'type' => 'Organization')
125
+ expect(response).to eq("name" => "University of California, Santa Barbara",
126
+ "type" => "Organization")
127
127
  end
128
128
 
129
- it 'name with affiliation crossref' do
130
- input = '10.7554/elife.01567'
131
- subject = described_class.new(input: input, from: 'crossref')
129
+ it "is another organization" do
130
+ author = { "name" => "University of California, Santa Barbara",
131
+ "id" => "https://ror.org/02t274463" }
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")
134
+ end
135
+
136
+ it "is anonymous" do
137
+ author = { "id" => "https://ror.org/05745n787" }
138
+ response = subject.get_one_author(author)
139
+ expect(response).to eq("type" => "Person", "affiliation" => [{"id"=>"https://ror.org/05745n787"}])
140
+ end
141
+
142
+ it "name with affiliation crossref" do
143
+ input = "10.7554/elife.01567"
144
+ subject = described_class.new(input: input, from: "crossref")
132
145
  response = subject.get_one_author(subject.creators.first)
133
- expect(response).to eq('affiliation' => [{ 'name' => 'Department of Plant Molecular Biology, University of Lausanne, Lausanne, Switzerland' }], 'familyName' => 'Sankar',
134
- 'givenName' => 'Martial',
135
- 'type' => 'Person')
146
+ expect(response).to eq("affiliation" => [{ "name" => "Department of Plant Molecular Biology, University of Lausanne, Lausanne, Switzerland" }], "familyName" => "Sankar",
147
+ "givenName" => "Martial",
148
+ "type" => "Person")
136
149
  end
137
150
 
138
- it 'only familyName and givenName' do
139
- input = 'https://doi.pangaea.de/10.1594/PANGAEA.836178'
140
- subject = described_class.new(input: input, from: 'schema_org')
151
+ it "only familyName and givenName" do
152
+ input = "https://doi.pangaea.de/10.1594/PANGAEA.836178"
153
+ subject = described_class.new(input: input, from: "schema_org")
141
154
  response = subject.get_one_author(subject.creators.first)
142
- expect(response).to eq('type' => 'Person', 'givenName' => 'Emma', 'familyName' => 'Johansson')
155
+ expect(response).to eq("type" => "Person", "givenName" => "Emma", "familyName" => "Johansson")
156
+ end
157
+
158
+ it "affiliation is space" do
159
+ input = "10.1177/0042098011428175"
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")
143
163
  end
144
164
  end
145
165
 
146
- context 'authors_as_string' do
166
+ context "authors_as_string" do
147
167
  let(:authors) do
148
- [{ 'type' => 'Person',
149
- 'id' => 'https://orcid.org/0000-0003-0077-4738',
150
- 'givenName' => 'Matt',
151
- 'familyName' => 'Jones' },
152
- { 'type' => 'Person',
153
- 'id' => 'https://orcid.org/0000-0002-2192-403X',
154
- 'givenName' => 'Peter',
155
- 'familyName' => 'Slaughter' },
156
- { 'type' => 'Organization',
157
- 'id' => 'https://ror.org/02t274463',
158
- 'name' => 'University of California, Santa Barbara' }]
159
- end
160
-
161
- it 'authors' do
168
+ [{ "type" => "Person",
169
+ "id" => "https://orcid.org/0000-0003-0077-4738",
170
+ "givenName" => "Matt",
171
+ "familyName" => "Jones" },
172
+ { "type" => "Person",
173
+ "id" => "https://orcid.org/0000-0002-2192-403X",
174
+ "givenName" => "Peter",
175
+ "familyName" => "Slaughter" },
176
+ { "type" => "Organization",
177
+ "id" => "https://ror.org/02t274463",
178
+ "name" => "University of California, Santa Barbara" }]
179
+ end
180
+
181
+ it "authors" do
162
182
  response = subject.authors_as_string(authors[0..1])
163
- expect(response).to eq('Jones, Matt and Slaughter, Peter')
183
+ expect(response).to eq("Jones, Matt and Slaughter, Peter")
164
184
  end
165
185
 
166
- it 'single author' do
186
+ it "single author" do
167
187
  response = subject.authors_as_string(authors.first)
168
- expect(response).to eq('Jones, Matt')
188
+ expect(response).to eq("Jones, Matt")
169
189
  end
170
190
 
171
- it 'no author' do
191
+ it "no author" do
172
192
  response = subject.authors_as_string(nil)
173
193
  expect(response.nil?).to be(true)
174
194
  end
175
195
 
176
- it 'with organization' do
196
+ it "with organization" do
177
197
  response = subject.authors_as_string(authors)
178
- expect(response).to eq('Jones, Matt and Slaughter, Peter and {University of California, Santa Barbara}')
198
+ expect(response).to eq("Jones, Matt and Slaughter, Peter and {University of California, Santa Barbara}")
199
+ end
200
+ end
201
+
202
+ context "get_affiliations" do
203
+ it "name" do
204
+ affiliation = [{ 'name' => 'University of Zurich, Zurich, Switzerland' }]
205
+ response = subject.get_affiliations(affiliation)
206
+ expect(response).to eq([{ 'name' => 'University of Zurich, Zurich, Switzerland' }])
207
+ end
208
+
209
+ it "name and ROR ID" do
210
+ affiliation = { "id" => "https://ror.org/02t274463",
211
+ "name" => "University of California, Santa Barbara" }
212
+ response = subject.get_affiliations(affiliation)
213
+ expect(response).to eq([{ "name" => "University of California, Santa Barbara" }])
214
+ end
215
+
216
+ it "only ROR ID" do
217
+ affiliation = { "affiliationIdentifier" => "https://ror.org/02t274463" }
218
+ response = subject.get_affiliations(affiliation)
219
+ expect(response).to eq([{"id"=>"https://ror.org/02t274463"}])
179
220
  end
180
221
  end
181
222
  end