flapjack 1.1.0 → 1.2.0rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.ruby-version +1 -1
  4. data/.travis.yml +12 -7
  5. data/CHANGELOG.md +12 -0
  6. data/Gemfile +6 -2
  7. data/Gemfile-ruby1.9 +29 -0
  8. data/Gemfile-ruby1.9.lock +251 -0
  9. data/README.md +2 -2
  10. data/Rakefile +1 -0
  11. data/etc/flapjack_config.yaml.example +2 -2
  12. data/features/steps/events_steps.rb +2 -2
  13. data/features/steps/flapjack-netsaint-parser_steps.rb +1 -1
  14. data/features/support/env.rb +1 -6
  15. data/lib/flapjack/cli/import.rb +2 -5
  16. data/lib/flapjack/cli/purge.rb +4 -4
  17. data/lib/flapjack/cli/receiver.rb +122 -54
  18. data/lib/flapjack/cli/server.rb +0 -5
  19. data/lib/flapjack/coordinator.rb +6 -0
  20. data/lib/flapjack/data/contact.rb +10 -62
  21. data/lib/flapjack/data/entity.rb +36 -52
  22. data/lib/flapjack/data/entity_check.rb +90 -21
  23. data/lib/flapjack/data/event.rb +4 -5
  24. data/lib/flapjack/data/notification.rb +8 -10
  25. data/lib/flapjack/data/notification_rule.rb +32 -35
  26. data/lib/flapjack/data/tagged.rb +48 -0
  27. data/lib/flapjack/gateways/jabber.rb +4 -5
  28. data/lib/flapjack/gateways/jsonapi/check_methods.rb +45 -7
  29. data/lib/flapjack/gateways/jsonapi/check_presenter.rb +1 -1
  30. data/lib/flapjack/gateways/jsonapi/contact_methods.rb +8 -2
  31. data/lib/flapjack/gateways/jsonapi/entity_methods.rb +26 -8
  32. data/lib/flapjack/gateways/jsonapi/medium_methods.rb +13 -9
  33. data/lib/flapjack/gateways/jsonapi/metrics_methods.rb +2 -2
  34. data/lib/flapjack/gateways/jsonapi/notification_rule_methods.rb +1 -1
  35. data/lib/flapjack/gateways/jsonapi/pagerduty_credential_methods.rb +24 -17
  36. data/lib/flapjack/gateways/jsonapi/rack/json_params_parser.rb +1 -1
  37. data/lib/flapjack/gateways/jsonapi/report_methods.rb +4 -4
  38. data/lib/flapjack/gateways/jsonapi.rb +52 -31
  39. data/lib/flapjack/gateways/oobetet.rb +2 -3
  40. data/lib/flapjack/gateways/pagerduty.rb +9 -8
  41. data/lib/flapjack/gateways/web/public/js/backbone.jsonapi.js +19 -0
  42. data/lib/flapjack/gateways/web/public/js/flapjack.js +6 -2
  43. data/lib/flapjack/gateways/web/public/js/modules/contact.js +9 -14
  44. data/lib/flapjack/gateways/web/public/js/modules/medium.js +1 -0
  45. data/lib/flapjack/gateways/web/public/js/self_stats.js +1 -1
  46. data/lib/flapjack/gateways/web/views/edit_contacts.html.erb +3 -3
  47. data/lib/flapjack/gateways/web.rb +8 -7
  48. data/lib/flapjack/notifier.rb +2 -4
  49. data/lib/flapjack/processor.rb +2 -2
  50. data/lib/flapjack/version.rb +1 -1
  51. data/lib/flapjack.rb +10 -0
  52. data/spec/lib/flapjack/coordinator_spec.rb +18 -0
  53. data/spec/lib/flapjack/data/contact_spec.rb +4 -12
  54. data/spec/lib/flapjack/data/entity_check_spec.rb +56 -3
  55. data/spec/lib/flapjack/data/entity_spec.rb +79 -67
  56. data/spec/lib/flapjack/data/event_spec.rb +78 -78
  57. data/spec/lib/flapjack/data/notification_rule_spec.rb +4 -2
  58. data/spec/lib/flapjack/gateways/jsonapi/check_methods_spec.rb +94 -11
  59. data/spec/lib/flapjack/gateways/jsonapi/entity_methods_spec.rb +84 -0
  60. data/spec/lib/flapjack/gateways/pagerduty_spec.rb +5 -3
  61. data/spec/lib/flapjack/gateways/web_spec.rb +3 -3
  62. data/spec/service_consumers/pact_helper.rb +74 -0
  63. data/spec/service_consumers/pacts/flapjack-diner_v1.0.json +4522 -0
  64. data/spec/service_consumers/provider_states_for_flapjack-diner.rb +356 -0
  65. data/spec/spec_helper.rb +0 -8
  66. data/spec/support/jsonapi_helper.rb +1 -1
  67. data/tasks/benchmarks.rake +6 -3
  68. data/tasks/profile.rake +1 -1
  69. data/tmp/acknowledge.rb +0 -3
  70. data/tmp/create_event_ok.rb +0 -3
  71. data/tmp/create_event_unknown.rb +0 -3
  72. data/tmp/create_events_failure.rb +0 -3
  73. data/tmp/create_events_ok.rb +0 -3
  74. data/tmp/create_events_ok_fail_ack_ok.rb +0 -3
  75. data/tmp/create_events_ok_failure.rb +2 -5
  76. data/tmp/create_events_ok_failure_ack.rb +0 -3
  77. data/tmp/test_json_post.rb +4 -3
  78. data/tmp/test_notification_rules_api.rb +2 -3
  79. metadata +13 -8
  80. data/lib/flapjack/data/tag.rb +0 -61
  81. data/lib/flapjack/data/tag_set.rb +0 -16
  82. data/spec/lib/flapjack/data/tag_spec.rb +0 -36
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4e8b5d1bee24a164e37f5db62f177d02cb470cb
4
- data.tar.gz: f7e916ff508251675628c89ff70a31a030ee31b2
3
+ metadata.gz: 2d2385cedabb54ffdf76fab97912ff06918d6d1d
4
+ data.tar.gz: 5df58568fccb796ee1f45e332a711b5b01003d15
5
5
  SHA512:
