omniauth-orcid 1.0.27 → 1.0.28

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: 236c44683b914245ce9d81d36a4a101c1e697a59
4
- data.tar.gz: 75a18a56830e6313b2af49fa1f924d0040909270
3
+ metadata.gz: be8ac6054fc7fffbb4aff8dec4a87de75190f6cd
4
+ data.tar.gz: c79f88f018d30d56d6c3011bf0ab583a4577fe40
5
5
  SHA512:
6
- metadata.gz: 2e7a9099f5a52648baf4dfe611d8c41e810f6002bb050b26168304629ae5605651587a051bea1d11bf27c2692332bd1c3cdac0cd2caddc78ce9e1eb0b740b544
7
- data.tar.gz: c1bb88e1b5de7965e95514cb9c07c7b4f48bf5af275f1e28ee52892d12e149301f69783b9351c9b27816ca5a6dffb89170aaff90fc06074fdf460e4441aac0da
6
+ metadata.gz: af6265b2e9d9ce3d3303bd47b0b2c4b4356bc12906732fbe463fef3f9cf486857b92084c4577340601215bb7deb84639ef0d59e9fb8df6551abe9cd98913a2d6
7
+ data.tar.gz: b160d02e565f93ba778bc529c7d46bab2c5ccbf52881a07855ae4d2f997f3aa32dba0749b4ca03a543b71266208ba63648c7f2eb78126e7e3b41fcd59ab9c0b6
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Orcid
3
- VERSION = "1.0.27"
3
+ VERSION = "1.0.28"
4
4
  end
5
5
  end
@@ -91,28 +91,31 @@ module OmniAuth
91
91
  uid { access_token.params["orcid"] }
92
92
 
93
93
  info do
94
- { name: access_token.params["name"],
94
+ { name: raw_info[:name],
95
95
  email: nil,
96
- nickname: access_token.params["orcid"],
97
96
  first_name: raw_info[:first_name],
98
97
  last_name: raw_info[:last_name],
99
98
  description: raw_info[:description],
100
99
  urls: raw_info[:urls]
101
- }
100
+ }
102
101
  end
103
102
 
104
103
  extra do
105
104
  skip_info? ? {} : { :raw_info => raw_info }
106
105
  end
107
106
 
107
+ def request_info
108
+ client.request(:get, "https://pub.orcid.org/v#{API_VERSION}/#{uid}/orcid-bio", headers: { accept: 'application/json' }).parsed || {}
109
+ end
110
+
108
111
  def raw_info
109
- info = client.request(:get, "https://pub.orcid.org/v#{API_VERSION}/#{uid}/orcid-bio", headers: { accept: 'application/json' }).parsed || {}
110
- orcid_bio = info.fetch('orcid-profile', {}).fetch('orcid-bio', {})
112
+ orcid_bio = request_info.fetch('orcid-profile', {}).fetch('orcid-bio', {})
111
113
 
