merb_hoptoad_notifier 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README +59 -0
- data/Rakefile +62 -0
- data/TODO +2 -0
- data/lib/merb_hoptoad_notifier/hoptoad_notifier.rb +40 -0
- data/lib/merb_hoptoad_notifier.rb +9 -0
- data/spec/fixtures/hoptoad.yml +9 -0
- data/spec/merb_hoptoad_notifier_spec.rb +15 -0
- data/spec/spec.opts +0 -0
- data/spec/spec_helper.rb +26 -0
- metadata +85 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Corey Donohoe<atmos@atmos.org>, Joakim Kolsjö<trejje@gmail.com>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
merb_hoptoad_notifier
|
2
|
+
---------------------------------------------
|
3
|
+
This is merb plugin for exception notification with hoptoad. It should work with
|
4
|
+
any merb app that's based on merb 1.0 and higher
|
5
|
+
|
6
|
+
This plugin: http://github.com/atmos/merb_hoptoad_notifier/tree/master
|
7
|
+
The original: http://github.com/thoughtbot/hoptoad_notifier/tree/master
|
8
|
+
|
9
|
+
Usage:
|
10
|
+
|
11
|
+
1) Get your api key for your app from hoptoadapp.com
|
12
|
+
|
13
|
+
2) Add the api key to config/hoptoad.yml with a similar syntax as the following
|
14
|
+
---
|
15
|
+
:development: &defaults
|
16
|
+
:api_key: ZOMGLOLROFLMAO
|
17
|
+
|
18
|
+
:rake:
|
19
|
+
<<: *defaults
|
20
|
+
|
21
|
+
:test:
|
22
|
+
<<: *defaults
|
23
|
+
|
24
|
+
:production:
|
25
|
+
:api_key: UBERSECRETSHIT
|
26
|
+
|
27
|
+
|
28
|
+
3) Require hoptoad in init.rb
|
29
|
+
require 'merb_hoptoad_notifier'
|
30
|
+
|
31
|
+
4) Add the following method to your Exceptions controller. Depending on your merb version you'll need to use the exceptions,standard_error, or internal_server error as the action name. Kinda weak, but the API changed a lot in 0.9.x
|
32
|
+
|
33
|
+
class Exceptions < Merb::Controller
|
34
|
+
if %w( staging production ).include?(Merb.env)
|
35
|
+
def standard_error
|
36
|
+
HoptoadNotifier.notify_hoptoad(request, session)
|
37
|
+
render
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
5) Restart the server, trigger an error(in staging or prod) and check that it arrived at hoptoad :)
|
43
|
+
|
44
|
+
|
45
|
+
Filtersing your post environment
|
46
|
+
--------------------------------
|
47
|
+
If you have environmental variables set in your ruby process that should not be sent to hoptoad,
|
48
|
+
there's a mechanism for filtering those attributes now. Throw something like this in
|
49
|
+
config/init.rb
|
50
|
+
|
51
|
+
Merb::BootLoader.after_app_loads do
|
52
|
+
HoptoadNotifier.environment_filters = %w(^AWS ^EC2 SECRET PRIVATE KEY)
|
53
|
+
end
|
54
|
+
|
55
|
+
Each of these words will be compiled into a regex so you should be able to use anchors if needed.
|
56
|
+
|
57
|
+
Thanks to the following GitHubbers
|
58
|
+
----------------------------------
|
59
|
+
joakimk, fairchild and cv.
|
data/Rakefile
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require 'rubygems/specification'
|
4
|
+
require 'date'
|
5
|
+
require 'merb-core/version'
|
6
|
+
require 'spec/rake/spectask'
|
7
|
+
require 'bundler'
|
8
|
+
|
9
|
+
install_home = ENV['GEM_HOME'] ? "-i #{ENV['GEM_HOME']}" : ""
|
10
|
+
|
11
|
+
NAME = "merb_hoptoad_notifier"
|
12
|
+
GEM_VERSION = "1.0.10"
|
13
|
+
AUTHOR = "Corey Donohoe"
|
14
|
+
EMAIL = 'atmos@atmos.org'
|
15
|
+
HOMEPAGE = "http://github.com/atmos/merb_hoptoad_notifier"
|
16
|
+
SUMMARY = "Merb plugin that provides hoptoad exception notification"
|
17
|
+
|
18
|
+
spec = Gem::Specification.new do |s|
|
19
|
+
s.rubyforge_project = 'merb'
|
20
|
+
s.name = NAME
|
21
|
+
s.version = GEM_VERSION
|
22
|
+
s.platform = Gem::Platform::RUBY
|
23
|
+
s.has_rdoc = true
|
24
|
+
s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
|
25
|
+
s.summary = SUMMARY
|
26
|
+
s.description = s.summary
|
27
|
+
s.author = AUTHOR
|
28
|
+
s.email = EMAIL
|
29
|
+
s.homepage = HOMEPAGE
|
30
|
+
|
31
|
+
manifest = Bundler::Environment.load(File.dirname(__FILE__) + '/Gemfile')
|
32
|
+
manifest.dependencies.each do |d|
|
33
|
+
next unless d.only && d.only.include?('release')
|
34
|
+
s.add_dependency(d.name, d.version)
|
35
|
+
end
|
36
|
+
|
37
|
+
s.require_path = 'lib'
|
38
|
+
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
|
39
|
+
end
|
40
|
+
|
41
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
42
|
+
pkg.gem_spec = spec
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "create a gemspec file"
|
46
|
+
task :make_spec do
|
47
|
+
File.open("#{NAME}.gemspec", "w") do |file|
|
48
|
+
file.puts spec.to_ruby
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
Spec::Rake::SpecTask.new(:default) do |t|
|
53
|
+
t.spec_opts << %w(-fs --color) << %w(-O spec/spec.opts)
|
54
|
+
t.spec_opts << '--loadby' << 'random'
|
55
|
+
t.spec_files = Dir["spec/*_spec.rb"]
|
56
|
+
t.rcov = ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true
|
57
|
+
t.rcov_opts << '--exclude' << '.gem/'
|
58
|
+
|
59
|
+
t.rcov_opts << '--text-summary'
|
60
|
+
t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
|
61
|
+
t.rcov_opts << '--only-uncovered'
|
62
|
+
end
|
data/TODO
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
module HoptoadNotifier
|
2
|
+
class << self
|
3
|
+
attr_accessor :api_key, :logger
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.configure
|
7
|
+
key = YAML.load_file(Merb.root / 'config' / 'hoptoad.yml')
|
8
|
+
|
9
|
+
if key
|
10
|
+
env = key[Merb.env.to_sym]
|
11
|
+
env ? @api_key = env[:api_key] : raise(ArgumentError, "No hoptoad key for Merb environment #{Merb.env}")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.logger
|
16
|
+
@logger || Merb.logger
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.notify_hoptoad(request, session)
|
20
|
+
request.exceptions.each do |exception|
|
21
|
+
options = {
|
22
|
+
:api_key => HoptoadNotifier.api_key,
|
23
|
+
:url => "#{request.protocol}://#{request.host}#{request.path}",
|
24
|
+
:component => request.params['controller'],
|
25
|
+
:action => request.params['action'],
|
26
|
+
:request => request,
|
27
|
+
:framework_env => Merb.env,
|
28
|
+
:notifier_name => 'Merb::HoptoadNotifier',
|
29
|
+
:notifier_version => '1.0.10',
|
30
|
+
:session => session.to_hash
|
31
|
+
}
|
32
|
+
dispatcher.post!(exception, options, {'X-Hoptoad-Client-Name' => 'Merb::HoptoadNotifier'})
|
33
|
+
end
|
34
|
+
true
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.dispatcher
|
38
|
+
@dispatcher ||= ToadHopper.new(api_key)
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,15 @@
|
|
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
ADDED
File without changes
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
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
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: merb_hoptoad_notifier
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.10
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Corey Donohoe
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-12-15 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: merb-core
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.0.9
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: toadhopper
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.9.1
|
34
|
+
version:
|
35
|
+
description: Merb plugin that provides hoptoad exception notification
|
36
|
+
email: atmos@atmos.org
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- README
|
43
|
+
- LICENSE
|
44
|
+
- TODO
|
45
|
+
files:
|
46
|
+
- LICENSE
|
47
|
+
- README
|
48
|
+
- Rakefile
|
49
|
+
- TODO
|
50
|
+
- lib/merb_hoptoad_notifier/hoptoad_notifier.rb
|
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
|
+
has_rdoc: true
|
57
|
+
homepage: http://github.com/atmos/merb_hoptoad_notifier
|
58
|
+
licenses: []
|
59
|
+
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: "0"
|
70
|
+
version:
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: "0"
|
76
|
+
version:
|
77
|
+
requirements: []
|
78
|
+
|
79
|
+
rubyforge_project: merb
|
80
|
+
rubygems_version: 1.3.5
|
81
|
+
signing_key:
|
82
|
+
specification_version: 3
|
83
|
+
summary: Merb plugin that provides hoptoad exception notification
|
84
|
+
test_files: []
|
85
|
+
|