rack-hoptoad-notifier 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ .idea
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.2-p136@rack-hoptoad-notifier
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ if respond_to? :source
2
+ source :gemcutter
3
+ source "http://gems.github.com"
4
+ end
5
+
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,81 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rack-hoptoad-notifier (0.1.0)
5
+ hoptoad_notifier (>= 2.4)
6
+ rack (>= 1.0)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ remote: http://gems.github.com/
11
+ specs:
12
+ activesupport (3.0.5)
13
+ archive-tar-minitar (0.5.2)
14
+ builder (3.0.0)
15
+ capybara (0.4.1.2)
16
+ celerity (>= 0.7.9)
17
+ culerity (>= 0.2.4)
18
+ mime-types (>= 1.16)
19
+ nokogiri (>= 1.3.3)
20
+ rack (>= 1.0.0)
21
+ rack-test (>= 0.5.4)
22
+ selenium-webdriver (>= 0.0.27)
23
+ xpath (~> 0.1.3)
24
+ celerity (0.8.8)
25
+ childprocess (0.1.8)
26
+ ffi (~> 1.0.6)
27
+ columnize (0.3.2)
28
+ culerity (0.2.15)
29
+ diff-lcs (1.1.2)
30
+ ffi (1.0.7)
31
+ rake (>= 0.8.7)
32
+ hoptoad_notifier (2.4.8)
33
+ activesupport
34
+ builder
35
+ json_pure (1.5.1)
36
+ linecache19 (0.5.11)
37
+ ruby_core_source (>= 0.1.4)
38
+ mime-types (1.16)
39
+ nokogiri (1.4.4)
40
+ rack (1.2.2)
41
+ rack-test (0.5.6)
42
+ rack (>= 1.0)
43
+ rake (0.8.7)
44
+ rr (1.0.2)
45
+ rspec (2.5.0)
46
+ rspec-core (~> 2.5.0)
47
+ rspec-expectations (~> 2.5.0)
48
+ rspec-mocks (~> 2.5.0)
49
+ rspec-core (2.5.1)
50
+ rspec-expectations (2.5.0)
51
+ diff-lcs (~> 1.1.2)
52
+ rspec-mocks (2.5.0)
53
+ ruby-debug-base19 (0.11.24)
54
+ columnize (>= 0.3.1)
55
+ linecache19 (>= 0.5.11)
56
+ ruby_core_source (>= 0.1.4)
57
+ ruby-debug19 (0.11.6)
58
+ columnize (>= 0.3.1)
59
+ linecache19 (>= 0.5.11)
60
+ ruby-debug-base19 (>= 0.11.19)
61
+ ruby_core_source (0.1.4)
62
+ archive-tar-minitar (>= 0.5.2)
63
+ rubyzip (0.9.4)
64
+ selenium-webdriver (0.1.4)
65
+ childprocess (>= 0.1.7)
66
+ ffi (>= 1.0.7)
67
+ json_pure
68
+ rubyzip
69
+ xpath (0.1.3)
70
+ nokogiri (~> 1.3)
71
+
72
+ PLATFORMS
73
+ ruby
74
+
75
+ DEPENDENCIES
76
+ capybara (= 0.4.1.2)
77
+ rack-hoptoad-notifier!
78
+ rack-test (= 0.5.6)
79
+ rr (= 1.0.2)
80
+ rspec (= 2.5.0)
81
+ ruby-debug19 (= 0.11.6)
data/README ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,21 @@
1
+ require "hoptoad_notifier"
2
+
3
+ class RackHoptoadNotifier
4
+ attr_reader :app
5
+ def initialize(app)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ response = app.call(env)
11
+ if env["rack.exception"]
12
+ HoptoadNotifier.notify(env["rack.exception"])
13
+ end
14
+ response
15
+ rescue Exception => e
16
+ HoptoadNotifier.notify(e)
17
+ raise e
18
+ end
19
+ end
20
+
21
+ require "#{File.dirname(__FILE__)}/rack-hoptoad-notifier/version"
@@ -0,0 +1,3 @@
1
+ class RackHoptoadNotifier
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib/', __FILE__)
3
+ $:.unshift lib unless $:.include?(lib)
4
+
5
+ require 'rack-hoptoad-notifier/version'
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "rack-hoptoad-notifier"
9
+ s.version = ::RackHoptoadNotifier::VERSION
10
+ s.platform = Gem::Platform::RUBY
11
+ s.authors = ["Brian Takita"]
12
+ s.email = ["btakita@truecar.com"]
13
+ s.homepage = "https://github.com/TrueCar/rack-hoptoad-notifier"
14
+ s.summary = %q{Simple Rack wrapper around HoptoadNotifier.notify}
15
+ s.description = %q{Simple Rack wrapper around HoptoadNotifier.notify}
16
+
17
+ s.required_rubygems_version = ">= 1.3.6"
18
+
19
+ # Man files are required because they are ignored by git
20
+ s.files = `git ls-files`.split("\n")
21
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
+ s.require_paths = ["lib"]
23
+
24
+ s.add_dependency "hoptoad_notifier", ">=2.4"
25
+ s.add_dependency "rack", ">=1.0"
26
+
27
+ s.add_development_dependency "capybara", "0.4.1.2"
28
+ s.add_development_dependency "rack-test", "0.5.6"
29
+ s.add_development_dependency "rr", "1.0.2"
30
+ s.add_development_dependency "rspec", "2.5.0"
31
+ s.add_development_dependency "ruby-debug19", "0.11.6"
32
+ end
@@ -0,0 +1,33 @@
1
+ require "#{File.dirname(__FILE__)}/spec_helper"
2
+
3
+ describe RackHoptoadNotifier do
4
+ context "when the request has no errors" do
5
+ it "does not call HoptoadNotifier.notify" do
6
+ dont_allow(HoptoadNotifier).notify
7
+ get "/"
8
+ end
9
+ end
10
+
11
+ context "when rack.exception is set" do
12
+ it "calls HoptoadNotifier.notify with the error" do
13
+ e = RuntimeError.new("test error")
14
+ stub(TestApp).call do |env|
15
+ env["rack.exception"] = e
16
+ [200, {}, {}]
17
+ end
18
+ mock(HoptoadNotifier).notify(e)
19
+ get "/"
20
+ end
21
+ end
22
+
23
+ context "when there is an error" do
24
+ it "calls HoptoadNotifier.notify with the error and raises the error" do
25
+ e = RuntimeError.new("test error")
26
+ stub(TestApp).call {raise e}
27
+ mock(HoptoadNotifier).notify(e)
28
+ lambda do
29
+ get "/"
30
+ end.should raise_error(e)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,78 @@
1
+ require "rubygems"
2
+
3
+ $LOAD_PATH.unshift(File.expand_path("#{File.dirname(__FILE__)}/../../lib"))
4
+
5
+ require "bundler"
6
+ Bundler.setup
7
+
8
+ require "rack/test"
9
+
10
+ require "rack-hoptoad-notifier"
11
+
12
+ ARGV.push("-b")
13
+ unless ARGV.include?("--format") || ARGV.include?("-f")
14
+ ARGV.push("--format", "nested")
15
+ end
16
+
17
+ require 'rspec'
18
+ require 'rspec/autorun'
19
+ require 'rr'
20
+ require 'capybara'
21
+ require 'capybara/rspec'
22
+
23
+ ENV["RACK_ENV"] = "test"
24
+
25
+ RSpec.configure do |configuration|
26
+ configuration.mock_with :rr
27
+ configuration.filter_run :focus => true
28
+ configuration.run_all_when_everything_filtered = true
29
+ configuration.before do
30
+ Capybara.reset!
31
+ end
32
+ end
33
+
34
+ RSpec::Core::ExampleGroup.class_eval do
35
+ include Capybara
36
+ [
37
+ :request, :last_request, :response, :last_response, :follow_redirect!,
38
+ :rack_mock_session
39
+ ].each do |method_name|
40
+ class_eval((<<-RUBY), __FILE__, __LINE__+1)
41
+ def #{method_name}(*args, &block)
42
+ page.driver.#{method_name}(*args, &block)
43
+ end
44
+ RUBY
45
+ end
46
+
47
+ [:get, :put, :post, :delete].each do |method_name|
48
+ class_eval((<<-RUBY), __FILE__, __LINE__+1)
49
+ def #{method_name}(*args, &block)
50
+ (res = page.driver.#{method_name}(*args, &block)).tap do
51
+ puts res.errors if res.status == 500
52
+ end
53
+ end
54
+ RUBY
55
+ end
56
+ end
57
+
58
+ class TestApp
59
+ class << self
60
+ def call(env)
61
+ [200, {}, {}]
62
+ end
63
+ end
64
+
65
+ attr_reader :app
66
+ def initialize(app)
67
+ @app = app
68
+ end
69
+
70
+ def call(env)
71
+ self.class.impl.call(env)
72
+ end
73
+ end
74
+
75
+ Capybara.app = Rack::Builder.new do
76
+ use RackHoptoadNotifier
77
+ run TestApp
78
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-hoptoad-notifier
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Brian Takita
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-03-22 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: hoptoad_notifier
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "2.4"
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: rack
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: "1.0"
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: capybara
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - "="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.4.1.2
47
+ type: :development
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: rack-test
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - "="
56
+ - !ruby/object:Gem::Version
57
+ version: 0.5.6
58
+ type: :development
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: rr
62
+ prerelease: false
63
+ requirement: &id005 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - "="
67
+ - !ruby/object:Gem::Version
68
+ version: 1.0.2
69
+ type: :development
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: rspec
73
+ prerelease: false
74
+ requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - "="
78
+ - !ruby/object:Gem::Version
79
+ version: 2.5.0
80
+ type: :development
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: ruby-debug19
84
+ prerelease: false
85
+ requirement: &id007 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - "="
89
+ - !ruby/object:Gem::Version
90
+ version: 0.11.6
91
+ type: :development
92
+ version_requirements: *id007
93
+ description: Simple Rack wrapper around HoptoadNotifier.notify
94
+ email:
95
+ - btakita@truecar.com
96
+ executables: []
97
+
98
+ extensions: []
99
+
100
+ extra_rdoc_files: []
101
+
102
+ files:
103
+ - .gitignore
104
+ - .rvmrc
105
+ - Gemfile
106
+ - Gemfile.lock
107
+ - README
108
+ - Rakefile
109
+ - lib/rack-hoptoad-notifier.rb
110
+ - lib/rack-hoptoad-notifier/version.rb
111
+ - rack-hoptoad-notifier.gemspec
112
+ - spec/rack-hoptoad-notifier_spec.rb
113
+ - spec/spec_helper.rb
114
+ has_rdoc: true
115
+ homepage: https://github.com/TrueCar/rack-hoptoad-notifier
116
+ licenses: []
117
+
118
+ post_install_message:
119
+ rdoc_options: []
120
+
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: "0"
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: 1.3.6
135
+ requirements: []
136
+
137
+ rubyforge_project:
138
+ rubygems_version: 1.6.2
139
+ signing_key:
140
+ specification_version: 3
141
+ summary: Simple Rack wrapper around HoptoadNotifier.notify
142
+ test_files: []
143
+