toccatore 0.3.6 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +9 -9
- data/README.md +1 -1
- data/lib/toccatore/base.rb +14 -4
- data/lib/toccatore/datacite_related.rb +9 -2
- data/lib/toccatore/orcid_update.rb +4 -1
- data/lib/toccatore/version.rb +1 -1
- data/spec/cli_spec.rb +1 -1
- data/spec/datacite_related_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c2d076ad83a73165bf2089a008c4461e477081d
|
4
|
+
data.tar.gz: e919fb11f3c1175f829a0df922b7e61316e89584
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d75464dfcacaa20d34ac497a6c9d949ac5d9f8161e313268c68bd4dd926696c1069326167cc6e7475fafb3a2d9384b225836a3d15b71a1ed6f36d0f65e971652
|
7
|
+
data.tar.gz: f77217f8bff00303217370b7688a1601ebb0314196ad9490cca592059687c57ad0fdb508b02dcd47c5014605e4add6231407a13dde42507ae4287bda1cd4d2b9
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
toccatore (0.3.
|
4
|
+
toccatore (0.3.8)
|
5
5
|
activesupport (~> 4.2, >= 4.2.5)
|
6
6
|
dotenv (~> 2.1, >= 2.1.1)
|
7
7
|
gender_detector (~> 1.0)
|
@@ -18,7 +18,7 @@ GEM
|
|
18
18
|
minitest (~> 5.1)
|
19
19
|
thread_safe (~> 0.3, >= 0.3.4)
|
20
20
|
tzinfo (~> 1.1)
|
21
|
-
addressable (2.5.
|
21
|
+
addressable (2.5.1)
|
22
22
|
public_suffix (~> 2.0, >= 2.0.2)
|
23
23
|
builder (3.2.3)
|
24
24
|
codeclimate-test-reporter (1.0.8)
|
@@ -38,24 +38,24 @@ GEM
|
|
38
38
|
gender_detector (1.0.0)
|
39
39
|
hashdiff (0.3.2)
|
40
40
|
i18n (0.8.1)
|
41
|
-
json (2.0
|
42
|
-
maremma (3.5.
|
43
|
-
activesupport (
|
41
|
+
json (2.1.0)
|
42
|
+
maremma (3.5.7)
|
43
|
+
activesupport (>= 4.2.5)
|
44
44
|
addressable (>= 2.3.6)
|
45
45
|
builder (~> 3.2, >= 3.2.2)
|
46
46
|
excon (~> 0.45.0)
|
47
47
|
faraday (~> 0.9.2)
|
48
48
|
faraday-encoding (~> 0.0.1)
|
49
49
|
faraday_middleware (~> 0.10.0)
|
50
|
-
multi_json (~> 1.
|
51
|
-
nokogiri (~> 1.6.
|
50
|
+
multi_json (~> 1.12)
|
51
|
+
nokogiri (~> 1.6, >= 1.6.8)
|
52
52
|
oj (~> 2.18, >= 2.18.1)
|
53
53
|
mini_portile2 (2.1.0)
|
54
54
|
minitest (5.10.1)
|
55
|
-
multi_json (1.
|
55
|
+
multi_json (1.12.1)
|
56
56
|
multipart-post (2.0.0)
|
57
57
|
namae (0.11.3)
|
58
|
-
nokogiri (1.
|
58
|
+
nokogiri (1.7.1)
|
59
59
|
mini_portile2 (~> 2.1.0)
|
60
60
|
oj (2.18.5)
|
61
61
|
public_suffix (2.0.5)
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
[![Code Climate](https://codeclimate.com/github/datacite/toccatore/badges/gpa.svg)](https://codeclimate.com/github/datacite/toccatore)
|
5
5
|
[![Test Coverage](https://codeclimate.com/github/datacite/toccatore/badges/coverage.svg)](https://codeclimate.com/github/datacite/toccatore/coverage)
|
6
6
|
|
7
|
-
|
7
|
+
Agent for Event Data service, providing links to ORCID IDs and DOIs not from DataCite as related identifiers in DataCite metadata.
|
8
8
|
|
9
9
|
## Development
|
10
10
|
|
data/lib/toccatore/base.rb
CHANGED
@@ -67,17 +67,20 @@ module Toccatore
|
|
67
67
|
if total > 0
|
68
68
|
# walk through paginated results
|
69
69
|
total_pages = (total.to_f / job_batch_size).ceil
|
70
|
+
error_total = 0
|
70
71
|
|
71
72
|
(0...total_pages).each do |page|
|
72
73
|
options[:offset] = page * job_batch_size
|
73
|
-
|
74
|
+
options[:total] = total
|
75
|
+
error_total += process_data(options)
|
74
76
|
end
|
75
|
-
text = "#{total} works processed for date range #{options[:from_date]} - #{options[:until_date]}."
|
77
|
+
text = "#{total} works processed with #{error_total} errors for date range #{options[:from_date]} - #{options[:until_date]}."
|
76
78
|
else
|
77
79
|
text = "No works found for date range #{options[:from_date]} - #{options[:until_date]}."
|
78
|
-
puts text
|
79
80
|
end
|
80
81
|
|
82
|
+
puts text
|
83
|
+
|
81
84
|
# send slack notification
|
82
85
|
options[:level] = total > 0 ? "good" : "warning"
|
83
86
|
options[:title] = "Report for #{source_id}"
|
@@ -101,13 +104,20 @@ module Toccatore
|
|
101
104
|
Maremma.get(query_url, options)
|
102
105
|
end
|
103
106
|
|
107
|
+
# method returns number of errors
|
104
108
|
def push_data(items, options={})
|
105
109
|
if items.empty?
|
106
110
|
puts "No works found for date range #{options[:from_date]} - #{options[:until_date]}."
|
111
|
+
0
|
107
112
|
elsif options[:access_token].blank?
|
108
113
|
puts "An error occured: Access token missing."
|
114
|
+
options[:total]
|
109
115
|
else
|
110
|
-
|
116
|
+
error_total = 0
|
117
|
+
Array(items).each do |item|
|
118
|
+
error_total += push_item(item, options)
|
119
|
+
end
|
120
|
+
error_total
|
111
121
|
end
|
112
122
|
end
|
113
123
|
|
@@ -2,6 +2,8 @@ require_relative 'base'
|
|
2
2
|
|
3
3
|
module Toccatore
|
4
4
|
class DataciteRelated < Base
|
5
|
+
LICENSE = "https://creativecommons.org/publicdomain/zero/1.0/"
|
6
|
+
|
5
7
|
def source_id
|
6
8
|
"datacite_related"
|
7
9
|
end
|
@@ -43,7 +45,8 @@ module Toccatore
|
|
43
45
|
"relation_type_id" => raw_relation_type.underscore,
|
44
46
|
"source_id" => "datacite",
|
45
47
|
"source_token" => options[:source_token],
|
46
|
-
"occurred_at" => item.fetch("minted")
|
48
|
+
"occurred_at" => item.fetch("minted"),
|
49
|
+
"license" => LICENSE }
|
47
50
|
else
|
48
51
|
ssum
|
49
52
|
end
|
@@ -76,10 +79,14 @@ module Toccatore
|
|
76
79
|
host: host)
|
77
80
|
end
|
78
81
|
|
82
|
+
# return 0 if successful, 1 if error
|
79
83
|
if response.status == 201
|
80
84
|
puts "#{item['subj_id']} #{item['relation_type_id']} #{item['obj_id']} pushed to Event Data service."
|
85
|
+
0
|
81
86
|
elsif response.body["errors"].present?
|
82
|
-
puts "
|
87
|
+
puts "#{item['subj_id']} #{item['relation_type_id']} #{item['obj_id']} had an error:"
|
88
|
+
puts "#{response.body['errors'].first['title']}"
|
89
|
+
1
|
83
90
|
end
|
84
91
|
end
|
85
92
|
end
|
@@ -56,8 +56,11 @@ module Toccatore
|
|
56
56
|
orcid = response.body.fetch("data", {}).fetch("attributes", {}).fetch("orcid", nil)
|
57
57
|
claim_action = response.body.fetch("data", {}).fetch("attributes", {}).fetch("claim-action", nil)
|
58
58
|
puts "#{claim_action.titleize} DOI #{doi} for ORCID ID #{orcid} pushed to Profiles service."
|
59
|
+
0
|
59
60
|
elsif response.body["errors"].present?
|
60
|
-
puts "
|
61
|
+
puts "#{claim_action.titleize} DOI #{doi} for ORCID ID #{orcid} had an error:"
|
62
|
+
puts "#{response.body['errors'].first['title']}"
|
63
|
+
1
|
61
64
|
end
|
62
65
|
end
|
63
66
|
end
|
data/lib/toccatore/version.rb
CHANGED
data/spec/cli_spec.rb
CHANGED
@@ -102,7 +102,7 @@ describe Toccatore::DataciteRelated, vcr: true do
|
|
102
102
|
response = subject.parse_data(result, source_token: ENV['SOURCE_TOKEN'])
|
103
103
|
|
104
104
|
expect(response.length).to eq(134)
|
105
|
-
expect(response.last.except("id")).to eq("message_action" => "create", "subj_id"=>"https://doi.org/10.17180/obs.yzeron", "obj_id"=>"https://doi.org/10.1016/j.jhydrol.2013.09.055", "relation_type_id"=>"is_referenced_by", "source_id"=>"datacite","source_token" => "28276d12-b320-41ba-9272-bb0adc3466ff", "occurred_at"=>"2015-04-07T12:22:40Z")
|
105
|
+
expect(response.last.except("id")).to eq("message_action" => "create", "subj_id"=>"https://doi.org/10.17180/obs.yzeron", "obj_id"=>"https://doi.org/10.1016/j.jhydrol.2013.09.055", "relation_type_id"=>"is_referenced_by", "source_id"=>"datacite","source_token" => "28276d12-b320-41ba-9272-bb0adc3466ff", "occurred_at"=>"2015-04-07T12:22:40Z", "license" => "https://creativecommons.org/publicdomain/zero/1.0/")
|
106
106
|
end
|
107
107
|
|
108
108
|
it "should report if there are works ignored because of an IsIdenticalTo relation" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toccatore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
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-
|
11
|
+
date: 2017-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: maremma
|