6
- metadata.gz: 4ea75824a365cf143acd0db2581a440799a8d9dda7b093fc55fb3325b05dc5bc4617e64d548bc7529a6bb64a3562f7c202daf9640c4b6c6e489f42119f6e84e0
7
- data.tar.gz: 05ed36b6fe5ad8745b4e4d27e44f1bdbf7097c59d4ff1bf5a31edf92ab72e157087e904a44d5e2147584eab58fcd050806f59130b77cf69692945d6920e89f77
6
+ metadata.gz: 2192ac69c3abfffd68ab6dd23dbbd4bf2ffb0bbb411620b8c6356857511f6792868a678f15796a8a116bec52b7ff2208b5ff251583fc57825e747816218b3532
7
+ data.tar.gz: f7bfa433a64c42747c3b9359c8e28049d618f10ee6c03787df83818a2f63dd7a2c04194c234371f7151d3bfd21b22cf28715f0783d80ef91fb8148e3b80ce941
data/.gitignore CHANGED
@@ -19,6 +19,7 @@ vendor
19
19
  .bundle
20
20
  etc/*.yaml
21
21
  coverage
22
+ tmp/pacts
22
23
  tmp/cucumber_cli
23
24
  tmp/pids/*
24
25
  tmp/spec*
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1.2
1
+ 2.1.3
data/.travis.yml CHANGED
@@ -1,10 +1,16 @@
1
1
  language: ruby
2
- rvm:
3
- - 1.9.3
4
- - '2.0'
5
- - '2.1'
6
- gemfile:
7
- - Gemfile
2
+ matrix:
3
+ include:
4
+ - rvm: 1.9.3
5
+ gemfile: Gemfile-ruby1.9
6
+ script: "bundle exec rspec spec && bundle exec rake pact:verify && bundle exec cucumber features"
7
+ env: BUNDLE_GEMFILE=Gemfile-ruby1.9
8
+ - rvm: '2.0'
9
+ gemfile: Gemfile
10
+ script: "bundle exec rspec spec && bundle exec rake pact:verify && bundle exec cucumber features"
11
+ - rvm: '2.1'
12
+ gemfile: Gemfile
13
+ script: "bundle exec rspec spec && bundle exec rake pact:verify && bundle exec cucumber features"
8
14
  services:
9
15
  - redis-server
10
16
  before_script:
@@ -12,7 +18,6 @@ before_script:
12
18
  before_install:
13
19
  - git submodule update --init --recursive
14
20
  - gem install bundler
15
- script: bundle exec rspec spec && bundle exec cucumber features
16
21
  notifications:
17
22
  irc:
18
23
  channels:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  ## Flapjack Changelog
2
2
 
3
+ # 1.2.0rc1 - 2014-10-08
4
+ - Feature: Allow updating an entities name via PATCH /entities/id[,id...] #628 (@ali-graham)
5
+ - Feature: Pact specs for flapjack-diner compatability testing #663 (@ali-graham)
6
+ - Feature: more api check methods #644 (@ali-graham)
7
+ - Chore: optimise tag code #654 (@ali-graham)
8
+ - Chore: fix #653, overuse of Redis KEYS in mirror #661 (@ali-graham)
9
+ - Bug: Entities should return linked checks with list of check "ids" in API #648 (@ali-graham)
10
+ - Bug: 500 error getting all checks from API #641 (@ali-graham)
11
+ - Bug: Pager Duty credentials get throws error #657 (@ali-graham)
12
+ - Bug: Flapjack crashes when email alert is triggered #656 (@ali-graham)
13
+ - Bug: Fix /edit_contacts media saving after adding contacts #651 (@ali-graham)
14
+
3
15
  # 1.1.0 - 2014-09-10
4
16
  - Feature: Add autorefresh for the web GUI (Closes: #494) #607 (@Hobbsee)
5
17
  - Feature: twilio sms sending #633 (@jessereynolds)
data/Gemfile CHANGED
@@ -11,6 +11,7 @@ group :test do
11
11
  gem 'cucumber'
12
12
  gem 'delorean'
13
13
  gem 'rack-test'
14
+ gem 'pact'
14
15
  gem 'async_rack_test', '>= 0.0.5'
15
16
  gem 'resque_spec'
16
17
  gem 'webmock'
@@ -20,6 +21,9 @@ group :test do
20
21
  gem 'guard-cucumber'
21
22
  gem 'fuubar'
22
23
  gem 'simplecov', :require => false
23
- gem 'debugger-ruby_core_source', '>= 1.3.4' # required for perftools
24
- gem 'perftools.rb'
24
+
25
+ if RUBY_VERSION.split('.')[0] == '1' && RUBY_VERSION.split('.')[1] == '9'
26
+ gem 'debugger-ruby_core_source', '>= 1.3.4' # required for perftools.rb
27
+ gem 'perftools.rb'
28
+ end
25
29
  end
data/Gemfile-ruby1.9 ADDED
@@ -0,0 +1,29 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :name => 'flapjack'
4
+
5
+ group :development do
6
+ gem 'ruby-prof'
7
+ end
8
+
9
+ group :test do
10
+ gem 'rspec', '~> 3.0'
11
+ gem 'cucumber'
12
+ gem 'delorean'
13
+ gem 'rack-test'
14
+ gem 'pact'
15
+ gem 'async_rack_test', '>= 0.0.5'
16
+ gem 'resque_spec'
17
+ gem 'webmock'
18
+ gem 'guard'
19
+ gem 'rb-fsevent'
20
+ gem 'guard-rspec'
21
+ gem 'guard-cucumber'
22
+ gem 'fuubar'
23
+ gem 'simplecov', :require => false
24
+
25
+ if RUBY_VERSION.split('.')[0] == '1' && RUBY_VERSION.split('.')[1] == '9'
26
+ gem 'debugger-ruby_core_source', '>= 1.3.4' # required for perftools.rb
27
+ gem 'perftools.rb'
28
+ end
29
+ end
@@ -0,0 +1,251 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ flapjack (1.2.0rc1)
5
+ activesupport (~> 3.2.14)
6
+ blather (~> 0.8.3)
7
+ chronic
8
+ chronic_duration
9
+ dante
10
+ em-http-request
11
+ em-resque
12
+ em-synchrony (~> 1.0.2)
13
+ eventmachine (~> 1.0.0)
14
+ gli (= 2.12.0)
15
+ hiredis
16
+ ice_cube
17
+ mail
18
+ nokogiri (= 1.6.2.1)
19
+ oj (>= 2.9.0)
20
+ rack-fiber_pool
21
+ rake
22
+ rbtrace
23
+ redis (~> 3.0.6)
24
+ resque (~> 1.23.0)
25
+ sinatra
26
+ terminal-table
27
+ thin (~> 1.6.1)
28
+ tzinfo (~> 1.0.1)
29
+ tzinfo-data
30
+
31
+ GEM
32
+ remote: https://rubygems.org/
33
+ specs:
34
+ activesupport (3.2.19)
35
+ i18n (~> 0.6, >= 0.6.4)
36
+ multi_json (~> 1.0)
37
+ addressable (2.3.6)
38
+ async_rack_test (0.0.5)
39
+ awesome_print (1.2.0)
40
+ blather (0.8.8)
41
+ activesupport (>= 2.3.11)
42
+ eventmachine (>= 1.0.0)
43
+ girl_friday
44
+ niceogiri (~> 1.0)
45
+ nokogiri (~> 1.5, >= 1.5.6)
46
+ builder (3.2.2)
47
+ celluloid (0.16.0)
48
+ timers (~> 4.0.0)
49
+ chronic (0.10.2)
50
+ chronic_duration (0.10.6)
51
+ numerizer (~> 0.1.1)
52
+ coderay (1.1.0)
53
+ connection_pool (1.2.0)
54
+ cookiejar (0.3.2)
55
+ crack (0.4.2)
56
+ safe_yaml (~> 1.0.0)
57
+ cucumber (1.3.17)
58
+ builder (>= 2.1.2)
59
+ diff-lcs (>= 1.1.3)
60
+ gherkin (~> 2.12)
61
+ multi_json (>= 1.7.5, < 2.0)
62
+ multi_test (>= 0.1.1)
63
+ daemons (1.1.9)
64
+ dante (0.2.0)
65
+ debugger-ruby_core_source (1.3.5)
66
+ delorean (2.1.0)
67
+ chronic
68
+ diff-lcs (1.2.5)
69
+ docile (1.1.5)
70
+ em-hiredis (0.1.1)
71
+ hiredis (~> 0.4.0)
72
+ em-http-request (1.1.2)
73
+ addressable (>= 2.3.4)
74
+ cookiejar
75
+ em-socksify (>= 0.3)
76
+ eventmachine (>= 1.0.3)
77
+ http_parser.rb (>= 0.6.0)
78
+ em-resque (1.1.1)
79
+ em-hiredis (~> 0.1.0)
80
+ em-synchrony (~> 1.0.0)
81
+ resque (~> 1.2)
82
+ em-socksify (0.3.0)
83
+ eventmachine (>= 1.0.0.beta.4)
84
+ em-synchrony (1.0.3)
85
+ eventmachine (>= 1.0.0.beta.1)
86
+ eventmachine (1.0.3)
87
+ ffi (1.9.3)
88
+ find_a_port (1.0.1)
89
+ formatador (0.2.5)
90
+ fuubar (2.0.0)
91
+ rspec (~> 3.0)
92
+ ruby-progressbar (~> 1.4)
93
+ gherkin (2.12.2)
94
+ multi_json (~> 1.3)
95
+ girl_friday (0.11.2)
96
+ connection_pool (~> 1.0)
97
+ rubinius-actor
98
+ gli (2.12.0)
99
+ guard (2.6.1)
100
+ formatador (>= 0.2.4)
101
+ listen (~> 2.7)
102
+ lumberjack (~> 1.0)
103
+ pry (>= 0.9.12)
104
+ thor (>= 0.18.1)
105
+ guard-cucumber (1.4.1)
106
+ cucumber (>= 1.2.0)
107
+ guard (>= 1.1.0)
108
+ guard-rspec (4.3.1)
109
+ guard (~> 2.1)
110
+ rspec (>= 2.14, < 4.0)
111
+ hiredis (0.4.5)
112
+ hitimes (1.2.2)
113
+ http_parser.rb (0.6.0)
114
+ i18n (0.6.11)
115
+ ice_cube (0.12.1)
116
+ json (1.8.1)
117
+ listen (2.7.9)
118
+ celluloid (>= 0.15.2)
119
+ rb-fsevent (>= 0.9.3)
120
+ rb-inotify (>= 0.9)
121
+ lumberjack (1.0.9)
122
+ mail (2.6.1)
123
+ mime-types (>= 1.16, < 3)
124
+ method_source (0.8.2)
125
+ mime-types (2.4.1)
126
+ mini_portile (0.6.0)
127
+ msgpack (0.5.9)
128
+ multi_json (1.10.1)
129
+ multi_test (0.1.1)
130
+ niceogiri (1.1.2)
131
+ nokogiri (~> 1.5)
132
+ nokogiri (1.6.2.1)
133
+ mini_portile (= 0.6.0)
134
+ numerizer (0.1.1)
135
+ oj (2.10.3)
136
+ pact (1.3.3)
137
+ awesome_print (~> 1.1)
138
+ find_a_port (~> 1.0.1)
139
+ json
140
+ rack-test (~> 0.6.2)
141
+ randexp (~> 0.1.7)
142
+ rspec (>= 2.14)
143
+ term-ansicolor (~> 1.0)
144
+ thor
145
+ webrick
146
+ perftools.rb (2.0.1)
147
+ pry (0.10.1)
148
+ coderay (~> 1.1.0)
149
+ method_source (~> 0.8.1)
150
+ slop (~> 3.4)
151
+ rack (1.5.2)
152
+ rack-fiber_pool (0.9.3)
153
+ rack-protection (1.5.3)
154
+ rack
155
+ rack-test (0.6.2)
156
+ rack (>= 1.0)
157
+ rake (10.3.2)
158
+ randexp (0.1.7)
159
+ rb-fsevent (0.9.4)
160
+ rb-inotify (0.9.5)
161
+ ffi (>= 0.5.0)
162
+ rbtrace (0.4.5)
163
+ ffi (>= 1.0.6)
164
+ msgpack (>= 0.4.3)
165
+ trollop (>= 1.16.2)
166
+ redis (3.0.7)
167
+ redis-namespace (1.5.1)
168
+ redis (~> 3.0, >= 3.0.4)
169
+ resque (1.23.1)
170
+ multi_json (~> 1.0)
171
+ redis-namespace (~> 1.0)
172
+ sinatra (>= 0.9.2)
173
+ vegas (~> 0.1.2)
174
+ resque_spec (0.16.0)
175
+ resque (>= 1.19.0)
176
+ rspec-core (>= 3.0.0)
177
+ rspec-expectations (>= 3.0.0)
178
+ rspec-mocks (>= 3.0.0)
179
+ rspec (3.1.0)
180
+ rspec-core (~> 3.1.0)
181
+ rspec-expectations (~> 3.1.0)
182
+ rspec-mocks (~> 3.1.0)
183
+ rspec-core (3.1.4)
184
+ rspec-support (~> 3.1.0)
185
+ rspec-expectations (3.1.1)
186
+ diff-lcs (>= 1.2.0, < 2.0)
187
+ rspec-support (~> 3.1.0)
188
+ rspec-mocks (3.1.1)
189
+ rspec-support (~> 3.1.0)
190
+ rspec-support (3.1.0)
191
+ rubinius-actor (0.0.2)
192
+ rubinius-core-api
193
+ rubinius-core-api (0.0.1)
194
+ ruby-prof (0.15.1)
195
+ ruby-progressbar (1.6.0)
196
+ safe_yaml (1.0.3)
197
+ simplecov (0.9.1)
198
+ docile (~> 1.1.0)
199
+ multi_json (~> 1.0)
200
+ simplecov-html (~> 0.8.0)
201
+ simplecov-html (0.8.0)
202
+ sinatra (1.4.5)
203
+ rack (~> 1.4)
204
+ rack-protection (~> 1.4)
205
+ tilt (~> 1.3, >= 1.3.4)
206
+ slop (3.6.0)
207
+ term-ansicolor (1.3.0)
208
+ tins (~> 1.0)
209
+ terminal-table (1.4.5)
210
+ thin (1.6.3)
211
+ daemons (~> 1.0, >= 1.0.9)
212
+ eventmachine (~> 1.0)
213
+ rack (~> 1.0)
214
+ thor (0.19.1)
215
+ tilt (1.4.1)
216
+ timers (4.0.1)
217
+ hitimes
218
+ tins (1.3.3)
219
+ trollop (2.0)
220
+ tzinfo (1.0.1)
221
+ tzinfo-data (1.2014.8)
222
+ tzinfo (>= 1.0.0)
223
+ vegas (0.1.11)
224
+ rack (>= 1.0.0)
225
+ webmock (1.18.0)
226
+ addressable (>= 2.3.6)
227
+ crack (>= 0.3.2)
228
+ webrick (1.3.1)
229
+
230
+ PLATFORMS
231
+ ruby
232
+
233
+ DEPENDENCIES
234
+ async_rack_test (>= 0.0.5)
235
+ cucumber
236
+ debugger-ruby_core_source (>= 1.3.4)
237
+ delorean
238
+ flapjack!
239
+ fuubar
240
+ guard
241
+ guard-cucumber
242
+ guard-rspec
243
+ pact
244
+ perftools.rb
245
+ rack-test
246
+ rb-fsevent
247
+ resque_spec
248
+ rspec (~> 3.0)
249
+ ruby-prof
250
+ simplecov
251
+ webmock
data/README.md CHANGED
@@ -47,7 +47,7 @@ gpg -a --export 803709B6 | sudo apt-key add -
47
47
  Add the Flapjack Debian repository to your Apt sources:
48
48
 
49
49
  ``` text
50
- echo "deb http://packages.flapjack.io/deb/1.0 precise main" | sudo tee /etc/apt/sources.list.d/flapjack.list
50
+ echo "deb http://packages.flapjack.io/deb/v1 precise main" | sudo tee /etc/apt/sources.list.d/flapjack.list
51
51
  ```
52
52
 
53
53
  Install the latest Flapjack package:
@@ -57,7 +57,7 @@ sudo apt-get update
57
57
  sudo apt-get install flapjack
58
58
  ```
59
59
 
60
- Alternatively, [download the deb](http://packages.flapjack.io/deb/1.0/pool/main/f/flapjack/) and install using `sudo dpkg -i <filename>`
60
+ Alternatively, [download the deb](http://packages.flapjack.io/deb/v1/pool/main/f/flapjack/) and install using `sudo dpkg -i <filename>`
61
61
 
62
62
  The Flapjack package is an [Omnibus](https://github.com/opscode/omnibus) package and as such contains most dependencies under `/opt/flapjack`, including Redis.
63
63
 
data/Rakefile CHANGED
@@ -8,6 +8,7 @@ require 'fileutils'
8
8
  require 'rake'
9
9
 
10
10
  require 'resque/tasks'
11
+ require 'pact/tasks'
11
12
 
12
13
  Dir['tasks/**/*.rake'].each { |t| load t }
