rails_riemann_middleware 0.5.1 → 0.6.0

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.
@@ -5,7 +5,7 @@ module RailsRiemannMiddleware
5
5
  class Event
6
6
  attr_reader :client, :options, :reporting_host, :tags
7
7
 
8
- def initialize(options)
8
+ def initialize(options={})
9
9
  @options = options
10
10
  @client = create_riemann_client
11
11
  @reporting_host = options[:reporting_host]
@@ -13,6 +13,10 @@ module RailsRiemannMiddleware
13
13
  event << message
14
14
  end
15
15
 
16
+ def deliver
17
+ send
18
+ end
19
+
16
20
  def message
17
21
  msg = {
18
22
  :host => env['HTTP_HOST'],
@@ -1,3 +1,3 @@
1
1
  module RailsRiemannMiddleware
2
- VERSION = "0.5.1"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -25,6 +25,16 @@ module RailsRiemannMiddleware
25
25
  Duration.new(event, env, start_time).send if send_durations
26
26
  end
27
27
 
28
+ def self.exception_notification(env, exception)
29
+ event = Event.new
30
+ ExceptionNotification.new(event, env, exception)
31
+ end
32
+
33
+ def self.background_exception_notification(exception)
34
+ event = Event.new
35
+ env = {}
36
+ ExceptionNotification.new(event, env, exception)
37
+ end
28
38
  end
29
39
 
30
40
  end
@@ -14,6 +14,7 @@ Gem::Specification.new do |gem|
14
14
  gem.name = "rails_riemann_middleware"
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = RailsRiemannMiddleware::VERSION
17
+ gem.license = 'MIT'
17
18
 
18
19
  gem.add_dependency("riemann-client", "~> 0.2.0")
19
20
 
File without changes
@@ -0,0 +1,23 @@
1
+ require_relative 'spec_helper'
2
+ require 'rails_riemann_middleware/exception_notification'
3
+
4
+ module RailsRiemannMiddleware
5
+ describe ExceptionNotification do
6
+ let(:event) {MiniTest::Mock.new}
7
+ let(:env) { {'HTTP_HOST' => 'some_host'}}
8
+ let(:exception) {Object.new}
9
+
10
+ subject {ExceptionNotification.new(event, env, exception)}
11
+
12
+ describe '#deliver' do
13
+ it "adds its message to its event" do
14
+ message = Object.new
15
+ event.expect(:<<, Object.new, [message])
16
+ subject.stub(:message, message) do
17
+ subject.deliver
18
+ end
19
+ event.verify
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,37 @@
1
+ require_relative 'spec_helper'
2
+ require 'rails_riemann_middleware'
3
+
4
+ module RailsRiemannMiddleware
5
+ describe Notifier do
6
+ let(:exception_notification_new) { MiniTest::Mock.new }
7
+ let(:error) { Object.new }
8
+
9
+ # Support ExceptionNotification gem API
10
+ describe '#exception_notification' do
11
+ it "creates an ExceptionNotification with an event" do
12
+ env = Object.new
13
+ exception_notification_new.expect(:call, nil) do |a1, a2, a3|
14
+ a1.kind_of?(Event) && a2 == env && a3 == error
15
+ end
16
+
17
+ ExceptionNotification.stub(:new, exception_notification_new) do
18
+ Notifier.exception_notification(env, error)
19
+ end
20
+ exception_notification_new.verify
21
+ end
22
+ end
23
+
24
+ describe "#background_exception_notification" do
25
+ it "creates an ExceptionNotification with event and empty env" do
26
+ exception_notification_new.expect(:call, nil) do |a1, a2, a3|
27
+ a1.kind_of?(Event) && a2 == {} && a3 == error
28
+ end
29
+
30
+ ExceptionNotification.stub(:new, exception_notification_new) do
31
+ Notifier.background_exception_notification(error)
32
+ end
33
+ exception_notification_new.verify
34
+ end
35
+ end
36
+ end
37
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_riemann_middleware
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-19 00:00:00.000000000 Z
12
+ date: 2013-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: riemann-client
16
- requirement: &70188642881040 !ruby/object:Gem::Requirement
16
+ requirement: &70117650213820 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 0.2.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70188642881040
24
+ version_requirements: *70117650213820
25
25
  description: Rack middleware for sending data to riemann
26
26
  email:
27
27
  - outtenr@gmail.com
@@ -41,10 +41,13 @@ files:
41
41
  - lib/rails_riemann_middleware/headers.rb
42
42
  - lib/rails_riemann_middleware/version.rb
43
43
  - rails_riemann_middleware.gemspec
44
- - specs/duraction_spec.rb
44
+ - specs/duration_spec.rb
45
+ - specs/exception_notification_spec.rb
46
+ - specs/notifier_spec.rb
45
47
  - specs/spec_helper.rb
46
48
  homepage: ''
47
- licenses: []
49
+ licenses:
50
+ - MIT
48
51
  post_install_message:
49
52
  rdoc_options: []
50
53
  require_paths: