merb_hoptoad_notifier 1.0.12 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +8 -7
- data/lib/merb_hoptoad_notifier.rb +5 -5
- data/lib/merb_hoptoad_notifier/hoptoad_notifier.rb +42 -32
- metadata +3 -7
- data/spec/fixtures/hoptoad.yml +0 -9
- data/spec/merb_hoptoad_notifier_spec.rb +0 -15
- data/spec/spec.opts +0 -0
- data/spec/spec_helper.rb +0 -26
data/Rakefile
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'rake/gempackagetask'
|
3
2
|
require 'rubygems/specification'
|
4
3
|
require 'date'
|
@@ -6,10 +5,12 @@ require 'merb-core/version'
|
|
6
5
|
require 'spec/rake/spectask'
|
7
6
|
require 'bundler'
|
8
7
|
|
9
|
-
|
8
|
+
Bundler.require_env
|
9
|
+
|
10
|
+
require 'lib/merb_hoptoad_notifier'
|
10
11
|
|
11
12
|
NAME = "merb_hoptoad_notifier"
|
12
|
-
GEM_VERSION =
|
13
|
+
GEM_VERSION = Merb::HoptoadNotifier::VERSION
|
13
14
|
AUTHOR = "Corey Donohoe"
|
14
15
|
EMAIL = 'atmos@atmos.org'
|
15
16
|
HOMEPAGE = "http://github.com/atmos/merb_hoptoad_notifier"
|
@@ -28,14 +29,14 @@ spec = Gem::Specification.new do |s|
|
|
28
29
|
s.email = EMAIL
|
29
30
|
s.homepage = HOMEPAGE
|
30
31
|
|
31
|
-
manifest = Bundler::
|
32
|
+
manifest = Bundler::Dsl.load_gemfile(File.dirname(__FILE__) + '/Gemfile')
|
32
33
|
manifest.dependencies.each do |d|
|
33
34
|
next unless d.only && d.only.include?('release')
|
34
35
|
s.add_dependency(d.name, d.version)
|
35
36
|
end
|
36
37
|
|
37
38
|
s.require_path = 'lib'
|
38
|
-
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib
|
39
|
+
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib}/**/*")
|
39
40
|
end
|
40
41
|
|
41
42
|
Rake::GemPackageTask.new(spec) do |pkg|
|
@@ -50,11 +51,11 @@ task :make_spec do
|
|
50
51
|
end
|
51
52
|
|
52
53
|
Spec::Rake::SpecTask.new(:default) do |t|
|
53
|
-
t.spec_opts << %w(-fs --color)
|
54
|
+
t.spec_opts << %w(-fs --color)
|
54
55
|
t.spec_opts << '--loadby' << 'random'
|
55
56
|
t.spec_files = Dir["spec/*_spec.rb"]
|
56
57
|
t.rcov = ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true
|
57
|
-
t.rcov_opts << '--exclude' << '
|
58
|
+
t.rcov_opts << '--exclude' << 'vendor'
|
58
59
|
|
59
60
|
t.rcov_opts << '--text-summary'
|
60
61
|
t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
|
@@ -1,9 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
require File.join(libdir, 'hoptoad_notifier')
|
1
|
+
require 'toadhopper'
|
2
|
+
libdir = File.join(File.dirname(__FILE__), 'merb_hoptoad_notifier')
|
3
|
+
require File.join(libdir, 'hoptoad_notifier')
|
5
4
|
|
5
|
+
if defined?(Merb::BootLoader)
|
6
6
|
Merb::BootLoader.after_app_loads do
|
7
|
-
HoptoadNotifier.configure
|
7
|
+
Merb::HoptoadNotifier.configure
|
8
8
|
end
|
9
9
|
end
|
@@ -1,42 +1,52 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module Merb
|
2
|
+
module HoptoadNotifier
|
3
|
+
VERSION = '1.1.0'
|
4
|
+
class << self
|
5
|
+
attr_accessor :api_key, :logger, :environment_filters
|
6
|
+
end
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
+
def self.configure
|
9
|
+
key = YAML.load_file(Merb.root / 'config' / 'hoptoad.yml')
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
11
|
+
if key
|
12
|
+
env = key[Merb.env.to_sym]
|
13
|
+
env ? @api_key = env[:api_key] : raise(ArgumentError, "No hoptoad key for Merb environment #{Merb.env}")
|
14
|
+
end
|
12
15
|
end
|
13
|
-
end
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
17
|
+
def self.environment_filters
|
18
|
+
@environment_filters ||= [ ]
|
19
|
+
end
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
def self.environment_filters=(filters)
|
22
|
+
@environment_filters << filters
|
23
|
+
end
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
:url => "#{request.protocol}://#{request.host}#{request.path}",
|
26
|
-
:component => controller && controller.capitalize,
|
27
|
-
:action => request.params['action'],
|
28
|
-
:request => request,
|
29
|
-
:framework_env => Merb.env,
|
30
|
-
:notifier_name => 'Merb::HoptoadNotifier',
|
31
|
-
:notifier_version => '1.0.10',
|
32
|
-
:session => session.to_hash
|
33
|
-
}
|
34
|
-
dispatcher.post!(exception, options, {'X-Hoptoad-Client-Name' => 'Merb::HoptoadNotifier'})
|
25
|
+
def self.logger
|
26
|
+
@logger || Merb.logger
|
35
27
|
end
|
36
|
-
true
|
37
|
-
end
|
38
28
|
|
39
|
-
|
40
|
-
|
29
|
+
def self.notify_hoptoad(request, session)
|
30
|
+
request.exceptions.each do |exception|
|
31
|
+
options = {
|
32
|
+
:api_key => HoptoadNotifier.api_key,
|
33
|
+
:url => "#{request.protocol}://#{request.host}#{request.path}",
|
34
|
+
:component => request.params['controller'],
|
35
|
+
:action => request.params['action'],
|
36
|
+
:request => request,
|
37
|
+
:framework_env => Merb.env,
|
38
|
+
:notifier_name => 'Merb::HoptoadNotifier',
|
39
|
+
:notifier_version => Merb::HoptoadNotifier::VERSION,
|
40
|
+
:session => session.to_hash
|
41
|
+
}
|
42
|
+
dispatcher.filters = environment_filters.flatten
|
43
|
+
dispatcher.post!(exception, options, {'X-Hoptoad-Client-Name' => 'Merb::HoptoadNotifier'})
|
44
|
+
end
|
45
|
+
true
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.dispatcher
|
49
|
+
@dispatcher ||= ToadHopper.new(api_key)
|
50
|
+
end
|
41
51
|
end
|
42
52
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merb_hoptoad_notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Corey Donohoe
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-25 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.9.
|
33
|
+
version: 0.9.1
|
34
34
|
version:
|
35
35
|
description: Merb plugin that provides hoptoad exception notification
|
36
36
|
email: atmos@atmos.org
|
@@ -49,10 +49,6 @@ files:
|
|
49
49
|
- TODO
|
50
50
|
- lib/merb_hoptoad_notifier/hoptoad_notifier.rb
|
51
51
|
- lib/merb_hoptoad_notifier.rb
|
52
|
-
- spec/fixtures/hoptoad.yml
|
53
|
-
- spec/merb_hoptoad_notifier_spec.rb
|
54
|
-
- spec/spec.opts
|
55
|
-
- spec/spec_helper.rb
|
56
52
|
has_rdoc: true
|
57
53
|
homepage: http://github.com/atmos/merb_hoptoad_notifier
|
58
54
|
licenses: []
|
data/spec/fixtures/hoptoad.yml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
describe "HoptoadNotifier" do
|
4
|
-
before(:each) do
|
5
|
-
config = { :development => { :api_key=> ENV['MY_HOPTOAD_API_KEY'] || 'blah' } }
|
6
|
-
mock(YAML).load_file(File.join(Merb.root / 'config' / 'hoptoad.yml')) { config }
|
7
|
-
|
8
|
-
HoptoadNotifier.configure
|
9
|
-
end
|
10
|
-
describe "notification" do
|
11
|
-
it "posts to hoptoad" do
|
12
|
-
HoptoadNotifier.notify_hoptoad(fake_request_with_exceptions, { :user_id => 42 })
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
data/spec/spec.opts
DELETED
File without changes
|
data/spec/spec_helper.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
Bundler.require_env(:test)
|
2
|
-
$:.push File.join(File.dirname(__FILE__), '..', 'lib')
|
3
|
-
require 'rr'
|
4
|
-
require 'merb-core'
|
5
|
-
require 'merb_hoptoad_notifier'
|
6
|
-
require 'tmpdir'
|
7
|
-
require 'pp'
|
8
|
-
|
9
|
-
class TestError < RuntimeError
|
10
|
-
end
|
11
|
-
|
12
|
-
Spec::Runner.configure do |config|
|
13
|
-
config.mock_with :rr
|
14
|
-
def fake_request
|
15
|
-
Merb::Test::RequestHelper::FakeRequest.new
|
16
|
-
end
|
17
|
-
def fake_request_with_exceptions(params = { :controller => 'Application', :action => 'index' })
|
18
|
-
request = Merb::Test::RequestHelper::FakeRequest.new(:params => params)
|
19
|
-
begin
|
20
|
-
raise(TestError, 'I like turtles')
|
21
|
-
rescue => e
|
22
|
-
request.exceptions = [ e ]
|
23
|
-
end
|
24
|
-
request
|
25
|
-
end
|
26
|
-
end
|