flapjack 0.7.18 → 0.7.19

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.
Files changed (100) hide show
  1. data/CHANGELOG.md +7 -0
  2. data/bin/flapjack +3 -0
  3. data/bin/flapjack-nagios-receiver +4 -1
  4. data/bin/flapjack-netsaint-parser +2 -1
  5. data/bin/flapjack-populator +6 -3
  6. data/bin/receive-events +3 -1
  7. data/bin/simulate-failed-check +2 -1
  8. data/etc/flapjack_config.yaml.example +20 -0
  9. data/features/events.feature +1 -1
  10. data/features/events_check_names.feature +1 -1
  11. data/features/notification_rules.feature +1 -1
  12. data/features/notifications.feature +1 -1
  13. data/features/steps/events_steps.rb +18 -17
  14. data/features/steps/flapjack-netsaint-parser_steps.rb +1 -2
  15. data/features/steps/notifications_steps.rb +14 -1
  16. data/features/support/env.rb +27 -10
  17. data/flapjack.gemspec +1 -3
  18. data/lib/flapjack/coordinator.rb +30 -20
  19. data/lib/flapjack/data/contact.rb +3 -2
  20. data/lib/flapjack/data/entity.rb +3 -3
  21. data/lib/flapjack/data/entity_check.rb +116 -43
  22. data/lib/flapjack/data/event.rb +10 -10
  23. data/lib/flapjack/data/message.rb +3 -6
  24. data/lib/flapjack/data/notification.rb +122 -57
  25. data/lib/flapjack/data/notification_rule.rb +11 -11
  26. data/lib/flapjack/filters/acknowledgement.rb +2 -2
  27. data/lib/flapjack/filters/ok.rb +1 -1
  28. data/lib/flapjack/gateways/api/entity_check_presenter.rb +1 -0
  29. data/lib/flapjack/gateways/api/entity_methods.rb +4 -6
  30. data/lib/flapjack/gateways/api/rack/json_params_parser.rb +1 -1
  31. data/lib/flapjack/gateways/email.rb +3 -5
  32. data/lib/flapjack/gateways/email/{alert.html.haml → alert.html.erb} +0 -0
  33. data/lib/flapjack/gateways/jabber.rb +66 -35
  34. data/lib/flapjack/gateways/oobetet.rb +5 -7
  35. data/lib/flapjack/gateways/pagerduty.rb +7 -7
  36. data/lib/flapjack/gateways/web.rb +101 -41
  37. data/lib/flapjack/gateways/web/public/css/flapjack.css +1 -1
  38. data/lib/flapjack/gateways/web/views/{_css.haml → _css.html.erb} +2 -1
  39. data/lib/flapjack/gateways/web/views/_foot.html.erb +3 -0
  40. data/lib/flapjack/gateways/web/views/_head.html.erb +4 -0
  41. data/lib/flapjack/gateways/web/views/_nav.html.erb +9 -0
  42. data/lib/flapjack/gateways/web/views/check.html.erb +204 -0
  43. data/lib/flapjack/gateways/web/views/checks.html.erb +77 -0
  44. data/lib/flapjack/gateways/web/views/contact.html.erb +114 -0
  45. data/lib/flapjack/gateways/web/views/contacts.html.erb +42 -0
  46. data/lib/flapjack/gateways/web/views/entities.html.erb +39 -0
  47. data/lib/flapjack/gateways/web/views/entity.html.erb +67 -0
  48. data/lib/flapjack/gateways/web/views/index.html.erb +27 -0
  49. data/lib/flapjack/gateways/web/views/self_stats.html.erb +97 -0
  50. data/lib/flapjack/logger.rb +71 -23
  51. data/lib/flapjack/notifier.rb +157 -0
  52. data/lib/flapjack/patches.rb +1 -41
  53. data/lib/flapjack/pikelet.rb +4 -2
  54. data/lib/flapjack/{executive.rb → processor.rb} +32 -145
  55. data/lib/flapjack/version.rb +1 -1
  56. data/spec/lib/flapjack/coordinator_spec.rb +134 -71
  57. data/spec/lib/flapjack/data/contact_spec.rb +1 -0
  58. data/spec/lib/flapjack/data/entity_check_spec.rb +146 -30
  59. data/spec/lib/flapjack/data/entity_spec.rb +4 -4
  60. data/spec/lib/flapjack/data/event_spec.rb +4 -4
  61. data/spec/lib/flapjack/data/message_spec.rb +2 -3
  62. data/spec/lib/flapjack/data/notification_spec.rb +13 -19
  63. data/spec/lib/flapjack/gateways/api/entity_methods_spec.rb +2 -2
  64. data/spec/lib/flapjack/gateways/jabber_spec.rb +34 -0
  65. data/spec/lib/flapjack/gateways/pagerduty_spec.rb +0 -2
  66. data/spec/lib/flapjack/gateways/web/views/{check.haml_spec.rb → check.html.erb_spec.rb} +2 -2
  67. data/spec/lib/flapjack/gateways/web/views/{contact.haml_spec.rb → contact.html.erb_spec.rb} +3 -3
  68. data/spec/lib/flapjack/gateways/web/views/index.html.erb_spec.rb +14 -0
  69. data/spec/lib/flapjack/gateways/web_spec.rb +20 -8
  70. data/spec/lib/flapjack/logger_spec.rb +30 -28
  71. data/spec/lib/flapjack/notifier_spec.rb +6 -0
  72. data/spec/lib/flapjack/pikelet_spec.rb +8 -8
  73. data/spec/lib/flapjack/{executive_spec.rb → processor_spec.rb} +4 -4
  74. data/spec/spec_helper.rb +1 -13
  75. data/spec/support/erb_view_helper.rb +23 -0
  76. data/tasks/profile.rake +1 -1
  77. data/tmp/acknowledge.rb +3 -1
  78. data/tmp/create_event_ok.rb +3 -1
  79. data/tmp/create_event_unknown.rb +3 -1
  80. data/tmp/create_events_failure.rb +3 -1
  81. data/tmp/create_events_ok.rb +3 -1
  82. data/tmp/create_events_ok_fail_ack_ok.rb +3 -1
  83. data/tmp/create_events_ok_failure.rb +3 -1
  84. data/tmp/create_events_ok_failure_ack.rb +3 -1
  85. data/tmp/test_json_post.rb +5 -3
  86. data/tmp/test_notification_rules_api.rb +5 -3
  87. metadata +32 -61
  88. data/lib/flapjack/gateways/web/views/_foot.haml +0 -8
  89. data/lib/flapjack/gateways/web/views/_head.haml +0 -10
  90. data/lib/flapjack/gateways/web/views/_nav.haml +0 -14
  91. data/lib/flapjack/gateways/web/views/check.haml +0 -191
  92. data/lib/flapjack/gateways/web/views/checks.haml +0 -49
  93. data/lib/flapjack/gateways/web/views/contact.haml +0 -85
  94. data/lib/flapjack/gateways/web/views/contacts.haml +0 -30
  95. data/lib/flapjack/gateways/web/views/entities.haml +0 -28
  96. data/lib/flapjack/gateways/web/views/entity.haml +0 -50
  97. data/lib/flapjack/gateways/web/views/index.haml +0 -32
  98. data/lib/flapjack/gateways/web/views/self_stats.haml +0 -70
  99. data/spec/lib/flapjack/gateways/web/views/index.haml_spec.rb +0 -13
  100. data/spec/support/haml_view_helper.rb +0 -15
