sul_orcid_client 0.2.0 → 0.3.0

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: a962456d9d06f989b7fe1fa4a95922ee3bfab33234baa35f6192398380016dc1
4
+ data.tar.gz: 7a2b53f1c0fc01c27748e6ec226f6ca271a2f356e78f3f5ac45fc9e920758fa3
5
5
  SHA512:
6
- metadata.gz: 1a814db636b2df5ee2294fac3e1303b63d43a868ad4a044a93f9c27e7f7b300a8eeb00b596cc10d6eefa6ac10433a7ceb989c16fccb92b0f3c9f00ec986af979
7
- data.tar.gz: eebc8350317753b68e6cd0d748f90710f4cf7bf50d716d97cadb7021faa1484884d5e6970c62a8b9da025ecee955539152a1908d6a2397273f89af9cc052d500
6
+ metadata.gz: 5d41466f03921824b3325bfec46018a0874bca2f01f8e7609171cbf90f0b077c428806b61483b66158699bafbf2ad2eb4afd1d24e5613bbbef7a477c011359a3
7
+ data.tar.gz: 1fbe6359f523713b2c851c85e249e4b55b4436c4092b4f9b239059750fa6c83507385352d92b78c943c5d8117537904b928c864c13c5b83fef1b24ae150190e7
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.0)
5
5
  activesupport (>= 4.2, < 8)
6
6
  cocina-models (~> 0.90)
7
7
  faraday
@@ -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.0"
5
5
  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.0
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-07-17 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