sul_orcid_client 0.5.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8b24483a206de34db6bc21becab54234e75353619cbf8f81769bb5a498f02c7
4
- data.tar.gz: 66000cc3d23ea9772c1769bad446a4cc029b8aae8b6b0c5cd7b22a3b7a0c6640
3
+ metadata.gz: c69ff816dc3d9337266431f30425887794ef50077d5e66efa667b47c337704b6
4
+ data.tar.gz: c3b186808e1c8fa4f1ebda219f9b23fc313dfea14e87eec7025f10609d96a221
5
5
  SHA512:
6
- metadata.gz: 3c0966d940278bfc2d4a905c1535d8000b68a32f7056be5b6ab61e03b647e64dae9a54868c9eed1775d7f12b58772b4d0615acb67155d51030a9bf6c27c0fe31
7
- data.tar.gz: e4deb9f7563d2117ee600ed2cd00095c78e486b576efbbbbdc237ab6f8c672574a2fa94325193bcc841ded6a8d280cad11adb80cc88d7d074666af93b95476a3
6
+ metadata.gz: c87d4cef98681e21bd0f3cc170f90dd3a4160f3e6162e32d9d5eff9bafe320688aeb45305402b1b364f4b167dd16c4cc08f9afeedfadb993a6058fa44a1cbb79
7
+ data.tar.gz: c6034b1e4f487acadce12faa1c296206faa9fdc5bcde86bf981dfd050f4e825f927947ef24683417fbf22c7a84af28e46cf2fa71d3df953c1231f840bd19e1b3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sul_orcid_client (0.5.0)
4
+ sul_orcid_client (0.6.0)
5
5
  activesupport (>= 4.2)
6
6
  cocina-models (~> 0.90)
7
7
  faraday
@@ -12,7 +12,7 @@ PATH
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
- activesupport (8.0.1)
15
+ activesupport (8.0.2)
16
16
  base64
17
17
  benchmark (>= 0.3)
18
18
  bigdecimal
@@ -27,13 +27,13 @@ GEM
27
27
  uri (>= 0.13.1)
28
28
  addressable (2.8.7)
29
29
  public_suffix (>= 2.0.2, < 7.0)
30
- ast (2.4.2)
30
+ ast (2.4.3)
31
31
  attr_extras (7.1.0)
32
- base64 (0.2.0)
33
- benchmark (0.4.0)
34
- bigdecimal (3.1.9)
35
- byebug (11.1.3)
36
- cocina-models (0.99.4)
32
+ base64 (0.3.0)
33
+ benchmark (0.4.1)
34
+ bigdecimal (3.2.2)
35
+ byebug (12.0.0)
36
+ cocina-models (0.104.1)
37
37
  activesupport
38
38
  deprecation
39
39
  dry-struct (~> 1.0)
@@ -48,15 +48,15 @@ GEM
48
48
  thor
49
49
  zeitwerk (~> 2.1)
50
50
  concurrent-ruby (1.3.5)
51
- connection_pool (2.5.0)
51
+ connection_pool (2.5.3)
52
52
  crack (1.0.0)
53
53
  bigdecimal
54
54
  rexml
55
55
  deprecation (1.1.0)
56
56
  activesupport
57
- diff-lcs (1.5.1)
57
+ diff-lcs (1.6.2)
58
58
  docile (1.4.1)
59
- drb (2.2.1)
59
+ drb (2.2.3)
60
60
  dry-core (1.1.0)
61
61
  concurrent-ruby (~> 1.0)
62
62
  logger
@@ -67,12 +67,12 @@ GEM
67
67
  concurrent-ruby (~> 1.0)
68
68
  dry-core (~> 1.1)
69
69
  zeitwerk (~> 2.6)
70
- dry-struct (1.7.1)
70
+ dry-struct (1.8.0)
71
71
  dry-core (~> 1.1)
72
72
  dry-types (~> 1.8, >= 1.8.2)
73
73
  ice_nine (~> 0.11)
74
74
  zeitwerk (~> 2.6)
75
- dry-types (1.8.2)
75
+ dry-types (1.8.3)
76
76
  bigdecimal (~> 3.0)
77
77
  concurrent-ruby (~> 1.0)
78
78
  dry-core (~> 1.0)
@@ -83,97 +83,107 @@ GEM
83
83
  activesupport (>= 3.0, < 9.0)