13
14
 
@@ -24,7 +24,7 @@ production:
24
24
  # This is useful is cases where your monitoring starts checking something
25
25
  # before it is completely provisioned
26
26
  # Value parsed by https://github.com/hpoydar/chronic_duration
27
- # You can disable this setting by specifying 0 seconds.
27
+ # You can disable this setting by specifying "0 seconds".
28
28
  new_check_scheduled_maintenance_duration: 100 years
29
29
  new_check_scheduled_maintenance_ignore_tags:
30
30
  - bypass_ncsm
@@ -236,7 +236,7 @@ development:
236
236
  # This is useful is cases where your monitoring starts checking something
237
237
  # before it is completely provisioned
238
238
  # Value parsed by https://github.com/hpoydar/chronic_duration
239
- # You can disable this setting by specifying 0 seconds.
239
+ # You can disable this setting by specifying "0 seconds".
240
240
  new_check_scheduled_maintenance_duration: 100 years
241
241
  new_check_scheduled_maintenance_ignore_tags:
242
242
  - bypass_ncsm
@@ -19,7 +19,7 @@ def drain_notifications
19
19
  end
20
20
 
21
21
  def submit_event(event)
22
- @redis.rpush 'events', event.to_json
22
+ @redis.rpush('events', Flapjack.dump_json(event))
23
23
  end
