toccatore 0.4.12 → 0.4.13

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: 78861df5575f3504d5cce258bc6bfd59751da8269a4b57f47f11d1bb4836930e
4
- data.tar.gz: 57293cd4eae644a522a925046e61cd90b397621a32dc85d0dc050821bc4613e8
3
+ metadata.gz: c2e7bd1c2f2e2c09c0fe6adcab866b0dbb20b2b80904f961c19b47a2c1fb5d7c
4
+ data.tar.gz: ba2940625807aa1010be4a1e420338cfee27e303d9ed07647753931709d25829
5
5
  SHA512:
6
- metadata.gz: d4860c8001b3e4a383cb537072e1e83ebfb9789894f16b2cbe2d7ceefcb52b617e35dd3abd103366a3b10039cb4a9b3701b5628a42cedb8520946d2cbbb965e7
7
- data.tar.gz: 54a4c8fc3962e6d7c04889ad481bbc38344b5a5c9c38577142825cd4ae4bbf9a85c615639e6078dc79e1e9ed1a615718be5e4a0205ccfde479ffd5d8299aed9a
6
+ metadata.gz: 692694881c5c8d48542ce05abd38397b1dc656535851646e722e2bb42d3e95f512c3d62a3c6ab6894e55e9b8cfff93916c7fb8ab2aa42f6b308a8ab7cec2bdea
7
+ data.tar.gz: 16faa9f7e9015f81203b8c738ef584933778fc569e3d29d9d74cf455810cf249e1b9a54606c6b73a9ebfae38ef44899412c748318cef4e674821f60a34e55f0a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- toccatore (0.4.12)
4
+ toccatore (0.4.13)
5
5
  activesupport (>= 4.2.5, < 6)
6
6
  aws-sdk-sqs
7
7
  dotenv (~> 2.1, >= 2.1.1)
@@ -82,7 +82,13 @@ module Toccatore
82
82
  puts text
83
83
 
84
84
  # send slack notification
85
- options[:level] = total > 0 ? "good" : "warning"
85
+ if total == 0
86
+ options[:level] = "warning"
87
+ elsif error_total > 0
88
+ options[:level] = "danger"
89
+ else
90
+ options[:level] = "good"
91
+ end
86
92
  options[:title] = "Report for #{source_id}"
87
93
  send_notification_to_slack(text, options) if options[:slack_webhook_url].present?
88
94
 
@@ -58,7 +58,10 @@ module Toccatore
58
58
  end
59
59
 
60
60
  def push_item(item, options={})
61
- return OpenStruct.new(body: { "errors" => [{ "title" => "Access token missing." }] }) if options[:access_token].blank?
61
+ if options[:access_token].blank?
62
+ puts "Access token missing."
63
+ return 1
64
+ end
62
65
 
63
66
  host = options[:push_url].presence || "https://bus.eventdata.crossref.org"
64
67
  push_url = host + "/events"
@@ -92,6 +95,9 @@ module Toccatore
92
95
  if response.status == 201
93
96
  puts "#{item['subj_id']} #{item['relation_type_id']} #{item['obj_id']} pushed to Event Data service."
94
97
  0
98
+ elsif response.status == 409
99
+ puts "#{item['subj_id']} #{item['relation_type_id']} #{item['obj_id']} already pushed to Event Data service."
100
+ 0
95
101
  elsif response.body["errors"].present?
96
102
  puts "#{item['subj_id']} #{item['relation_type_id']} #{item['obj_id']} had an error:"
97
103
  puts "#{response.body['errors'].first['title']}"
@@ -44,9 +44,13 @@ module Toccatore
44
44
  end
45
45
 
46
46
  def push_item(item, options={})
47
- return OpenStruct.new(body: { "errors" => [{ "title" => "Access token missing." }] }) if options[:access_token].blank?
47
+ if options[:access_token].blank?
48
+ puts "Access token missing."
49
+ return 1
50
+ end
48
51
 
49
- push_url = (options[:push_url].presence || "https://profiles.datacite.org/api") + "/claims"
52
+ host = options[:push_url].presence || "https://profiles.datacite.org/api"
53
+ push_url = host + "/claims"
50
54
 
51
55
  response = Maremma.post(push_url, data: { "claim" => item }.to_json,
52
56
  bearer: options[:access_token],
@@ -161,10 +161,11 @@ module Toccatore
161
161
  "id" => item["uuid"],
162
162
  "type" => "events",
163
163
  "attributes" => item.except("id") }}
164
+
164
165
  response = Maremma.put(push_url, data: data.to_json,
165
- bearer: options[:access_token],
166
- content_type: 'application/json',
167
- host: host)
166
+ bearer: options[:access_token],
167
+ content_type: 'json',
168
+ host: host)
168
169
 
169
170
  if response.status == 201
170
171
  puts "#{item['subj-id']} #{item['relation-type-id']} #{item['obj-id']} pushed to Event Data service."
@@ -1,3 +1,3 @@
1
1
  module Toccatore
2
- VERSION = "0.4.12"
2
+ VERSION = "0.4.13"
3
3
  end
data/spec/cli_spec.rb CHANGED
@@ -8,7 +8,7 @@ describe Toccatore::CLI do
8
8
 
9
9
  describe "version" do
10
10
  it 'has version' do
11
- expect { subject.__print_version }.to output("0.4.12\n").to_stdout
11
+ expect { subject.__print_version }.to output("0.4.13\n").to_stdout
12
12
  end
13
13
  end
14
14
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toccatore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.12
4
+ version: 0.4.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner