sul_orcid_client 0.2.0 → 0.3.1

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: 94e61c08976837c4f5fc946beca72656f4443258eace1a0c22c0d40884cb6e10
4
- data.tar.gz: 8186d27f99e87462626a57aaa858abd33b8746615fde51148a2a9a3db76b67b1
3
+ metadata.gz: 57218fe5c199745f0479d48ffde6483d94ec7dac3f33d278bb37a796bcd5534a
4
+ data.tar.gz: 21824eef4efdb0c1c668483b1d4b1c4e42f7d8417db77c0ef85eb79d6cbe1fa6
5
5
  SHA512:
6
- metadata.gz: 1a814db636b2df5ee2294fac3e1303b63d43a868ad4a044a93f9c27e7f7b300a8eeb00b596cc10d6eefa6ac10433a7ceb989c16fccb92b0f3c9f00ec986af979
7
- data.tar.gz: eebc8350317753b68e6cd0d748f90710f4cf7bf50d716d97cadb7021faa1484884d5e6970c62a8b9da025ecee955539152a1908d6a2397273f89af9cc052d500
6
+ metadata.gz: 5623cd78ba366d9ddf1e33aa6eb858d787aca52deee5c569a7ae6fa1333e8f2134b39781aac6c47e772367ed4d51a4eea348ea728acb2ba4b8c64697d3041ff4
7
+ data.tar.gz: 64c1672225217bbd8b6cc7b962bea2549ef2432558902a396919778ede223fa78922b54dc73a7eee4087c5bada798c53fb4abe86e385afc35cf87199a989bf38
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sul_orcid_client (0.2.0)
4
+ sul_orcid_client (0.3.1)
5
5
  activesupport (>= 4.2, < 8)
6
6
  cocina-models (~> 0.90)
7
7
  faraday
@@ -12,15 +12,16 @@ PATH
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
- activesupport (7.0.6)
15
+ activesupport (7.0.7)
16
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
17
  i18n (>= 1.6, < 2)
18
18
  minitest (>= 5.1)
19
19
  tzinfo (~> 2.0)
20
- addressable (2.8.4)
20
+ addressable (2.8.5)
21
21
  public_suffix (>= 2.0.2, < 6.0)
22
22
  ast (2.4.2)
23
23
  attr_extras (7.1.0)
24
+ base64 (0.1.1)
24
25
  byebug (11.1.3)
25
26
  cocina-models (0.90.0)
26
27
  activesupport
@@ -37,7 +38,7 @@ GEM
37
38
  super_diff
38
39
  thor
39
40
  zeitwerk (~> 2.1)
40
- commonmarker (0.23.9)
41
+ commonmarker (0.23.10)
41
42
  concurrent-ruby (1.2.2)
42
43
  crack (0.4.5)
43
44
  rexml
@@ -45,7 +46,7 @@ GEM
45
46
  activesupport
46
47
  diff-lcs (1.5.0)
47
48
  docile (1.4.0)
48
- dry-core (1.0.0)
49
+ dry-core (1.0.1)
49
50
  concurrent-ruby (~> 1.0)
50
51
  zeitwerk (~> 2.6)
51
52
  dry-inflector (1.0.0)
@@ -85,12 +86,12 @@ GEM
85
86
  jwt (2.7.1)
86
87
  language_server-protocol (3.17.0.3)
87
88
  lint_roller (1.1.0)
88
- minitest (5.18.1)
89
+ minitest (5.19.0)
89
90
  multi_json (1.15.0)
90
91
  multi_xml (0.6.0)
91
- nokogiri (1.15.3-x86_64-darwin)
92
+ nokogiri (1.15.4-x86_64-darwin)
92
93
  racc (~> 1.4)
93
- nokogiri (1.15.3-x86_64-linux)
94
+ nokogiri (1.15.4-x86_64-linux)
94
95
  racc (~> 1.4)
95
96
  oauth2 (2.0.9)
96
97
  faraday (>= 0.17.3, < 3.0)
@@ -102,7 +103,7 @@ GEM
102
103
  openapi3_parser (0.9.2)
103
104
  commonmarker (~> 0.17)
104
105
  openapi_parser (0.15.0)
105
- optimist (3.0.1)
106
+ optimist (3.1.0)
106
107
  parallel (1.23.0)
107
108
  parser (3.2.2.3)
108
109
  ast (~> 2.4.1)
@@ -115,7 +116,7 @@ GEM
115
116
  rainbow (3.1.1)
116
117
  rake (13.0.6)
117
118
  regexp_parser (2.8.1)
118
- rexml (3.2.5)
119
+ rexml (3.2.6)
119
120
  rspec (3.12.0)
120
121
  rspec-core (~> 3.12.0)
121
122
  rspec-expectations (~> 3.12.0)
@@ -129,16 +130,18 @@ GEM
129
130
  diff-lcs (>= 1.2.0, < 2.0)
130
131
  rspec-support (~> 3.12.0)
131
132
  rspec-support (3.12.1)
132
- rss (0.2.9)
133
+ rss (0.3.0)
133
134
  rexml
134
- rubocop (1.52.1)
135
+ rubocop (1.56.1)
136
+ base64 (~> 0.1.1)
135
137
  json (~> 2.3)
138
+ language_server-protocol (>= 3.17.0)
136
139
  parallel (~> 1.10)
137
140
  parser (>= 3.2.2.3)
138
141
  rainbow (>= 2.2.2, < 4.0)
139
142
  regexp_parser (>= 1.8, < 3.0)
140
143
  rexml (>= 3.2.5, < 4.0)
141
- rubocop-ast (>= 1.28.0, < 2.0)
144
+ rubocop-ast (>= 1.28.1, < 2.0)
142
145
  ruby-progressbar (~> 1.7)
143
146
  unicode-display_width (>= 2.4.0, < 3.0)
144
147
  rubocop-ast (1.29.0)
@@ -147,10 +150,10 @@ GEM
147
150
  rubocop (~> 1.41)
148
151
  rubocop-factory_bot (2.23.1)
149
152
  rubocop (~> 1.33)
150
- rubocop-performance (1.18.0)
153
+ rubocop-performance (1.19.0)
151
154
  rubocop (>= 1.7.0, < 2.0)
152
155
  rubocop-ast (>= 0.4.0)
153
- rubocop-rspec (2.22.0)
156
+ rubocop-rspec (2.23.2)
154
157
  rubocop (~> 1.33)
155
158
  rubocop-capybara (~> 2.17)
156
159
  rubocop-factory_bot (~> 2.22)
@@ -165,18 +168,18 @@ GEM
165
168
  snaky_hash (2.0.1)
166
169
  hashie
167
170
  version_gem (~> 1.1, >= 1.1.1)
168
- standard (1.30.1)
171
+ standard (1.31.0)
169
172
  language_server-protocol (~> 3.17.0.2)
170
173
  lint_roller (~> 1.0)
171
- rubocop (~> 1.52.0)
174
+ rubocop (~> 1.56.0)
172
175
  standard-custom (~> 1.0.0)
173
- standard-performance (~> 1.1.0)
176
+ standard-performance (~> 1.2)
174
177
  standard-custom (1.0.2)
175
178
  lint_roller (~> 1.0)
176
179
  rubocop (~> 1.50)
177
- standard-performance (1.1.1)
180
+ standard-performance (1.2.0)
178
181
  lint_roller (~> 1.1)
179
- rubocop-performance (~> 1.18.0)
182
+ rubocop-performance (~> 1.19.0)
180
183
  super_diff (0.10.0)
181
184
  attr_extras (>= 6.2.4)
182
185
  diff-lcs
@@ -191,7 +194,7 @@ GEM
191
194
  addressable (>= 2.8.0)
192
195
  crack (>= 0.3.2)
193
196
  hashdiff (>= 0.4.0, < 2.0.0)
194
- zeitwerk (2.6.8)
197
+ zeitwerk (2.6.11)
195
198
 
196
199
  PLATFORMS
197
200
  x86_64-darwin-22
data/README.md CHANGED
@@ -29,8 +29,8 @@ require "sul_orcid_client"
29
29
  client = SulOrcidClient.configure(
30
30
  client_id: Settings.orcid.client_id,
31
31
  client_secret: Settings.orcid.client_secret,
32
- base_url: Settings.orcid.base_url
33
- base_public_url: Settings.orcid.base_public_url
32
+ base_url: Settings.orcid.base_url,
33
+ base_public_url: Settings.orcid.base_public_url,
34
34
  base_auth_url: Settings.orcid.base_auth_url
35
35
  )
36
36
  client.fetch_works(orcidid: 'https://sandbox.orcid.org/0000-0002-7262-6251')
