orcid_client 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/lib/orcid_client/api.rb +9 -6
- data/lib/orcid_client/metadata.rb +8 -8
- data/lib/orcid_client/version.rb +1 -1
- data/orcid_client.gemspec +1 -1
- data/spec/api_spec.rb +10 -6
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4029bf25df2ad75c7ae622f7ac356f1e87edbcba
|
4
|
+
data.tar.gz: 484dd8e735ac80dedb219487f29b4271205dec19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2412a070c7648ba1c4fe0d154ac9e2a1d3b782326d4e562d47ff1f6707304fd81b7ef6fd7f0cdd0707498e85e56804d725898f9e133603f99abba15d8b338691
|
7
|
+
data.tar.gz: 77e3a8897944889b34ffc617e07c4a8b5a35b42f9a789dc8050473fd93a2acd129b8d83ec61369f7fed7233160ff742fb189707e0148452ebe7542daf88611b7
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
orcid_client (0.1.
|
4
|
+
orcid_client (0.1.4)
|
5
5
|
activesupport (~> 4.2, >= 4.2.5)
|
6
6
|
builder (~> 3.2, >= 3.2.2)
|
7
7
|
dotenv (~> 2.1, >= 2.1.1)
|
8
|
-
maremma (~>
|
8
|
+
maremma (~> 3.0)
|
9
9
|
namae (~> 0.10.1)
|
10
10
|
nokogiri (~> 1.6.8)
|
11
11
|
sanitize (~> 4.0, >= 4.0.1)
|
@@ -37,10 +37,10 @@ GEM
|
|
37
37
|
faraday
|
38
38
|
faraday_middleware (0.10.1)
|
39
39
|
faraday (>= 0.7.4, < 1.0)
|
40
|
-
hashdiff (0.3.
|
40
|
+
hashdiff (0.3.1)
|
41
41
|
i18n (0.7.0)
|
42
42
|
json (1.8.3)
|
43
|
-
maremma (
|
43
|
+
maremma (3.0.1)
|
44
44
|
activesupport (~> 4.2, >= 4.2.5)
|
45
45
|
builder (~> 3.2, >= 3.2.2)
|
46
46
|
excon (~> 0.45.0)
|
data/lib/orcid_client/api.rb
CHANGED
@@ -20,8 +20,9 @@ module OrcidClient
|
|
20
20
|
|
21
21
|
url = "#{orcid_api_url}/v#{API_VERSION}/#{orcid}/work"
|
22
22
|
response = Maremma.post(url, content_type: 'application/vnd.orcid+xml', data: data, bearer: access_token)
|
23
|
-
put_code = response.
|
24
|
-
response.
|
23
|
+
put_code = response.headers.fetch("Location", "").split("/").last
|
24
|
+
response.body["put_code"] = put_code.present? ? put_code.to_i : nil
|
25
|
+
response
|
25
26
|
end
|
26
27
|
|
27
28
|
def update_work(options={})
|
@@ -32,8 +33,9 @@ module OrcidClient
|
|
32
33
|
|
33
34
|
url = "#{orcid_api_url}/v#{API_VERSION}/#{orcid}/work/#{put_code}"
|
34
35
|
response = Maremma.put(url, content_type: 'application/vnd.orcid+xml', data: data, bearer: access_token)
|
35
|
-
put_code = response.
|
36
|
-
response.
|
36
|
+
put_code = response.headers.fetch("Location", "").split("/").last
|
37
|
+
response.body["put_code"] = put_code.present? ? put_code.to_i : nil
|
38
|
+
response
|
37
39
|
end
|
38
40
|
|
39
41
|
def delete_work(options={})
|
@@ -66,8 +68,9 @@ module OrcidClient
|
|
66
68
|
|
67
69
|
url = "#{orcid_api_url}/v#{API_VERSION}/#{orcid}/notification-permission"
|
68
70
|
response = Maremma.post(url, content_type: 'application/vnd.orcid+xml', data: data, bearer: notification_access_token)
|
69
|
-
put_code = response.
|
70
|
-
response.
|
71
|
+
put_code = response.headers.fetch("Location", "").split("/").last
|
72
|
+
response.body["put_code"] = put_code.present? ? put_code.to_i : nil
|
73
|
+
response
|
71
74
|
end
|
72
75
|
end
|
73
76
|
end
|
@@ -15,9 +15,9 @@ module OrcidClient
|
|
15
15
|
|
16
16
|
url = "http://api.crossref.org/works/" + PostRank::URI.escape(doi)
|
17
17
|
response = Maremma.get(url, options.merge(host: true))
|
18
|
-
return response if response["errors"]
|
18
|
+
return response if response.body["errors"]
|
19
19
|
|
20
|
-
metadata = response.fetch("data", {}).fetch("message", {})
|
20
|
+
metadata = response.body.fetch("data", {}).fetch("message", {})
|
21
21
|
return { "errors" => [{ "title" => "Not found.", "status" => 404 }] } if metadata.blank?
|
22
22
|
|
23
23
|
date_parts = metadata.fetch("issued", {}).fetch("date-parts", []).first
|
@@ -56,9 +56,9 @@ module OrcidClient
|
|
56
56
|
wt: "json" }
|
57
57
|
url = "http://search.datacite.org/api?" + URI.encode_www_form(params)
|
58
58
|
response = Maremma.get(url, options)
|
59
|
-
return response if response["errors"]
|
59
|
+
return response if response.body["errors"]
|
60
60
|
|
61
|
-
metadata = response.fetch("data", {}).fetch("response", {}).fetch("docs", []).first
|
61
|
+
metadata = response.body.fetch("data", {}).fetch("response", {}).fetch("docs", []).first
|
62
62
|
return { "errors" => [{ "title" => "Not found.", "status" => 404 }] } if metadata.blank?
|
63
63
|
|
64
64
|
doi = metadata.fetch("doi", nil)
|
@@ -88,9 +88,9 @@ module OrcidClient
|
|
88
88
|
|
89
89
|
url = "http://pub.orcid.org/v1.2/#{orcid}/orcid-bio"
|
90
90
|
response = Maremma.get(url, options)
|
91
|
-
return response if response["errors"]
|
91
|
+
return response if response.body["errors"]
|
92
92
|
|
93
|
-
metadata = response.fetch("data", {}).fetch("orcid_message", {}).fetch("orcid_profile", nil)
|
93
|
+
metadata = response.body.fetch("data", {}).fetch("orcid_message", {}).fetch("orcid_profile", nil)
|
94
94
|
metadata.extend Hashie::Extensions::DeepFetch
|
95
95
|
|
96
96
|
personal_details = metadata.deep_fetch("orcid_bio", "personal_details") { {} }
|
@@ -115,9 +115,9 @@ module OrcidClient
|
|
115
115
|
|
116
116
|
url = "http://doi.crossref.org/doiRA/" + CGI.unescape(doi)
|
117
117
|
response = Maremma.get(url, options.merge(host: true))
|
118
|
-
return response if response["errors"]
|
118
|
+
return response if response.body["errors"]
|
119
119
|
|
120
|
-
ra = response.fetch("data", {}).first.fetch("RA", nil)
|
120
|
+
ra = response.body.fetch("data", {}).first.fetch("RA", nil)
|
121
121
|
if ra.present?
|
122
122
|
ra.delete(' ').downcase
|
123
123
|
else
|
data/lib/orcid_client/version.rb
CHANGED
data/orcid_client.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
21
|
# Declary dependencies here, rather than in the Gemfile
|
22
|
-
s.add_dependency 'maremma', '~>
|
22
|
+
s.add_dependency 'maremma', '~> 3.0'
|
23
23
|
s.add_dependency 'nokogiri', '~> 1.6.8'
|
24
24
|
s.add_dependency 'builder', '~> 3.2', '>= 3.2.2'
|
25
25
|
s.add_dependency 'namae', '~> 0.10.1'
|
data/spec/api_spec.rb
CHANGED
@@ -16,14 +16,15 @@ describe OrcidClient, vcr: true do
|
|
16
16
|
|
17
17
|
it 'should create work' do
|
18
18
|
response = subject.create_work(sandbox: true)
|
19
|
-
expect(response["put_code"]).not_to be_blank
|
19
|
+
expect(response.body["put_code"]).not_to be_blank
|
20
|
+
expect(response.status).to eq(201)
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
23
24
|
describe 'get' do
|
24
25
|
it 'should get works' do
|
25
26
|
response = subject.get_works(sandbox: true)
|
26
|
-
works = response.fetch("data", {}).fetch("group", {})
|
27
|
+
works = response.body.fetch("data", {}).fetch("group", {})
|
27
28
|
expect(works.length).to eq(27)
|
28
29
|
work = works.first
|
29
30
|
expect(work["external-ids"]).to eq("external-id"=>[{"external-id-type"=>"doi", "external-id-value"=>"10.5167/UZH-19531", "external-id-url"=>nil, "external-id-relationship"=>"SELF"}])
|
@@ -33,15 +34,17 @@ describe OrcidClient, vcr: true do
|
|
33
34
|
describe 'put' do
|
34
35
|
it 'should update work' do
|
35
36
|
response = subject.update_work(sandbox: true)
|
36
|
-
expect(response.fetch("data", {}).fetch("work", {}).fetch("put_code", nil)).to eq(put_code)
|
37
|
+
expect(response.body.fetch("data", {}).fetch("work", {}).fetch("put_code", nil)).to eq(put_code)
|
38
|
+
expect(response.status).to eq(200)
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
40
42
|
describe 'delete' do
|
41
43
|
it 'should delete work' do
|
42
44
|
response = subject.delete_work(sandbox: true)
|
43
|
-
expect(response["data"]).to be_blank
|
44
|
-
expect(response["errors"]).to be_nil
|
45
|
+
expect(response.body["data"]).to be_blank
|
46
|
+
expect(response.body["errors"]).to be_nil
|
47
|
+
expect(response.status).to eq(204)
|
45
48
|
end
|
46
49
|
end
|
47
50
|
end
|
@@ -52,7 +55,8 @@ describe OrcidClient, vcr: true do
|
|
52
55
|
describe 'post' do
|
53
56
|
it 'should create notification' do
|
54
57
|
response = subject.create_notification(sandbox: true)
|
55
|
-
expect(response["put_code"]).not_to be_blank
|
58
|
+
expect(response.body["put_code"]).not_to be_blank
|
59
|
+
expect(response.status).to eq(201)
|
56
60
|
end
|
57
61
|
end
|
58
62
|
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.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Fenner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: maremma
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '3.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: nokogiri
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|