runscope_statuspage 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: acb698298c57d971a36d1189668eb53e68dde261
4
- data.tar.gz: 43811e43813360053f78f568d9c7b9c863ebecd4
3
+ metadata.gz: 876152fb45917929d74512f7a698af3aab184bf4
4
+ data.tar.gz: 6e38d356acdd2720fd07db9327cb6133a79e0552
5
5
  SHA512:
6
- metadata.gz: 0d9eccd59a4604d9b3dfad5c5cf22f34bbfadfffe1e325c33ac1ba3e5ffdfe8f057e4e139c93446141226d7d09871f83f6d68886078105853e7ff414b7bd92cf
7
- data.tar.gz: 8306a12cff6102a87a2a48811e16924bef252c75fa5758d8871c52f378bcbf631122441d6bfc4583f461a393a50d91d166f3fb2b4129fb3248be25dff2a3d4cb
6
+ metadata.gz: 61be1407248d38797d75408e882bc21ebb969aaf4ca92c57fe770d1067efcc49a551f49aee414501a09699b88715d2e403f7816adc2fb7666b62fde573c981f0
7
+ data.tar.gz: 9cf417c8e2b97c50a973d9aa9dda83a7a10c054cafdddd00a6b768c1dec33f5548199e806c72c854f8e74cdaf96abe370dd8b52e842b26140cca824b58879ac4
data/.gitignore CHANGED
@@ -1,9 +1,9 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'httparty'
4
-
5
- # Specify your gem's dependencies in runscope_statuspage.gemspec
6
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'httparty'
4
+
5
+ # Specify your gem's dependencies in runscope_statuspage.gemspec
6
+ gemspec
data/LICENSE.txt CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2015 David Stancu
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 David Stancu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -31,21 +31,24 @@ In a nutshell, each call will grab metrics from RunScope then send them over to
31
31
  ```ruby
32
32
  opts = {:status => "page status (either 'investigating|identified|monitoring|resolved')",
33
33
  :twitter_update => 'do you want to post status to twitter (bool)',
34
- :fail_on => 'number of failures to induce statuspage update (int, default 0)'}
34
+ :fail_on => 'number of failures to induce statuspage update (int, default 0)',
35
+ :no_sp => skip statuspage.io report and return data}
35
36
  ```
36
37
  - *report_buckets:* Report all radars of buckets in list.
37
38
  ```ruby
38
39
  opts = {:bucket_names => 'list of names of buckets containing radars',
39
40
  :status => "page status (either 'investigating|identified|monitoring|resolved')",
40
41
  :twitter_update => 'do you want to post status to twitter (bool)',
41
- :fail_on => 'number of failures to induce statuspage update (int, default 0)'}
42
+ :fail_on => 'number of failures to induce statuspage update (int, default 0)',
43
+ :no_sp => skip statuspage.io report and return data}
42
44
  ```
43
45
  - *report_bucket:* Report all radars in bucket.
44
46
  ```ruby
45
47
  opts = {:bucket_name => 'name of bucket containing radars',
46
48
  :status => "page status (either 'investigating|identified|monitoring|resolved')",
47
49
  :twitter_update => 'do you want to post status to twitter (bool)',
48
- :fail_on => 'number of failures to induce statuspage update (int, default 0)'}
50
+ :fail_on => 'number of failures to induce statuspage update (int, default 0)',
51
+ :no_sp => skip statuspage.io report and return data}
49
52
  ```
50
53
  - *report_radars:* Report radars in list for given bucket.
51
54
  ```ruby
@@ -53,7 +56,8 @@ opts = {:bucket_name => 'name of bucket containing radars',
53
56
  :radar_names => 'list of names of radars within bucket',
54
57
  :status => "page status (either 'investigating|identified|monitoring|resolved')",
55
58
  :twitter_update => 'do you want to post status to twitter (bool)',
56
- :fail_on => 'number of failures to induce statuspage update (int, default 0)'}
59
+ :fail_on => 'number of failures to induce statuspage update (int, default 0)',
60
+ :no_sp => skip statuspage.io report and return data}
57
61
  ```
58
62
  - *report_radar:* Report one radar in bucket.