84
84
  equivalent-xml (0.6.0)
85
85
  nokogiri (>= 1.4.3)
86
- faraday (2.12.2)
86
+ faraday (2.13.1)
87
87
  faraday-net_http (>= 2.0, < 3.5)
88
88
  json
89
89
  logger
90
- faraday-net_http (3.4.0)
90
+ faraday-net_http (3.4.1)
91
91
  net-http (>= 0.5.0)
92
- faraday-retry (2.2.1)
92
+ faraday-retry (2.3.2)
93
93
  faraday (~> 2.0)
94
- hashdiff (1.1.2)
94
+ hashdiff (1.2.0)
95
95
  hashie (5.0.0)
96
96
  i18n (1.14.7)
97
97
  concurrent-ruby (~> 1.0)
98
98
  ice_nine (0.11.2)
99
- json (2.9.1)
99
+ json (2.12.2)
100
100
  jsonpath (1.1.5)
101
101
  multi_json
102
- jwt (2.10.1)
102
+ jwt (3.1.2)
103
103
  base64
104
- language_server-protocol (3.17.0.4)
105
- logger (1.6.6)
106
- minitest (5.25.4)
104
+ language_server-protocol (3.17.0.5)
105
+ lint_roller (1.1.0)
106
+ logger (1.7.0)
107
+ minitest (5.25.5)
107
108
  multi_json (1.15.0)
108
- multi_xml (0.7.1)
109
+ multi_xml (0.7.2)
109
110
  bigdecimal (~> 3.1)
110
111
  net-http (0.6.0)
111
112
  uri
112
- nokogiri (1.18.2-arm64-darwin)
113
+ nokogiri (1.18.8-arm64-darwin)
113
114
  racc (~> 1.4)
114
- nokogiri (1.18.2-x86_64-darwin)
115
+ nokogiri (1.18.8-x86_64-darwin)
115
116
  racc (~> 1.4)
116
- nokogiri (1.18.2-x86_64-linux-gnu)
117
+ nokogiri (1.18.8-x86_64-linux-gnu)
117
118
  racc (~> 1.4)
118
- oauth2 (2.0.9)
119
- faraday (>= 0.17.3, < 3.0)
120
- jwt (>= 1.0, < 3.0)
119
+ oauth2 (2.0.12)
120
+ faraday (>= 0.17.3, < 4.0)
121
+ jwt (>= 1.0, < 4.0)
122
+ logger (~> 1.2)
121
123
  multi_xml (~> 0.5)
122
124
  rack (>= 1.2, < 4)
123
- snaky_hash (~> 2.0)
124
- version_gem (~> 1.1)
125
+ snaky_hash (~> 2.0, >= 2.0.3)
126
+ version_gem (>= 1.1.8, < 3)
125
127
  openapi_parser (1.0.0)
126
- optimist (3.2.0)
127
- parallel (1.26.3)
128
- parser (3.3.7.1)
128
+ optimist (3.2.1)
129
+ parallel (1.27.0)
130
+ parser (3.3.8.0)
129
131
  ast (~> 2.4.1)
130
132
  racc
131
133
  patience_diff (1.2.0)
132
134
  optimist (~> 3.0)
133
- public_suffix (6.0.1)
135
+ prism (1.4.0)
136
+ public_suffix (6.0.2)
134
137
  racc (1.8.1)
135
- rack (3.1.9)
138
+ rack (3.1.16)
136
139
  rainbow (3.1.1)
137
- rake (13.2.1)
140
+ rake (13.3.0)
138
141
  regexp_parser (2.10.0)
139
- rexml (3.4.0)
140
- rspec (3.13.0)
142
+ rexml (3.4.1)
143
+ rspec (3.13.1)
141
144
  rspec-core (~> 3.13.0)
142
145
  rspec-expectations (~> 3.13.0)
143
146
  rspec-mocks (~> 3.13.0)
144
- rspec-core (3.13.3)
147
+ rspec-core (3.13.5)
145
148
  rspec-support (~> 3.13.0)
146
- rspec-expectations (3.13.3)
149
+ rspec-expectations (3.13.5)
147
150
  diff-lcs (>= 1.2.0, < 2.0)
148
151
  rspec-support (~> 3.13.0)
149
- rspec-mocks (3.13.2)
152
+ rspec-mocks (3.13.5)
150
153
  diff-lcs (>= 1.2.0, < 2.0)