@@ -1,13 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'web/views/check.haml', :haml_view => true do
3
+ describe 'web/views/check.html.erb', :erb_view => true do
4
4
 
5
5
  it "should escape unsafe check characters in URIs" do
6
6
  @entity = 'abc-xyz-01'
7
7
  @check = 'Disk / Utilisation'
8
8
  @last_notifications = {}
9
9
 
10
- page = render_haml('check.haml', self)
10
+ page = render_erb('check.html.erb', binding)
11
11
  page.should match(%r{/abc-xyz-01/Disk%20%2F%20Utilisation})
12
12
  end
13
13
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'web/views/contact.haml', :haml_view => true do
3
+ describe 'web/views/contact.html.erb', :erb_view => true do
4
4
 
5
5
  it "should escape unsafe check characters in URI parameters" do
6
6
  @contact = mock('contact')
@@ -15,8 +15,8 @@ describe 'web/views/contact.haml', :haml_view => true do
15
15
 
16
16
  @entities_and_checks = [{:entity => entity, :checks => checks}]
17
17
 
18
- page = render_haml('contact.haml', self)
19
- page.should match(%r{\?entity=abc-xyz-01&check=Disk\+%2F\+Utilisation})
18
+ page = render_erb('contact.html.erb', binding)
19
+ page.should match(%r{\?entity=abc-xyz-01&check=Disk%20%2F%20Utilisation})
20
20
  end