@@ -46,8 +46,8 @@ to be sure configuration has already occurred, e.g.:
46
46
  SulOrcidClient.configure(
47
47
  client_id: Settings.orcid.client_id,
48
48
  client_secret: Settings.orcid.client_secret,
49
- base_url: Settings.orcid.base_url
50
- base_public_url: Settings.orcid.base_public_url
49
+ base_url: Settings.orcid.base_url,
50
+ base_public_url: Settings.orcid.base_public_url,
51
51
  base_auth_url: Settings.orcid.base_auth_url
52
52
  )
53
53
 
@@ -0,0 +1,27 @@
1
+ class SulOrcidClient
2
+ # Helper methods for working with Orcid in Cocina
3
+ class CocinaSupport
4
+ # @param [Cocina::Models::Contributor] contributor to check
5
+ # @return [Boolean] true unless the contributor has a citation status of false
6
+ def self.cited?(contributor)
7
+ contributor.note.none? { |note| note.type == "citation status" && note.value == "false" }
8
+ end
9
+
10
+ # @param [Cocina::Models::Contributor] contributor to check
11
+ # @return [String, nil] orcid id including host if present
12
+ def self.orcidid(contributor)
13
+ identifier = contributor.identifier.find { |identifier| identifier.type == "ORCID" }
14
+ return unless identifier
15
+
16
+ URI.join(identifier.source.uri, identifier.value).to_s
17
+ end
18
+
19
+ # @param [Cocina::Models::Description] description containing contributors to check
20
+ # @return [Array<String>] orcid ids including host if present
21
+ # Note that non-cited contributors are excluded.
22
+ def self.cited_orcidids(description)
23
+ cited_contributors = description.contributor.select { |contributor| cited?(contributor) }
24
+ cited_contributors.map { |contributor| orcidid(contributor) }.compact
25
+ end
26
+ end
27
+ end
@@ -12,7 +12,7 @@ class SulOrcidClient
12
12
  end
13
13
 
14
14
  def map
15
- return unless cited?
15
+ return unless CocinaSupport.cited?(contributor)
16
16
 
17
17
  {
18
18
  "credit-name": map_credit_name,
@@ -25,10 +25,6 @@ class SulOrcidClient
25
25
 
26
26
  attr_reader :contributor
27
27
 
28
- def cited?
29
- contributor.note.none? { |note| note.type == "citation status" && note.value == "false" }
30
- end
31
-
32
28
  def map_credit_name
33
29
  value = if contributor.name.first&.structuredValue.present?
34
30
  name_from_structured_value(contributor.name.first.structuredValue)
@@ -68,12 +64,12 @@ class SulOrcidClient
68
64
  end
69
65
 
70
66
  MARC_RELATOR_MAP = {
71
- "aut" => "Author",
72
- "cmp" => "Author",
73
- "ctb" => "Author",
74
- "cre" => "Author",
75
- "edt" => "Editor",
76
- "rth" => "Principal investigator"
67
+ "aut" => "author",
68
+ "cmp" => "author",
69
+ "ctb" => "author",
70
+ "cre" => "author",
71
+ "edt" => "editor",
72
+ "rth" => "principal-investigator"
77
73
  }
78
74
 
79
75
  def map_role
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class SulOrcidClient
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.1"
5
5
  end
@@ -136,6 +136,8 @@ class SulOrcidClient
136
136
  work.merge({"put-code" => put_code}).to_json,
137
137
  "Content-Type" => "application/vnd.orcid+json")
138
138
 
139
+ raise "ORCID.org API returned #{response.status} when updating #{put_code} for #{orcidid}. The author may have previously deleted this work from their ORCID profile." if response.status == 404
140
+
139
141
  raise "ORCID.org API returned #{response.status} when updating #{put_code} for #{orcidid}" unless response.status == 200
140
142
  true
141
143
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sul_orcid_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Mangiafico
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2023-07-14 00:00:00.000000000 Z
12
+ date: 2023-08-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -217,6 +217,7 @@ files:
217
217
  - README.md
218
218
  - Rakefile
219
219
  - lib/sul_orcid_client.rb
220
+ - lib/sul_orcid_client/cocina_support.rb
220
221
  - lib/sul_orcid_client/contributor_mapper.rb
221
222
  - lib/sul_orcid_client/version.rb
222
223
  - lib/sul_orcid_client/work_mapper.rb
@@ -243,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
244
  - !ruby/object:Gem::Version
244
245
  version: '0'
245
246
  requirements: []
246
- rubygems_version: 3.4.14
247
+ rubygems_version: 3.4.10
247
248
  signing_key:
248
249
  specification_version: 4
249
250
  summary: Interface for interacting with the ORCID API.