151
154
  rspec-support (~> 3.13.0)
152
- rspec-support (3.13.2)
153
- rubocop (1.71.2)
155
+ rspec-support (3.13.4)
156
+ rubocop (1.77.0)
154
157
  json (~> 2.3)
155
- language_server-protocol (>= 3.17.0)
158
+ language_server-protocol (~> 3.17.0.2)
159
+ lint_roller (~> 1.1.0)
156
160
  parallel (~> 1.10)
157
161
  parser (>= 3.3.0.2)
158
162
  rainbow (>= 2.2.2, < 4.0)
159
163
  regexp_parser (>= 2.9.3, < 3.0)
160
- rubocop-ast (>= 1.38.0, < 2.0)
164
+ rubocop-ast (>= 1.45.1, < 2.0)
161
165
  ruby-progressbar (~> 1.7)
162
166
  unicode-display_width (>= 2.4.0, < 4.0)
163
- rubocop-ast (1.38.0)
164
- parser (>= 3.3.1.0)
165
- rubocop-capybara (2.21.0)
166
- rubocop (~> 1.41)
167
- rubocop-factory_bot (2.26.1)
168
- rubocop (~> 1.61)
169
- rubocop-performance (1.23.1)
170
- rubocop (>= 1.48.1, < 2.0)
171
- rubocop-ast (>= 1.31.1, < 2.0)
172
- rubocop-rspec (3.4.0)
173
- rubocop (~> 1.61)
174
- rubocop-rspec_rails (2.30.0)
175
- rubocop (~> 1.61)
176
- rubocop-rspec (~> 3, >= 3.0.1)
167
+ rubocop-ast (1.45.1)
168
+ parser (>= 3.3.7.2)
169
+ prism (~> 1.4)
170
+ rubocop-capybara (2.22.1)
171
+ lint_roller (~> 1.1)
172
+ rubocop (~> 1.72, >= 1.72.1)
173
+ rubocop-factory_bot (2.27.1)
174
+ lint_roller (~> 1.1)
175
+ rubocop (~> 1.72, >= 1.72.1)
176
+ rubocop-performance (1.25.0)
177
+ lint_roller (~> 1.1)
178
+ rubocop (>= 1.75.0, < 2.0)
179
+ rubocop-ast (>= 1.38.0, < 2.0)
180
+ rubocop-rspec (3.6.0)
181
+ lint_roller (~> 1.1)
182
+ rubocop (~> 1.72, >= 1.72.1)
183
+ rubocop-rspec_rails (2.31.0)
184
+ lint_roller (~> 1.1)
185
+ rubocop (~> 1.72, >= 1.72.1)
186
+ rubocop-rspec (~> 3.5)
177
187
  ruby-progressbar (1.13.0)
178
188
  securerandom (0.4.1)
179
189
  simplecov (0.22.0)
@@ -182,10 +192,10 @@ GEM
182
192
  simplecov_json_formatter (~> 0.1)
183
193
  simplecov-html (0.13.1)
184
194
  simplecov_json_formatter (0.1.4)
185
- snaky_hash (2.0.1)
186
- hashie
187
- version_gem (~> 1.1, >= 1.1.1)
188
- super_diff (0.15.0)
195
+ snaky_hash (2.0.3)
196
+ hashie (>= 0.1.0, < 6)
197
+ version_gem (>= 1.1.8, < 3)
198
+ super_diff (0.16.0)
189
199
  attr_extras (>= 6.2.4)
190
200
  diff-lcs
191
201
  patience_diff
@@ -195,17 +205,18 @@ GEM
195
205
  unicode-display_width (3.1.4)
196
206
  unicode-emoji (~> 4.0, >= 4.0.4)
197
207
  unicode-emoji (4.0.4)
198
- uri (1.0.2)
208
+ uri (1.0.3)
199
209
  vcr (6.3.1)
200
210
  base64
201
- version_gem (1.1.4)
202
- webmock (3.25.0)
211
+ version_gem (1.1.8)
212
+ webmock (3.25.1)
203
213
  addressable (>= 2.8.0)
204
214
  crack (>= 0.3.2)
205
215
  hashdiff (>= 0.4.0, < 2.0.0)
206
- zeitwerk (2.7.1)
216
+ zeitwerk (2.7.3)
207
217
 