112
- { first_name: orcid_bio.fetch('personal-details', {}).fetch('given-names', {}).fetch('value', nil),
114
+ { name: orcid_bio.fetch('personal-details', {}).fetch('credit-name', {}).fetch('value', nil),
115
+ first_name: orcid_bio.fetch('personal-details', {}).fetch('given-names', {}).fetch('value', nil),
113
116
  last_name: orcid_bio.fetch('personal-details', {}).fetch('family-name', {}).fetch('value', nil),
114
- other_names: orcid_bio.fetch('personal-details', {}).fetch('other-names', [{}]).map { |other_name| other_name.fetch('other-name', {}).fetch('value', nil) },
115
- description: personal_details.fetch('biography', {}).fetch('value', nil),
117
+ other_names: orcid_bio.fetch('personal-details', {}).fetch('other-names', {}).fetch('other-name', [{}]).map { |other_name| other_name.fetch('value', nil) },
118
+ description: orcid_bio.fetch('biography', {}).fetch('value', nil),
116
119
  urls: {}
117
120
  }
118
121
  end
@@ -23,35 +23,49 @@ describe OmniAuth::Strategies::ORCID do
23
23
 
24
24
  describe 'uid' do
25
25
  before do
26
- allow(subject).to receive(:raw_info).and_return(raw_info_hash)
26
+ allow(subject).to receive(:request_info).and_return(request_info_hash)
27
27
  end
28
28
 
29
29
  it 'should return the uid' do
30
- expect(subject.uid).to eq(raw_info_hash['orcid'])
30
+ expect(subject.uid).to eq(1)
31
31
  end
32
32
  end
33
33
 
34
34
  describe 'info' do
35
35
  before do
36
- allow(subject).to receive(:raw_info).and_return(raw_info_hash)
36
+ allow(subject).to receive(:request_info).and_return(request_info_hash)
37
37
  end
38
38
 
39
- it 'should returns the name' do
40
- expect(subject.info[:name]).to eq(raw_info_hash['name'])
39
+ it 'should return name' do
40
+ expect(subject.info[:name]).to eq("Martin Fenner")
41
+ end
42
+
43
+ it 'should return first_name' do
44
+ expect(subject.info[:first_name]).to eq("Martin")
45
+ end
46
+
47
+ it 'should return last_name' do
48
+ expect(subject.info[:last_name]).to eq("Fenner")
49
+ end
50
+
51
+ it 'should return description' do
52
+ expect(subject.info[:description]).to eq("Martin Fenner is the DataCite Technical Director and manages the technical architecture for Datacite as well as DataCite’s technical contributions for the EU-funded THOR project.. From 2012 to 2015 he was technical lead for the PLOS Article-Level Metrics project. He served on the Board of the Open Researcher and Contributor ID (ORCID) initiative from 2010-2012, and worked for ORCID EU in the EC-funded ODIN project from 2012 to 2013. Martin has a medical degree from the Free University of Berlin and is a Board-certified medical oncologist.")
53
+ end
54
+ end
55
+
56
+ describe 'raw_info' do
57
+ before do
58
+ allow(subject).to receive(:request_info).and_return(request_info_hash)
59
+ end
60
+
61
+ it 'should return other_names' do
62
+ expect(subject.raw_info[:other_names]).to eq([" Martin Hellmut Fenner", "M Fenner", "MH Fenner", "Martin H. Fenner"])
41
63
  end
42
64
  end
43
65
  end
44
66
 
45
67
  private
46
68
 
47
- def raw_info_hash
48
- {
49
- "name" => "Josiah Carberry",
50
- "access_token" => "e6394ba4-34bd-43a8-8c3d-a99752fe0bf9",
51
- "expires_in" => 631138518,
52
- "token_type" => "bearer",
53
- "orcid" => "0000-0002-1825-0097",
54
- "scope" => "/authenticate",
55
- "refresh_token" => "c07df09f-2015-4b88-a387-61b7e2a89fb0"
56
- }
69
+ def request_info_hash
70
+ { 'message-version' => '1.2', 'orcid-profile' => { 'orcid' => nil, 'orcid-id' => nil, 'orcid-identifier' => { 'value' => nil, 'uri' => 'http://orcid.org/0000-0003-1419-2405', 'path' => '0000-0003-1419-2405', 'host' => 'orcid.org' }, 'orcid-deprecated' => nil, 'orcid-preferences' => { 'locale' => 'EN' }, 'orcid-history' => { 'creation-method' => 'WEBSITE', 'completion-date' => { 'value' => 1_349_732_964_340 }, 'submission-date' => { 'value' => 1_349_729_360_270 }, 'last-modified-date' => { 'value' => 1_446_719_619_721 }, 'claimed' => { 'value' => true }, 'source' => nil, 'deactivation-date' => nil, 'verified-email' => { 'value' => true }, 'verified-primary-email' => { 'value' => true }, 'visibility' => nil }, 'orcid-bio' => { 'personal-details' => { 'given-names' => { 'value' => 'Martin' }, 'family-name' => { 'value' => 'Fenner' }, 'credit-name' => { 'value' => 'Martin Fenner', 'visibility' => 'PUBLIC' }, 'other-names' => { 'other-name' => [{ 'value' => ' Martin Hellmut Fenner' }, { 'value' => 'M Fenner' }, { 'value' => 'MH Fenner' }, { 'value' => 'Martin H. Fenner' }], 'visibility' => 'PUBLIC' } }, 'biography' => { 'value' => 'Martin Fenner is the DataCite Technical Director and manages the technical architecture for Datacite as well as DataCite’s technical contributions for the EU-funded THOR project.. From 2012 to 2015 he was technical lead for the PLOS Article-Level Metrics project. He served on the Board of the Open Researcher and Contributor ID (ORCID) initiative from 2010-2012, and worked for ORCID EU in the EC-funded ODIN project from 2012 to 2013. Martin has a medical degree from the Free University of Berlin and is a Board-certified medical oncologist.', 'visibility' => 'PUBLIC' }, 'researcher-urls' => { 'researcher-url' => [{ 'url-name' => { 'value' => 'Blog' }, 'url' => { 'value' => 'http://blog.martinfenner.org' } }, { 'url-name' => { 'value' => 'Twitter' }, 'url' => { 'value' => 'http://twitter.com/mfenner' } }, { 'url-name' => { 'value' => 'My SciENCV' }, 'url' => { 'value' => 'http://www.ncbi.nlm.nih.gov/myncbi/mfenner/cv/1413/' } }], 'visibility' => 'PUBLIC' }, 'contact-details' => { 'email' => [], 'address' => { 'country' => { 'value' => 'DE', 'visibility' => 'PUBLIC' } } }, 'keywords' => nil, 'external-identifiers' => { 'external-identifier' => [{ 'orcid' => nil, 'external-id-orcid' => nil, 'external-id-common-name' => { 'value' => 'ISNI' }, 'external-id-reference' => { 'value' => '000000035060549X' }, 'external-id-url' => { 'value' => 'http://isni.org/000000035060549X' }, 'external-id-source' => nil, 'source' => { 'source-orcid' => { 'value' => nil, 'uri' => 'http://orcid.org/0000-0003-0412-1857', 'path' => '0000-0003-0412-1857', 'host' => 'orcid.org' }, 'source-client-id' => nil, 'source-name' => nil, 'source-date' => nil } }, { 'orcid' => nil, 'external-id-orcid' => nil, 'external-id-common-name' => { 'value' => 'Scopus Author ID' }, 'external-id-reference' => { 'value' => '7006600825' }, 'external-id-url' => { 'value' => 'http://www.scopus.com/inward/authorDetails.url?authorID=7006600825&partnerID=MN8TOARS' }, 'external-id-source' => nil, 'source' => { 'source-orcid' => { 'value' => nil, 'uri' => 'http://orcid.org/0000-0002-5982-8983', 'path' => '0000-0002-5982-8983', 'host' => 'orcid.org' }, 'source-client-id' => nil, 'source-name' => nil, 'source-date' => nil } }], 'visibility' => 'PUBLIC' }, 'delegation' => nil, 'scope' => nil }, 'orcid-activities' => nil, 'orcid-internal' => nil, 'type' => 'USER', 'group-type' => nil, 'client-type' => nil }, 'orcid-search-results' => nil, 'error-desc' => nil }
57
71
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-orcid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.27
4
+ version: 1.0.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gudmundur A. Thorisson