21
21
 
22
22
  end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'web/views/checks.html.erb', :erb_view => true do
4
+
5
+ it "should escape unsafe check characters in URI parameters" do
6
+ @states = {'abc-xyz-01' => [['Disk / Utilisation', 'OK', 'Looking good', '-', '-', false, false, nil, nil]]}
7
+ @entities_sorted = ['abc-xyz-01']
8
+ @adjective = "all"
9
+
10
+ page = render_erb('checks.html.erb', binding)
11
+ page.should match(%r{\?entity=abc-xyz-01&check=Disk%20%2F%20Utilisation})
12
+ end
13
+
14
+ end
@@ -43,17 +43,24 @@ describe Flapjack::Gateways::Web, :sinatra => true, :logger => true do
43
43
  end
44
44
 
45
45
  def expect_check_stats
46
- redis.should_receive(:keys).with('check:*:*').and_return([])
47
- redis.should_receive(:zcard).with('failed_checks')
46
+ Flapjack::Data::EntityCheck.should_receive(:count_all).
47
+ with(:redis => redis).and_return(1)
48
+ Flapjack::Data::EntityCheck.should_receive(:count_all_failing).
49
+ with(:redis => redis).and_return(1)
48
50
  end
49
51
 
50
52
  def expect_entity_stats
53
+ Flapjack::Data::Entity.should_receive(:find_all_with_checks).
54
+ with(:redis => redis).and_return([entity_name])
55
+ Flapjack::Data::Entity.should_receive(:find_all_with_failing_checks).
56
+ with(:redis => redis).and_return([entity_name])
51
57
  end
52
58
 
53
59
  def expect_entity_check_status(ec)
54
60
  time = Time.now.to_i
55
61
 
56
62
  ec.should_receive(:state).and_return('ok')
63
+ ec.should_receive(:summary).and_return('happy results are returned')
57
64
  ec.should_receive(:last_update).and_return(time - (3 * 60 * 60))
58
65
  ec.should_receive(:last_change).and_return(time - (3 * 60 * 60))
59
66
  ec.should_receive(:last_notification_for_state).with(:problem).and_return({:timestamp => time - ((3 * 60 * 60) + (5 * 60))})
@@ -67,8 +74,9 @@ describe Flapjack::Gateways::Web, :sinatra => true, :logger => true do
67
74
  # (for the methods that access redis directly)
68
75
 
69
76
  it "shows a page listing all checks" do
70
- redis.should_receive(:keys).with('*:*:states').and_return(["#{entity_name}:#{check}"])
71
-
77
+ #redis.should_receive(:keys).with('*:*:states').and_return(["#{entity_name}:#{check}"])
78
+ Flapjack::Data::EntityCheck.should_receive(:find_all_by_entity).
79
+ with(:redis => redis).and_return({entity_name => [check]})
72
80
  expect_check_stats
73
81
 
74
82
  expect_entity_check_status(entity_check)
@@ -84,7 +92,7 @@ describe Flapjack::Gateways::Web, :sinatra => true, :logger => true do
84
92
  end
85
93
 
86
94
  it "shows a page listing failing checks" do
87
- redis.should_receive(:zrange).with('failed_checks', 0, -1).and_return(["#{entity_name}:#{check}"])
95
+ #redis.should_receive(:zrange).with('failed_checks', 0, -1).and_return(["#{entity_name}:#{check}"])
88
96
 
89
97
  expect_check_stats
90
98
 
@@ -93,6 +101,9 @@ describe Flapjack::Gateways::Web, :sinatra => true, :logger => true do
93
101
  Flapjack::Data::Entity.should_receive(:find_by_name).
94
102
  with(entity_name, :redis => redis).and_return(entity)
95
103
 
104
+ Flapjack::Data::EntityCheck.should_receive(:find_all_failing_by_entity).
105
+ with(:redis => redis).and_return({entity_name => [check]})
106
+
96
107
  Flapjack::Data::EntityCheck.should_receive(:for_entity).
97
108
  with(entity, 'ping', :redis => redis).and_return(entity_check)
98
109
  get '/checks_failing'
@@ -100,8 +111,8 @@ describe Flapjack::Gateways::Web, :sinatra => true, :logger => true do
100
111
  end
101
112
 