208
218
  PLATFORMS
219
+ arm64-darwin-23
209
220
  arm64-darwin-24
210
221
  x86_64-darwin-19
211
222
  x86_64-darwin-22
@@ -227,4 +238,4 @@ DEPENDENCIES
227
238
  webmock
228
239
 
229
240
  BUNDLED WITH
230
- 2.5.14
241
+ 2.6.9
@@ -2,17 +2,7 @@
2
2
 
3
3
  class SulOrcidClient
4
4
  # Helper methods for working with Orcid in Cocina
5
- # NOTE: there is similar code in dor_indexing_app which fetches
6
- # ORCIDs out of cocina. Consider consolidating at some point or keeping in sync.
7
- # see https://github.com/sul-dlss/dor_indexing_app/blob/main/app/services/orcid_builder.rb
8
- # and https://github.com/sul-dlss/dor_indexing_app/issues/1022
9
5
  class CocinaSupport
10
- # @param [Cocina::Models::Contributor] contributor to check
11
- # @return [Boolean] true unless the contributor has a citation status of false
12
- def self.cited?(contributor)
13
- contributor.note.none? { |note| note.type == 'citation status' && note.value == 'false' }
14
- end
15
-
16
6
  # @param [Cocina::Models::Contributor] contributor to check
17
7
  # @return [String, nil] orcid id including host if present
18
8
  # rubocop:disable Metrics/AbcSize
@@ -30,13 +20,5 @@ class SulOrcidClient
30
20
  URI.join(identifier.source.uri, identifier.value).to_s
31
21
  end
32
22
  # rubocop:enable Metrics/AbcSize
33
-
34
- # @param [Cocina::Models::Description] description containing contributors to check
35
- # @return [Array<String>] orcid ids including host if present
36
- # Note that non-cited contributors are excluded.
37
- def self.cited_orcidids(description)
38
- cited_contributors = description.contributor.select { |contributor| cited?(contributor) }
39
- cited_contributors.filter_map { |contributor| orcidid(contributor) }
40
- end
41
23
  end
42
24
  end
@@ -13,8 +13,6 @@ class SulOrcidClient
13
13
  end
14
14
 
15
15
  def map
16
- return unless CocinaSupport.cited?(contributor)
17
-
18
16
  {
19
17
  'credit-name': map_credit_name,
20
18
  'contributor-orcid': map_orcid,
@@ -40,19 +38,49 @@ class SulOrcidClient
40
38
  }
41
39
  end
42
40
 
41
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
43
42
  def name_from_structured_value(structured_value)
44
43
  forename = structured_value.find { |name_part| name_part.type == 'forename' }&.value
45
44
  surname = structured_value.find { |name_part| name_part.type == 'surname' }&.value
46
- [forename, surname].join(' ')
45
+
46
+ if forename.present? || surname.present?
47
+ [forename, surname].compact.join(' ')
48
+ else
49
+ # take first value for the Stanford University organization. Do not map the department/institute suborganization for now.
50
+ structured_value.first&.value
51
+ end
47
52
  end
53
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
48
54
 
49
55
  IDENTIFIER_TYPES = %w[ORCID ROR].freeze
50
56
 
51
57
  def map_orcid
52
- identifier = contributor.identifier.find { |check_identifier| IDENTIFIER_TYPES.include?(check_identifier.type) }
58
+ if contributor.name.first&.structuredValue.present?
59
+ # there could be an identifier in the structuredValue if it has a suborganization
60
+ if contributor.name.first.structuredValue.first&.identifier.present?
61
+ orcid_from_structured_value
62
+ else
63
+ orcid_from_contributor
64
+ end
65
+ else
66
+ orcid_from_contributor
67
+ end
68
+ end
53
69
 
54
- return unless identifier
70
+ def identifier_from_structured_value(structured_value)
71
+ structured_value.identifier.find { |identifier| IDENTIFIER_TYPES.include?(identifier.type) }
72
+ end
73
+
74
+ # the identifier in the structuredValue has the uri in a different properties than a top-level contributor.identifier
75
+ def map_orcid_from_structured_value(identifier)
76
+ {
77
+ uri: identifier.uri || identifier.value,
78
+ path: URI(identifier.uri).path.split('/').last,
79
+ host: identifier.type == 'ORCID' ? 'orcid.org' : 'ror.org'
80
+ }
81
+ end
55
82
 
