orcid_client 0.2.2 → 0.2.3

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
  SHA1:
3
- metadata.gz: 14d5bdcfdd4434694f41ed0f1790983ea3c93eb9
4
- data.tar.gz: e8226e9332e5daf02f8d70df610a0060e306bd2b
3
+ metadata.gz: eeaf7b53eebf7c7877d24e9fc458a7a6a307032d
4
+ data.tar.gz: 65e9b253be1606b55d93d8eabddf834a2a10ef7a
5
5
  SHA512:
6
- metadata.gz: be30a372d8ef68ebf6c77c192e64b4681016e42d7a3fe9461d218d7baaf00be0d3200eb46dc02e6e29e8d416ef2115b24b68a1b47661f3efcc29c64fdabe11ae
7
- data.tar.gz: c91d735ed1c063e3b717d421f1bfaf2613d19b10f548fea60f783ed2e6e0f46f806aba0ff586cb273b8914f4a388397d5acbc0afc72dd1f8fbe5aec9d69a34c7
6
+ metadata.gz: 996e7dcb216b8568c2823c7fdbd11abcc84bba831b46e34e0040b79f38d923f0f921a2313c6f478abdfda8f3c533b34d869766482d9b225cfd8a36edce31b80c
7
+ data.tar.gz: 87d4e73f8a67f2a670f5d9b4d1757480c2a1a8a2236b29636c7e3cf62f39b1c57cf03779c38728d4640ff5803bf6940875e9a947e79d780e5d15b35ffe1e6abb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- orcid_client (0.2.2)
4
+ orcid_client (0.2.3)
5
5
  activesupport (~> 4.2, >= 4.2.5)
6
6
  builder (~> 3.2, >= 3.2.2)
7
7
  dotenv (~> 2.1, >= 2.1.1)
@@ -113,4 +113,4 @@ DEPENDENCIES
113
113
  webmock (~> 1.22, >= 1.22.3)
114
114
 
115
115
  BUNDLED WITH
116
- 1.14.3
116
+ 1.12.5
@@ -2,6 +2,11 @@ require 'namae'
2
2
 
3
3
  module OrcidClient
4
4
  module Author
5
+ def validate_orcid(orcid)
6
+ orcid = Array(/\A(?:http:\/\/orcid\.org\/)?(\d{4}[[:space:]-]\d{4}[[:space:]-]\d{4}[[:space:]-]\d{3}[0-9X]+)\z/.match(orcid)).last
7
+ orcid.gsub(/[[:space:]]/, "-") if orcid.present?
8
+ end
9
+
5
10
  # parse author string into CSL format
6
11
  def get_one_author(author)
7
12
  return "" if author.blank?
@@ -38,7 +43,7 @@ module OrcidClient
38
43
  def get_name_identifier(author)
39
44
  name_identifier = author.fetch("nameIdentifier", nil)
40
45
  name_identifier_scheme = author.fetch("nameIdentifierScheme", "orcid").downcase
41
- if name_identifier.present? && name_identifier_scheme == "orcid"
46
+ if name_identifier_scheme == "orcid" && name_identifier = validate_orcid(name_identifier)
42
47
  "http://orcid.org/#{name_identifier}"
43
48
  else
44
49
  nil
@@ -1,3 +1,3 @@
1
1
  module OrcidClient
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -101,7 +101,7 @@ module OrcidClient
101
101
  def insert_titles(xml)
102
102
  if title
103
103
  xml.send(:'work:title') do
104
- xml.send(:'common:title', title)
104
+ xml.send(:'common:title', title.truncate(1000, separator: ' '))
105
105
  end
106
106
  end
107
107
 
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe OrcidClient, vcr: true do
4
+ let(:doi) { "10.5281/zenodo.59983"}
5
+ let(:orcid) { "0000-0001-6528-2027" }
6
+ let(:access_token) { ENV['ACCESS_TOKEN'] }
7
+ let(:notification_access_token) { ENV['NOTIFICATION_ACCESS_TOKEN'] }
8
+ let(:put_code) { "740616" }
9
+ let(:fixture_path) { "spec/fixtures/" }
10
+
11
+ subject { OrcidClient::Work.new(doi: doi, orcid: orcid, access_token: access_token, put_code: put_code) }
12
+
13
+ context "validate_orcid" do
14
+ it "validate_orcid" do
15
+ orcid = "http://orcid.org/0000-0002-2590-225X"
16
+ response = subject.validate_orcid(orcid)
17
+ expect(response).to eq("0000-0002-2590-225X")
18
+ end
19
+
20
+ it "validate_orcid id" do
21
+ orcid = "0000-0002-2590-225X"
22
+ response = subject.validate_orcid(orcid)
23
+ expect(response).to eq("0000-0002-2590-225X")
24
+ end
25
+
26
+ it "validate_orcid with spaces" do
27
+ orcid = "0000 0002 1394 3097"
28
+ response = subject.validate_orcid(orcid)
29
+ expect(response).to eq("0000-0002-1394-3097")
30
+ end
31
+
32
+ it "validate_orcid wrong id" do
33
+ orcid = "0000-0002-1394-309"
34
+ response = subject.validate_orcid(orcid)
35
+ expect(response).to be_nil
36
+ end
37
+ end
38
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orcid_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-02 00:00:00.000000000 Z
11
+ date: 2017-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: maremma
@@ -343,6 +343,7 @@ files:
343
343
  - resources/record_2.0_rc3/search-2.0_rc3.xsd
344
344
  - resources/record_2.0_rc3/work-2.0_rc3.xsd
345
345
  - spec/api_spec.rb
346
+ - spec/author_spec.rb
346
347
  - spec/external_identifier_spec.rb
347
348
  - spec/fixtures/external_identifier.xml
348
349
  - spec/fixtures/vcr_cassettes/OrcidClient/external_identifier/delete/should_delete_external_identifier.yml