24
24
 
25
25
  def set_scheduled_maintenance(entity, check, duration)
@@ -300,7 +300,7 @@ Then /^dump notification rules for user (\S+)$/ do |contact|
300
300
  puts "There #{(rule_ids.length == 1) ? 'is' : 'are'} #{rule_ids.length} notification rule#{(rule_ids.length == 1) ? '' : 's'} for user #{contact}:"
301
301
  rule_ids.each {|rule_id|
302
302
  rule = Flapjack::Data::NotificationRule.find_by_id(rule_id, :redis => @redis)
303
- puts rule.to_json
303
+ puts Flapjack.dump_json(rule)
304
304
  }
305
305
  end
306
306
 
@@ -14,7 +14,7 @@ end
14
14
 
15
15
  Then /^I should see a valid JSON output$/ do
16
16
  expect {
17
- @data = Oj.load(@output)
17
+ @data = Flapjack.load_json(@output)
18
18
  }.not_to raise_error
19
19
  end
20
20
 
@@ -15,7 +15,6 @@ if ENV['COVERAGE']
15
15
  add_filter '/features/'
16
16
  end
17
17
  SimpleCov.at_exit do
18
- Oj.default_options = { :mode => :compat }
19
18
  SimpleCov.result.format!
20
19
  end
21
20
  end
