copperegg-alerts 0.1.0 → 0.1.1

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: 60f86c02f2b84845f8148475383e391f6fcc7147
4
- data.tar.gz: 3d4c3e906ac7cc21ab85fa8c6fcf978be49453a9
3
+ metadata.gz: c78c120a8a32d710c50be87fab4ad4347bb685e3
4
+ data.tar.gz: d13e0d46c5afaf6a905c313f924c031b16854887
5
5
  SHA512:
6
- metadata.gz: 7051e964d2989bde9eeae23cd63316c93637f209ae64af32de0a6922ce31672c6933e40dc95ba161e5cf1a6a86d259020252aa74c9e74bad745a0ebd9cc5a7f5
7
- data.tar.gz: 5c4402cfa23c097a1876ca0b89e147f2d4dce0a65991dcec3c73678bd78f6d85583f23fad7327f23433bf08ca76b45a1ca62d21b6949f9f6c9996df01a764e61
6
+ metadata.gz: e40ce0301732cedb2b9c5b3d89806a26f0a394ceed96f1e7eb38d5b713d207f62d7fdf2fcfdf93d36aea91e39ff3cda9755a3b570cb988acf1226691c80e2ad7
7
+ data.tar.gz: 3b42f67e4ce5db9ef23d9840a626880ba4626c4edacfe237afe7cf951a20d5a3def9e271fc5ab143889c722052094a7ecddbeb35000f1481869cd96e82f3cc93
@@ -14,16 +14,16 @@ module Copperegg
14
14
  end
15
15
 
16
16
  def auth_setup(api_key)
17
- @auth = {:basic_auth => {:username => api_key, :password => 'U'}}
18
- return self
17
+ @auth = { basic_auth: { username: api_key, password: 'U' } }
18
+ self
19
19
  end
20
20
 
21
- JSON = {'content-type' => 'application/json'}
21
+ JSON = { 'content-type' => 'application/json' }.freeze
22
22
 
23
23
  def method_missing(method, resource, *args)
24
24
  if method.to_s =~ /\?$/
25
25
  method = method.to_s.sub!(/\?$/, '')
26
- result = self.send(method.to_sym, resource, *args)
26
+ result = send(method.to_sym, resource, *args)
27
27
  return result if result.code == 200
28
28
  end
29
29
  end
@@ -49,7 +49,7 @@ module Copperegg
49
49
  def _send(method, path, body = {})
50
50
  auth = @auth.clone
51
51
  unless body.empty?
52
- auth.merge!({:headers => JSON}.merge!({:body => body.to_json}))
52
+ auth.merge!({ headers: JSON }.merge!(body: body.to_json))
53
53
  end
54
54
  response = HTTParty.send(method.to_sym, @api_base_uri + path, auth.to_hash)
55
55
  if response.code != 200
@@ -57,7 +57,6 @@ module Copperegg
57
57
  end
58
58
  response
59
59
  end
60
-
61
60
  end
62
61
  end
63
62
  end
@@ -1,7 +1,6 @@
1
1
  require 'deep_merge'
2
2
  require 'copperegg/alerts'
3
3
 
4
-
5
4
  module Copperegg
6
5
  module Alerts
7
6
  class Schedule
@@ -25,26 +24,25 @@ module Copperegg
25
24
  @schedules -= selected_schedules
26
25
  selected_schedules.each do |s|
27
26
  result = @client.put?("alerts/schedules/#{s['id']}.json", body)
28
- if result == nil
29
- @schedules << s
30
- else
31
- @schedules << result
32
- end
27
+ @schedules << if result.nil?
28
+ s
29
+ else
30
+ result
31
+ end
33
32
  end
34
33
  end
35
34
  end
36
35
 
37
36
  def add(name, *args)
38
37
  defaults = {
39
- 'name' => name,
40
- 'state' => 'enabled',
41
- 'duration' => 10,
42
- 'start_time' => Time.now.gmtime.strftime('%Y-%m-%dt%H:%M:%Sz'),
38
+ 'name' => name,
39
+ 'state' => 'enabled',
40
+ 'duration' => 10,
41
+ 'start_time' => Time.now.gmtime.strftime('%Y-%m-%dt%H:%M:%Sz')
43
42
  }
44
43
  args.each { |arg| defaults.deep_merge!(arg) }
45
- if result = @client.post?('alerts/schedules.json', defaults)
46
- @schedules << result.parsed_response
47
- end
44
+ result = @client.post?('alerts/schedules.json', defaults)
45
+ @schedules << result.parsed_response if result
48
46
  end
49
47
 
50
48
  def delete(name)
@@ -52,7 +50,7 @@ module Copperegg
52
50
  if selected_schedules
53
51
  @schedules -= selected_schedules
54
52
  selected_schedules.each do |s|
55
- if @client.delete?("alerts/schedules/#{s['id']}.json") == nil
53
+ if @client.delete?("alerts/schedules/#{s['id']}.json").nil?
56
54
  @schedules << s
57
55
  end
58
56
  end
@@ -61,4 +59,3 @@ module Copperegg
61
59
  end
62
60
  end
63
61
  end
64
-
@@ -1,5 +1,5 @@
1
1
  module Copperegg
2
2
  module Alerts
3
- VERSION = "0.1.0"
3
+ VERSION = '0.1.1'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: copperegg-alerts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cargo Media
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-12 00:00:00.000000000 Z
12
+ date: 2016-10-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -137,6 +137,20 @@ dependencies:
137
137
  - - "~>"
138
138
  - !ruby/object:Gem::Version
139
139
  version: 0.2.1
140
+ - !ruby/object:Gem::Dependency
141
+ name: rubocop
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - "~>"
145
+ - !ruby/object:Gem::Version
146
+ version: 0.41.2
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - "~>"
152
+ - !ruby/object:Gem::Version
153
+ version: 0.41.2
140
154
  description: Set and remove alert silencing schedules aka maintenance windows
141
155
  email: hello@cargomedia.ch
142
156
  executables: []
@@ -169,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
183
  version: '0'
170
184
  requirements: []
171
185
  rubyforge_project:
172
- rubygems_version: 2.4.6
186
+ rubygems_version: 2.5.1
173
187
  signing_key:
174
188
  specification_version: 4
175
189
  summary: A very minimalistic Copperegg API client for managing alert schedules