59
63
  ```ruby
@@ -61,7 +65,8 @@ opts = {:bucket_name => 'name of bucket containing radars',
61
65
  :radar_name => 'name of radar within bucket',
62
66
  :status => "page status (either 'investigating|identified|monitoring|resolved')",
63
67
  :twitter_update => 'do you want to post status to twitter (bool)',
64
- :fail_on => 'number of failures to induce statuspage update (int, default 0)'}
68
+ :fail_on => 'number of failures to induce statuspage update (int, default 0)',
69
+ :no_sp => skip statuspage.io report and return data}
65
70
  ```
66
71
 
67
72
  #### Important Notes
@@ -104,6 +109,10 @@ Usage:
104
109
 
105
110
  ## Changelog
106
111
 
112
+ 0.1.5
113
+ * Added `:no_sp` to available options so that data can be returned instead of posting to statuspage.io. Useful for SMS notifications.
114
+ * Fix bug where gem crashes when a key with a null value is used in the incident strings.
115
+
107
116
  0.1.4
108
117
  * Added attr_accessor for `@rs` and `@sp`.
109
118
 
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
- require "bundler/gem_tasks"
2
-
1
+ require "bundler/gem_tasks"
2
+
data/bin/console CHANGED
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "runscope_statuspage"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "runscope_statuspage"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup CHANGED
@@ -1,7 +1,7 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- bundle install
6
-
7
- # Do any other automated setup that you need to do here
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -1,237 +1,284 @@
1
- require_relative 'runscope_statuspage/version'
2
- require_relative 'runscope_statuspage/exceptions'
3
- require_relative 'runscope_statuspage/runscope_api'
4
- require_relative 'runscope_statuspage/statuspage_api'
5
-
6
- module RunscopeStatuspage
7
- # Let Ruby write boring getters and setters
8
- class << self; attr_accessor :rs_key, :sp_key, :sp_page, :name, :msg, :rs, :sp; end
9
-
10
- # API credentials and IDs
11
- @rs_key, @sp_key, @sp_page = ''
12
-
13
- # Verbage sent to statuspage
14
- @name = 'Suspected issues with /name/'
15
- @msg = 'Our automated test detected an issue while testing the /description/ endpoint. We are currently investigating this issue.'
16
-
17
- # As the user may decide (for whatever reason)
18
- # to change API keys after one request, we re-initialize
19
- # these objects.
20
- def self.reinit_rest
21
- @rs = RunscopeAPI.new(@rs_key)
22
- @sp = StatuspageAPI.new(@sp_key)
23
- end
24
-
25
- # Splice radar hash values from keys defined in
26
- # @name and @msg.
27
- def self.parameterize(radar)
28
- rname = @name
29
- rmsg = @msg
30
-
31
- @name.scan(/.*?(\/)([A-Za-z]*)(\/)/).each do |set|
32
- set.each do |token|
33
- if radar.has_key?(token)
34
- rname = rname.sub!("/#{token}/", radar[token]) unless (token == "/" and token.length == 1)
35
- end
36
- end
37
- end
38
-
39
- @msg.scan(/.*?(\/)([A-Za-z]*)(\/)/).each do |set|
40
- set.each do |token|
41
- if radar.has_key?(token)
42
- rmsg = rmsg.sub!("/#{token}/", radar[token]) unless (token == "/" and token.length == 1)
43
- end
44
- end
45
- end
46
-
47
- return rname, rmsg
48
- end
49
-
50
- # Update status page with all radars, from all buckets.
51
- # An error will most likely be thrown if you have empty buckets.
52
- #
53
- # Parameters: {:status => page status (either 'investigating|identified|monitoring|resolved'),
54
- # :twitter_update => do you want to post status to twitter (bool),
55
- # :fail_on => number of failures to induce statuspage update (int, default 0)}
56
- def self.report_everything(opts={})
57
- raise MissingArgumentException.new, 'report_everything is missing arguments' \
58
- if not (opts.key?(:status) or opts.key?(:twitter_update))
59
-
60
- opts[:fail_on] = opts.key?(:fail_on) ? opts[:fail_on] : 0
61
- failed_radars = []
62
-
63
- reinit_rest
64
- @rs.buckets.each do |bucket|
65
- @rs.radars(bucket['key']).each do |radar|
66
- begin
67
- if @rs.latest_radar_result(bucket['key'], radar['uuid'])['result'] != 'pass'
68
- failed_radars.push radar
69
- end
70
- rescue RunscopeAPIException => r
71
- p r
72
- next
73
- end
74
- end
75
- end
76
-
77
- if failed_radars.length >= opts[:fail_on]
78
- failed_radars.each do |radar|
79
- @sp.create_realtime_incident(@sp_page, *parameterize(radar).concat([opts[:status], opts[:twitter_update]]))
80
- end
81
- end
82
- end
83
-
84
- # Update status page with one radar, from one bucket.
85
- #
86
- # Parameters: {:bucket_name => name of bucket containing radars,
87
- # :radar_name => name of radar within bucket,
88
- # :status => page status (either 'investigating|identified|monitoring|resolved'),
89
- # :twitter_update => do you want to post status to twitter (bool),
90
- # :fail_on => number of failures to induce statuspage update (int, default 0)}
91
- def self.report_radar(opts = {})
92
- raise MissingArgumentException.new, 'report_radar is missing arguments' \
93
- if not (opts.key?(:status) or opts.key?(:twitter_update) \
94
- or opts.key?(:bucket_name) or opts.key?(:radar_name))
95
-
96
- opts[:fail_on] = opts.key?(:fail_on) ? opts[:fail_on] : 0
97
- failed_radars = []
98
-
99
- reinit_rest
100
- @rs.buckets.each do |bucket|
101
- if bucket['name'] == bucket_name
102
- @rs.radars(bucket['key']).each do |radar|
103
- begin
104
- if @rs.latest_radar_result(bucket['key'], radar['uuid'])['result'] != 'pass' and radar['name'] == radar_name
105
- failed_radars.push radar
106
- end
107
- rescue RunscopeAPIException => r
108
- p r
109
- next
110
- end
111
- end
112
- end
113
- end
114
-
115
- if failed_radars.length >= opts[:fail_on]
116
- failed_radars.each do |radar|
117
- @sp.create_realtime_incident(@sp_page, *parameterize(radar).concat([opts[:status], opts[:twitter_update]]))
118
- end
119
- end
120
- end
121
-
122
- # Update status page with list of radars, from one bucket.
123
- #
124
- # Parameters: {:bucket_name => name of bucket containing radars,
125
- # :radar_names => list of names of radars within bucket,
126
- # :status => page status (either 'investigating|identified|monitoring|resolved'),
127
- # :twitter_update => do you want to post status to twitter (bool),
128
- # :fail_on => number of failures to induce statuspage update (int, default 0)}
129
- def self.report_radars(opts = {})
130
- raise MissingArgumentException.new, 'report_radars is missing arguments' \
131
- if not (opts.key?(:status) or opts.key?(:twitter_update) \
132
- or opts.key?(:bucket_name) or opts.key?(:radar_names))
133
-
134
- opts[:fail_on] = opts.key?(:fail_on) ? opts[:fail_on] : 0
135
- failed_radars = []
136
-
137
- reinit_rest
138
- @rs.buckets.each do |bucket|
139
- if bucket['name'] == opts[:bucket_name]
140
- @rs.radars(bucket['key']).each do |radar|
141
- begin
142
- if @rs.latest_radar_result(bucket['key'], radar['uuid'])['result'] != 'pass' and opts[:radar_names].include?(radar['name'])
143
- failed_radars.push radar
144
- end
145
- rescue RunscopeAPIException => r
146
- p r
147
- next
148
- end
149
- end
150
- end
151
- end
152
-
153
- if failed_radars.length >= opts[:fail_on]
154
- failed_radars.each do |radar|
155
- @sp.create_realtime_incident(@sp_page, *parameterize(radar).concat([opts[:status], opts[:twitter_update]]))
156
- end
157
- end
158
- end
159
-
160
- # Update status page with all radars under passed
161
- # bucket name.
162
- #
163
- # Parameters: {:bucket_name => name of bucket containing radars,
164
- # :status => page status (either 'investigating|identified|monitoring|resolved'),
165
- # :twitter_update => do you want to post status to twitter (bool),
166
- # :fail_on => number of failures to induce statuspage update (int, default 0)}
167
- def self.report_bucket(opts={})
168
- raise MissingArgumentException.new, 'report_bucket is missing arguments' \
169
- if not (opts.key?(:status) or opts.key?(:twitter_update) \
170
- or opts.key?(:bucket_name))
171
-
172
- opts[:fail_on] = opts.key?(:fail_on) ? opts[:fail_on] : 0
173
- failed_radars = []
174
-
175
- reinit_rest
176
- @rs.buckets.each do |bucket|
177
- if bucket['name'] == opts[:bucket_name]
178
- @rs.radars(bucket['key']).each do |radar|
179
- begin
180
- if @rs.latest_radar_result(bucket['key'], radar['uuid'])['result'] != 'pass'
181
- failed_radars.push radar
182
- end
183
- rescue RunscopeAPIException => r
184
- p r
185
- next
186
- end
187
- end
188
- end
189
- end
190
-
191
- if failed_radars.length >= opts[:fail_on]
192
- failed_radars.each do |radar|
193
- @sp.create_realtime_incident(@sp_page, *parameterize(radar).concat([opts[:status], opts[:twitter_update]]))
194
- end
195
- end
196
- end
197
-
198
- # Update status page with all radars under the specified
199
- # buckets
200
- #
201
- # Parameters: {:bucket_names => list of names of buckets containing radars,
202
- # :status => page status (either 'investigating|identified|monitoring|resolved'),
203
- # :twitter_update => do you want to post status to twitter (bool),
204
- # :fail_on => number of failures to induce statuspage update (int, default 0)}
205
- def self.report_buckets(bucket_names, status, twitter_update)
206
- raise MissingArgumentException.new, 'report_buckets is missing arguments' \
207
- if not (opts.key?(:status) or opts.key?(:twitter_update) \
208
- or opts.key?(:bucket_name))
209
-
210
- opts[:fail_on] = opts.key?(:fail_on) ? opts[:fail_on] : 0
211
- failed_radars = []
212
-
213
- reinit_rest
214
-
215
- @rs.buckets.each do |bucket|
216
- if opts[:bucket_names].include?(bucket['name'])
217
- @rs.radars(bucket['key']).each do |radar|
218
- begin
219
- if @rs.latest_radar_result(bucket['key'], radar['uuid'])['result'] != 'pass'
220
- failed_radars.push radar
221
- end
222
- rescue RunscopeAPIException => r
223
- p r
224
- next
225
- end
226
- end
227
- end
228
- end
229
-
230
- if failed_radars.length >= opts[:fail_on]
231
- failed_radars.each do |radar|
232
- @sp.create_realtime_incident(@sp_page, *parameterize(radar).concat([opts[:status], opts[:twitter_update]]))
233
- end
234
- end
235
- end
236
-
237
- end
1
+ require_relative 'runscope_statuspage/version'
2
+ require_relative 'runscope_statuspage/exceptions'
3
+ require_relative 'runscope_statuspage/runscope_api'
4
+ require_relative 'runscope_statuspage/statuspage_api'
5
+
6
+ module RunscopeStatuspage
7
+ # Let Ruby write boring getters and setters
8
+ class << self; attr_accessor :rs_key, :sp_key, :sp_page, :name, :msg, :rs, :sp; end
9
+
10
+ # API credentials and IDs
11
+ @rs_key, @sp_key, @sp_page = ''
12
+
13
+ # Verbage sent to statuspage
14
+ @name = 'Suspected issues with /name/'
15
+ @msg = 'Our automated test detected an issue while testing the /description/ endpoint. We are currently investigating this issue.'
16
+
17
+ # As the user may decide (for whatever reason)
18
+ # to change API keys after one request, we re-initialize
19
+ # these objects.
20
+ def self.reinit_rest
21
+ @rs = RunscopeAPI.new(@rs_key)
22
+ @sp = StatuspageAPI.new(@sp_key)
23
+ end
24
+
25
+ # Splice radar hash values from keys defined in
26
+ # @name and @msg.
27
+ def self.parameterize(radar)
28
+ rname = @name
29
+ rmsg = @msg
30
+
31
+ @name.scan(/.*?(\/)([A-Za-z]*)(\/)/).each do |set|
32
+ set.each do |token|
33
+ if radar.has_key?(token)
34
+ next if radar[:token].nil?
35
+ rname = rname.sub!("/#{token}/", radar[token]) unless (token == "/" and token.length == 1)
36
+ end
37
+ end
38
+ end
39
+
40
+ @msg.scan(/.*?(\/)([A-Za-z]*)(\/)/).each do |set|
41
+ set.each do |token|
42
+ if radar.has_key?(token)
43
+ next if radar[:token].nil?
44
+ rmsg = rmsg.sub!("/#{token}/", radar[token]) unless (token == "/" and token.length == 1)
45
+ end
46
+ end
47
+ end
48
+
49
+ return rname, rmsg
50
+ end
51
+
52
+ # Update status page with all radars, from all buckets.
53
+ # An error will most likely be thrown if you have empty buckets.
54
+ #
55
+ # Parameters: {:status => page status (either 'investigating|identified|monitoring|resolved'),
56
+ # :twitter_update => do you want to post status to twitter (bool),
57
+ # :fail_on => number of failures to induce statuspage update (int, default 0),
58
+ # :no_sp => skip statuspage.io report and return data}
59
+ def self.report_everything(opts={})
60
+ raise MissingArgumentException.new, 'report_everything is missing arguments' \
61
+ if not (opts.key?(:status) or opts.key?(:twitter_update))
62
+
63
+ opts[:fail_on] = opts.key?(:fail_on) ? opts[:fail_on] : 0
64
+ opts[:no_sp] = opts.key?(:no_sp) ? opts[:no_sp] : false
65
+
66
+ failed_radars = []
67
+ event_info = []
68
+
69
+ reinit_rest
70
+ @rs.buckets.each do |bucket|
71
+ @rs.radars(bucket['key']).each do |radar|
72
+ begin
73
+ if @rs.latest_radar_result(bucket['key'], radar['uuid'])['result'] != 'pass'
74
+ failed_radars.push radar
75
+ end
76
+ rescue RunscopeAPIException => r
77
+ p r
78
+ next
79
+ end
80
+ end
81
+ end
82
+
83
+ if failed_radars.length >= opts[:fail_on]
84
+ failed_radars.each do |radar|
85
+ data = *parameterize(radar)
86
+
87
+ @sp.create_realtime_incident(@sp_page, data.concat([opts[:status], opts[:twitter_update]])) if not opts[:no_sp]
88
+ event_info.push data if opts[:no_sp]
89
+ end
90
+ end
91
+
92
+ event_info if opts[:no_sp]
93
+ end
94
+
95
+ # Update status page with one radar, from one bucket.
96
+ #
97
+ # Parameters: {:bucket_name => name of bucket containing radars,
98
+ # :radar_name => name of radar within bucket,
99
+ # :status => page status (either 'investigating|identified|monitoring|resolved'),
100
+ # :twitter_update => do you want to post status to twitter (bool),
101
+ # :fail_on => number of failures to induce statuspage update (int, default 0),
102
+ # :no_sp => skip statuspage.io report and return data}
103
+ def self.report_radar(opts = {})
104
+ raise MissingArgumentException.new, 'report_radar is missing arguments' \
105
+ if not (opts.key?(:status) or opts.key?(:twitter_update) \
106
+ or opts.key?(:bucket_name) or opts.key?(:radar_name))
107
+
108
+ opts[:fail_on] = opts.key?(:fail_on) ? opts[:fail_on] : 0
109
+ opts[:no_sp] = opts.key?(:no_sp) ? opts[:no_sp] : false
110
+
111
+ failed_radars = []
112
+ event_info = []
113
+
114
+ reinit_rest
115
+ @rs.buckets.each do |bucket|
116
+ if bucket['name'] == bucket_name
117
+ @rs.radars(bucket['key']).each do |radar|
118
+ begin
119
+ if @rs.latest_radar_result(bucket['key'], radar['uuid'])['result'] != 'pass' and radar['name'] == radar_name
120
+ failed_radars.push radar
121
+ end
122
+ rescue RunscopeAPIException => r
123
+ p r
124
+ next
125
+ end
126
+ end
127
+ end
128
+ end
129
+
130
+ if failed_radars.length >= opts[:fail_on]
131
+ failed_radars.each do |radar|
132
+ data = *parameterize(radar)
133
+
134
+ @sp.create_realtime_incident(@sp_page, data.concat([opts[:status], opts[:twitter_update]])) if not opts[:no_sp]
135
+ event_info.push data if opts[:no_sp]
136
+ end
137
+ end
138
+
139
+ event_info if opts[:no_sp]
140
+ end
141
+
142
+ # Update status page with list of radars, from one bucket.
143
+ #
144
+ # Parameters: {:bucket_name => name of bucket containing radars,
145
+ # :radar_names => list of names of radars within bucket,
146
+ # :status => page status (either 'investigating|identified|monitoring|resolved'),
147
+ # :twitter_update => do you want to post status to twitter (bool),
148
+ # :fail_on => number of failures to induce statuspage update (int, default 0),
149
+ # :no_sp => skip statuspage.io report and return data}
150
+ def self.report_radars(opts = {})
151
+ raise MissingArgumentException.new, 'report_radars is missing arguments' \
152
+ if not (opts.key?(:status) or opts.key?(:twitter_update) \
153
+ or opts.key?(:bucket_name) or opts.key?(:radar_names))
154
+
155
+ opts[:fail_on] = opts.key?(:fail_on) ? opts[:fail_on] : 0
156
+ opts[:no_sp] = opts.key?(:no_sp) ? opts[:no_sp] : false
157
+
158
+ failed_radars = []
159
+ event_info = []
160
+
161
+ reinit_rest
162
+ @rs.buckets.each do |bucket|
163
+ if bucket['name'] == opts[:bucket_name]
164
+ @rs.radars(bucket['key']).each do |radar|
165
+ begin
166
+ if @rs.latest_radar_result(bucket['key'], radar['uuid'])['result'] != 'pass' and opts[:radar_names].include?(radar['name'])
167
+ failed_radars.push radar
168
+ end
169
+ rescue RunscopeAPIException => r
170
+ p r
171
+ next
172
+ end
173
+ end
174
+ end
175
+ end
176
+
177
+ if failed_radars.length >= opts[:fail_on]
178
+ failed_radars.each do |radar|
179
+ data = *parameterize(radar)
180
+
181
+ @sp.create_realtime_incident(@sp_page, data.concat([opts[:status], opts[:twitter_update]])) if not opts[:no_sp]
182
+ event_info.push data if opts[:no_sp]
183
+ end
184
+ end
185
+
186
+ event_info if opts[:no_sp]
187
+ end
188
+
189
+ # Update status page with all radars under passed
190
+ # bucket name.
191
+ #
192
+ # Parameters: {:bucket_name => name of bucket containing radars,
193
+ # :status => page status (either 'investigating|identified|monitoring|resolved'),
194
+ # :twitter_update => do you want to post status to twitter (bool),
195
+ # :fail_on => number of failures to induce statuspage update (int, default 0),
196
+ # :no_sp => skip statuspage.io report and return data}
197
+ def self.report_bucket(opts={})
198
+ raise MissingArgumentException.new, 'report_bucket is missing arguments' \
199
+ if not (opts.key?(:status) or opts.key?(:twitter_update) \
200
+ or opts.key?(:bucket_name))
201
+
202
+ opts[:fail_on] = opts.key?(:fail_on) ? opts[:fail_on] : 0
203
+ opts[:no_sp] = opts.key?(:no_sp) ? opts[:no_sp] : false
204
+
205
+ failed_radars = []
206
+ event_info = []
207
+
208
+ reinit_rest
209
+ @rs.buckets.each do |bucket|
210
+ if bucket['name'] == opts[:bucket_name]
211
+ @rs.radars(bucket['key']).each do |radar|
212
+ begin
213
+ if @rs.latest_radar_result(bucket['key'], radar['uuid'])['result'] != 'pass'
214
+ failed_radars.push radar
215
+ end
216
+ rescue RunscopeAPIException => r
217
+ p r
218
+ next
219
+ end
220
+ end
221
+ end
222
+ end
223
+
224
+ if failed_radars.length >= opts[:fail_on]
225
+ failed_radars.each do |radar|
226
+ data = *parameterize(radar)
227
+
228
+ @sp.create_realtime_incident(@sp_page, data.concat([opts[:status], opts[:twitter_update]])) if not opts[:no_sp]
229
+ event_info.push data if opts[:no_sp]
230
+ end
231
+ end
232
+
233
+ event_info if opts[:no_sp]
234
+ end
235
+
236
+ # Update status page with all radars under the specified
237
+ # buckets
238
+ #
239
+ # Parameters: {:bucket_names => list of names of buckets containing radars,
240
+ # :status => page status (either 'investigating|identified|monitoring|resolved'),
241
+ # :twitter_update => do you want to post status to twitter (bool),
242
+ # :fail_on => number of failures to induce statuspage update (int, default 0),
243
+ # :no_sp => skip statuspage.io report and return data}
244
+ def self.report_buckets(bucket_names, status, twitter_update)
245
+ raise MissingArgumentException.new, 'report_buckets is missing arguments' \
246
+ if not (opts.key?(:status) or opts.key?(:twitter_update) \
247
+ or opts.key?(:bucket_name))
248
+
249
+ opts[:fail_on] = opts.key?(:fail_on) ? opts[:fail_on] : 0
250
+ opts[:no_sp] = opts.key?(:no_sp) ? opts[:no_sp] : false
251
+
252
+ failed_radars = []
253
+ event_info = []
254
+
255
+ reinit_rest
256
+
257
+ @rs.buckets.each do |bucket|
258
+ if opts[:bucket_names].include?(bucket['name'])
259
+ @rs.radars(bucket['key']).each do |radar|
260
+ begin
261
+ if @rs.latest_radar_result(bucket['key'], radar['uuid'])['result'] != 'pass'
262
+ failed_radars.push radar
263
+ end
264
+ rescue RunscopeAPIException => r
265
+ p r
266
+ next
267
+ end
268
+ end
269
+ end
270
+ end
271
+
272
+ if failed_radars.length >= opts[:fail_on]
273
+ failed_radars.each do |radar|
274
+ data = *parameterize(radar)
275
+
276
+ @sp.create_realtime_incident(@sp_page, data.concat([opts[:status], opts[:twitter_update]])) if not opts[:no_sp]
277
+ event_info.push data if opts[:no_sp]
278
+ end
279
+ end
280
+
281
+ event_info if opts[:no_sp]
282
+ end
283
+
284
+ end
@@ -1,3 +1,3 @@
1
- module RunscopeStatuspage
2
- VERSION = '0.1.4'
3
- end
1
+ module RunscopeStatuspage
2
+ VERSION = '0.1.5'
3
+ end
@@ -1,24 +1,24 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'runscope_statuspage/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'runscope_statuspage'
8
- spec.version = RunscopeStatuspage::VERSION
9
- spec.authors = ['David Stancu']
10
- spec.email = ['dstancu@nyu.edu']
11
-
12
-
13
- spec.summary = 'Push RunScope data to StatusPage.io'
14
- spec.description = 'Get test data from RunScope and easily report incidents to StatusPage.io, all with one gem.'
15
- spec.homepage = 'https://github.com/mach-kernel/runscope_statuspage'
16
- spec.license = 'MIT'
17
-
18
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ['lib']
21
-
22
- spec.add_development_dependency 'bundler', '~> 1.8'
23
- spec.add_development_dependency 'rake', '~> 10.0'
24
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'runscope_statuspage/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'runscope_statuspage'
8
+ spec.version = RunscopeStatuspage::VERSION
9
+ spec.authors = ['David Stancu']
10
+ spec.email = ['dstancu@nyu.edu']
11
+
12
+
13
+ spec.summary = 'Push RunScope data to StatusPage.io'
14
+ spec.description = 'Get test data from RunScope and easily report incidents to StatusPage.io, all with one gem.'
15
+ spec.homepage = 'https://github.com/mach-kernel/runscope_statuspage'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.8'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runscope_statuspage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Stancu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-24 00:00:00.000000000 Z
11
+ date: 2015-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  version: '0'
80
80
  requirements: []
81
81
  rubyforge_project:
82
- rubygems_version: 2.2.2
82
+ rubygems_version: 2.2.3
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: Push RunScope data to StatusPage.io