102
113
  it "shows a page listing flapjack statistics" do
103
- redis.should_receive(:keys).with('check:*').and_return([])
104
- redis.should_receive(:zrange).with('failed_checks', 0, -1).and_return(["#{entity_name}:#{check}"])
114
+ #redis.should_receive(:keys).with('check:*').and_return([])
115
+ #redis.should_receive(:zrange).with('failed_checks', 0, -1).and_return(["#{entity_name}:#{check}"])
105
116
  expect_stats
106
117
  expect_check_stats
107
118
  expect_entity_stats
@@ -130,9 +141,10 @@ describe Flapjack::Gateways::Web, :sinatra => true, :logger => true do
130
141
  entity_check.should_receive(:current_maintenance).with(:scheduled => true).and_return(false)
131
142
  entity_check.should_receive(:current_maintenance).with(:scheduled => false).and_return(false)
132
143
  entity_check.should_receive(:contacts).and_return([])
133
-
134
144
  entity_check.should_receive(:historical_states).
135
145
  with(nil, time.to_i, :order => 'desc', :limit => 20).and_return([])
146
+ entity_check.should_receive(:enabled?).with().
147
+ and_return(true)
136
148
 
137
149
  Flapjack::Data::Entity.should_receive(:find_by_name).
138
150
  with(entity_name, :redis => redis).and_return(entity)
@@ -1,32 +1,34 @@
1
1
  require 'spec_helper'
2
- require 'flapjack/pikelet'
3
2
 
4
3
  describe Flapjack::Logger do
5
4
 
6
- # let(:logger) { mock(Log4r::Logger) }
7
- # let(:stdout_out) { mock('stdout_out') }
8
- # let(:syslog_out) { mock('syslog_out') }
9
-
10
- it "creates a log4r logger"
11
-
12
- it "changes the logging level via config hash"
13
-
14
- it "passes a log command to its log4r logger"
15
-
16
- # def setup_logger(type)
17
- # formatter = mock('Formatter')
18
- # Log4r::PatternFormatter.should_receive(:new).with(
19
- # :pattern => "[%l] %d :: #{type} :: %m",
20
- # :date_pattern => "%Y-%m-%dT%H:%M:%S%z").and_return(formatter)
21
-
22
- # stdout_out.should_receive(:formatter=).with(formatter)
23
- # syslog_out.should_receive(:formatter=).with(formatter)
24
-
25
- # Log4r::StdoutOutputter.should_receive(:new).and_return(stdout_out)
26
- # Log4r::SyslogOutputter.should_receive(:new).and_return(syslog_out)
27
- # logger.should_receive(:add).with(stdout_out)
28
- # logger.should_receive(:add).with(syslog_out)
29
- # Log4r::Logger.should_receive(:new).and_return(logger)
30
- # end
31
-
32
- end
5
+ let(:logger) { mock(::Logger) }
6
+
7
+ let(:sys_logger) { mock(::Logger) }
8
+ let(:syslog) { mock(Syslog) }
9
+
10
+ it "creates a logger logging to STDOUT and syslog" do
11
+ logger.should_receive(:formatter=).with(an_instance_of(Proc))
12
+ logger.should_receive(:level=).and_return(Logger::DEBUG)
13
+ logger.should_receive(:warn).with("Yowza!")
14
+ ::Logger.should_receive(:new).with(STDOUT).and_return(logger)
15
+
16
+ if Syslog.const_defined?('Logger', false)
17
+ sys_logger.should_receive(:formatter=).with(an_instance_of(Proc))
18
+ sys_logger.should_receive(:level=).with(Logger::DEBUG)
19
+ sys_logger.should_receive(:warn).with("Yowza!")
20
+ Syslog.const_get('Logger', false).should_receive(:new).with('flapjack').and_return(sys_logger)
21
+ else
22
+ syslog.should_receive(:log).with(Syslog::Constants::LOG_WARNING, /\[WARN\] :: spec :: %s/, "Yowza!")
23
+ Syslog.should_receive(:"opened?").and_return(false)
24
+ Syslog.should_receive(:open).with('flapjack',
25
+ (Syslog::Constants::LOG_PID | Syslog::Constants::LOG_CONS),
26
+ Syslog::Constants::LOG_USER).and_return(syslog)
27
+ Syslog.should_receive(:mask=).with(Syslog::LOG_UPTO(Syslog::Constants::LOG_DEBUG))
28
+ end
29
+
30
+ flogger = Flapjack::Logger.new('spec', 'level' => 'debug')
31
+ flogger.warn "Yowza!"
32
+ end
33
+
34
+ end
@@ -0,0 +1,6 @@
1
+ require 'spec_helper'
2
+ require 'flapjack/notifier'
3
+
4
+ describe Flapjack::Notifier do
5
+
6
+ end
@@ -3,10 +3,10 @@ require 'flapjack/pikelet'
3
3
 