@@ -34,11 +33,7 @@ require 'pathname'
34
33
  require 'webmock/cucumber'
35
34
  WebMock.disable_net_connect!
36
35
 
37
- require 'oj'
38
- Oj.mimic_JSON
39
- Oj.default_options = { :indent => 0, :mode => :strict }
40
- require 'active_support/json'
41
-
36
+ require 'flapjack'
42
37
  require 'flapjack/notifier'
43
38
  require 'flapjack/processor'
44
39
  require 'flapjack/patches'
@@ -1,8 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'oj'
4
- Oj.default_options = { :indent => 0, :mode => :strict }
5
-
6
3
  require 'redis'
7
4
 
8
5
  require 'flapjack/configuration'
@@ -32,7 +29,7 @@ module Flapjack
32
29
  # {'contacts' => [CONTACT_HASH, ...]}
33
30
 
34
31
  def contacts
35
- conts = Oj.load(File.new(@options[:from]))
32
+ conts = Flapjack.load_json(File.new(@options[:from]))
36
33
 
37
34
  if conts && conts.is_a?(Enumerable) && conts.any? {|e| !e['id'].nil?}
38
35
  conts.each do |contact|
@@ -47,7 +44,7 @@ module Flapjack
47
44
  end
48
45
 
49
46
  def entities
50
- ents = Oj.load(File.new(@options[:from]))
47
+ ents = Flapjack.load_json(File.new(@options[:from]))
51
48
 
52
49
  if ents && ents.is_a?(Enumerable) && ents.any? {|e| !e['id'].nil?}
53
50
  ents.each do |entity|
@@ -35,10 +35,10 @@ module Flapjack
35
35
  else
36
36
  Flapjack::Data::EntityCheck.all(:redis => redis, :create_entity => true)
37
37
  end
38
- purged = checks.map do |check|
39
- p = check.purge_history(options)
40
- p == 0 ? nil : p
41
- end.compact
38
+ purged = checks.inject([]) do |memo, check|
39
+ pu = check.purge_history(options)
40
+ memo << pu unless pu == 0
41
+ end
42
42
 
43
43
  if purged.empty?
44
44
  puts "Nothing to do"