83
+ def map_orcid_from_contributor(identifier)
56
84
  {
57
85
  uri: URI.join(identifier.source.uri, identifier.value).to_s,
58
86
  path: identifier.value,
@@ -60,6 +88,20 @@ class SulOrcidClient
60
88
  }
61
89
  end
62
90
 
91
+ # find and map an orcid from a contributor.identifier
92
+ def orcid_from_contributor
93
+ identifier = contributor.identifier.find { |check_identifier| IDENTIFIER_TYPES.include?(check_identifier.type) }
94
+ return unless identifier
95
+
96
+ map_orcid_from_contributor(identifier)
97
+ end
98
+
99
+ # find and map an orcid from a contributor.structuredValue.identifier
100
+ def orcid_from_structured_value
101
+ identifier = identifier_from_structured_value(contributor.name.first.structuredValue.first)
102
+ map_orcid_from_structured_value(identifier)
103
+ end
104
+
63
105
  def map_attributes
64
106
  {
65
107
  'contributor-role': map_role
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class SulOrcidClient
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.0'
5
5
  end
@@ -93,7 +93,7 @@ class SulOrcidClient
93
93
  num_pages = (num_results / max_num_returned.to_f).ceil
94
94
 
95
95
  # we already have page 1 of the results
96
- (1..num_pages - 1).each do |page_num|
96
+ (1..num_pages - 1).each do |page_num| # rubocop:disable Lint/AmbiguousRange
97
97
  response = get("/v3.0/#{search_method}/?q=#{query}&start=#{(page_num * max_num_returned) + 1}&rows=#{max_num_returned}")
98
98
  total_response[response_name] += response[response_name]
99
99
  end
@@ -12,12 +12,12 @@ Gem::Specification.new do |spec|
12
12
 
13
13
  spec.summary = 'Interface for interacting with the ORCID API.'
14
14
  spec.description = 'This provides API interaction with the ORCID API'
15
- spec.homepage = 'https://github.com/sul-dlss/sul_orcid_client'
15
+ spec.homepage = 'https://github.com/sul-dlss/orcid_client'
16
16
  spec.required_ruby_version = '>= 3.2.0'
17
17
 
18
18
  spec.metadata['homepage_uri'] = spec.homepage
19
- spec.metadata['source_code_uri'] = 'https://github.com/sul-dlss/sul_orcid_client'
20
- spec.metadata['changelog_uri'] = 'https://github.com/sul-dlss/sul_orcid_client/releases'
19
+ spec.metadata['source_code_uri'] = 'https://github.com/sul-dlss/orcid_client'
20
+ spec.metadata['changelog_uri'] = 'https://github.com/sul-dlss/orcid_client/releases'
21
21
  spec.metadata['rubygems_mfa_required'] = 'true'
22
22
 
23
23
  # Specify which files should be added to the gem when it is released.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sul_orcid_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Mangiafico
8
8
  - Justin Littman
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-02-18 00:00:00.000000000 Z
11
+ date: 2025-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -269,12 +269,12 @@ files:
269
269
  - lib/sul_orcid_client/version.rb
270
270
  - lib/sul_orcid_client/work_mapper.rb
271
271
  - sul_orcid_client.gemspec
272
- homepage: https://github.com/sul-dlss/sul_orcid_client
272
+ homepage: https://github.com/sul-dlss/orcid_client
273
273
  licenses: []
274
274
  metadata:
275
- homepage_uri: https://github.com/sul-dlss/sul_orcid_client
276
- source_code_uri: https://github.com/sul-dlss/sul_orcid_client
277
- changelog_uri: https://github.com/sul-dlss/sul_orcid_client/releases
275
+ homepage_uri: https://github.com/sul-dlss/orcid_client
276
+ source_code_uri: https://github.com/sul-dlss/orcid_client
277
+ changelog_uri: https://github.com/sul-dlss/orcid_client/releases
278
278
  rubygems_mfa_required: 'true'
279
279
  rdoc_options: []
280
280
  require_paths:
@@ -290,7 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
290
  - !ruby/object:Gem::Version
291
291
  version: '0'
292
292
  requirements: []
293
- rubygems_version: 3.6.3
293
+ rubygems_version: 3.6.2
294
294
  specification_version: 4
295
295
  summary: Interface for interacting with the ORCID API.
296
296
  test_files: []