4
4
  describe Flapjack::Pikelet do
5
5
 
6
- let(:config) { mock('config') }
6
+ let(:config) { mock('config') }
7
7
  let(:redis_config) { mock('redis_config') }
8
8
 
9
- let(:logger) { mock(Flapjack::Logger) }
9
+ let(:logger) { mock(Flapjack::Logger) }
10
10
 
11
11
  let(:fiber) { mock(Fiber) }
12
12
 
@@ -16,21 +16,21 @@ describe Flapjack::Pikelet do
16
16
  Flapjack::Pikelet::Resque.class_variable_set(:@@resque_pool, nil)
17
17
  end
18
18
 
19
- it "creates and starts an executive pikelet" do
19
+ it "creates and starts a processor pikelet" do
20
20
  Flapjack::Logger.should_receive(:new).and_return(logger)
21
21
 
22
22
  config.should_receive(:[]).with('logger').and_return(nil)
23
23
 
24
- executive = mock('executive')
25
- executive.should_receive(:start)
26
- Flapjack::Executive.should_receive(:new).with(:config => config,
24
+ processor = mock('processor')
25
+ processor.should_receive(:start)
26
+ Flapjack::Processor.should_receive(:new).with(:config => config,
27
27
  :redis_config => redis_config, :boot_time => time, :logger => logger).
28
- and_return(executive)
28
+ and_return(processor)
29
29
 
30
30
  fiber.should_receive(:resume)
31
31
  Fiber.should_receive(:new).and_yield.and_return(fiber)
32
32
 
33
- pik = Flapjack::Pikelet.create('executive', :config => config,
33
+ pik = Flapjack::Pikelet.create('processor', :config => config,
34
34
  :redis_config => redis_config, :boot_time => time)
35
35
  pik.should be_a(Flapjack::Pikelet::Generic)
36
36
  pik.start
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
- require 'flapjack/executive'
2
+ require 'flapjack/processor'
3
3
 
4
- describe Flapjack::Executive, :logger => true do
4
+ describe Flapjack::Processor, :logger => true do
5
5
 
6
- # NB: this is only testing the public API of the Executive class, which is pretty limited.
6
+ # NB: this is only testing the public API of the Processor class, which is pretty limited.
7
7
  # (initialize, main, stop). Most test coverage for this class comes from the cucumber features.
8
8
 
9
9
  # TODO this does too much -- split it up
@@ -40,7 +40,7 @@ describe Flapjack::Executive, :logger => true do
40
40
  Flapjack::Data::Event.should_receive(:pending_count).with(:redis => redis).and_return(0)
41
41
 
42
42
  Flapjack::RedisPool.should_receive(:new).and_return(redis)
43
- executive = Flapjack::Executive.new(:config => {}, :logger => @logger)
43
+ executive = Flapjack::Processor.new(:config => {}, :logger => @logger)
44
44
 
45
45
  shutdown_evt = mock(Flapjack::Data::Event)
46
46
  shutdown_evt.should_receive(:inspect)
data/spec/spec_helper.rb CHANGED
@@ -61,18 +61,6 @@ RSpec.configure do |config|
61
61
  # --seed 1234
62
62
  config.order = 'random'
63
63
 
64
- config.before(:each, :logger => true) do
65
- def test_logger(class_name)
66
- logger = Log4r::Logger.new(class_name)
67
- outp = Log4r::FileOutputter.new(class_name,
68
- :filename => File.join(File.dirname(__FILE__), '..', 'log', 'test.log'))
69
- outp.formatter = Log4r::PatternFormatter.new(:pattern => "[%l] %d :: #{class_name} :: %m",
70
- :date_pattern => "%Y-%m-%dT%H:%M:%S%z")
71
- logger.add(outp)
72
- logger
73
- end
74
- end
75
-
76
64
  config.around(:each, :redis => true) do |example|
77
65
  @redis = ::Redis.new(:db => 14, :driver => :ruby)
78
66
  @redis.flushdb
@@ -92,7 +80,7 @@ RSpec.configure do |config|
92
80
  Delorean.back_to_the_present
93
81
  end
94
82
 
95
- config.include HamlViewHelper, :haml_view => true
83
+ config.include ErbViewHelper, :erb_view => true
96
84
  config.include Rack::Test::Methods, :sinatra => true
97
85
  config.include JsonSpec::Helpers, :json => true
98
86
  end
@@ -0,0 +1,23 @@
1
+ require 'flapjack/utility'
2
+
3
+ module ErbViewHelper
4
+
5
+ TEMPLATE_PATH = File.dirname(__FILE__) +
6
+ '/../../lib/flapjack/gateways/web/views/'
7
+
8
+ include Flapjack::Utility
9
+
10
+ def render_erb(file, bind)
11
+ erb = ERB.new(File.read(TEMPLATE_PATH + file))
12
+ erb.result(bind)
13
+ end
14
+
15
+ def h(text)
16
+ ERB::Util.h(text)
17
+ end
18
+
19
+ def u(text)
20
+ ERB::Util.u(text)
21
+ end
22
+
23
+ end
data/tasks/profile.rake CHANGED
@@ -278,7 +278,7 @@ namespace :profile do
278
278
  contents = msg.contents
279
279
  contents['event_count'] = n
280
280
  redis.rpush(config_env['jabber_gateway']['queue'],
281
- Yajl::Encoder.encode(contents))
281
+ Oj.dump(contents))
282
282
  end
283
283
  end
284
284
 
data/tmp/acknowledge.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'redis'
4
- require 'json'
4
+
5
+ require 'oj'
6
+ Oj.default_options = { :indent => 0, :mode => :strict }
5
7
 
6
8
  if not id = ARGV.first then
7
9
  puts "Usage: acknowledge.rb <id>"
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'redis'
4
- require 'json'
4
+
5
+ require 'oj'
6
+ Oj.default_options = { :indent => 0, :mode => :strict }
5
7
 
6
8
  #id = "%.2d" % (1..10).to_a[rand(9)]
7
9
 
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'redis'
4
- require 'json'
4
+
5
+ require 'oj'
6
+ Oj.default_options = { :indent => 0, :mode => :strict }
5
7
 
6
8
  #id = "%.2d" % (1..10).to_a[rand(9)]
7
9
 
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'redis'
4
- require 'json'
4
+
5
+ require 'oj'
6
+ Oj.default_options = { :indent => 0, :mode => :strict }
5
7
 
6
8
  id = "%.2d" % (1..10).to_a[rand(9)]
7
9
 
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'redis'
4
- require 'json'
4
+
5
+ require 'oj'
6
+ Oj.default_options = { :indent => 0, :mode => :strict }
5
7
 
6
8
  id = "%.2d" % (1..10).to_a[rand(9)]
7
9
 
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'redis'
4
- require 'json'
4
+
5
+ require 'oj'
6
+ Oj.default_options = { :indent => 0, :mode => :strict }
5
7
 
6
8
  id = "%.2d" % (1..10).to_a[rand(9)]
7
9
 
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'redis'
4
- require 'json'
4
+
5
+ require 'oj'
6
+ Oj.default_options = { :indent => 0, :mode => :strict }
5
7
 
6
8
  id = "%.2d" % (1..10).to_a[rand(9)]
7
9
 
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'redis'
4
- require 'json'
4
+
5
+ require 'oj'
6
+ Oj.default_options = { :indent => 0, :mode => :strict }
5
7
 
6
8
  id = "%.2d" % (1..10).to_a[rand(9)]
7
9
 
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'HTTParty'
4
- require 'json'
3
+ require 'httparty'
4
+
5
+ require 'oj'
6
+ Oj.default_options = { :indent => 0, :mode => :strict }
5
7
 
6
8
  @payload ={
7
9
  "email" => "phil@gmail.com",
@@ -12,5 +14,5 @@ require 'json'
12
14
  "auto_action" => "true"
13
15
  }
14
16
 
15
- HTTParty.post( 'http://localhost:4091/notification_rules', :body => JSON.dump(@payload), :options => { :headers => { 'ContentType' => 'application/json' } })
17
+ HTTParty.post( 'http://localhost:4091/notification_rules', :body => Oj.dump(@payload), :options => { :headers => { 'ContentType' => 'application/json' } })
16
18