yogi_berra 0.0.1 → 0.0.2
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.
- data/Gemfile +2 -0
- data/Gemfile.lock +14 -0
- data/README.md +5 -0
- data/Rakefile +1 -1
- data/lib/facets.rb +280 -0
- data/lib/yogi_berra/catcher.rb +25 -10
- data/lib/yogi_berra/data.rb +2 -0
- data/lib/yogi_berra/exception_middleware.rb +3 -1
- data/lib/yogi_berra/logger.rb +12 -0
- data/lib/yogi_berra/rails.rb +1 -2
- data/lib/yogi_berra/version.rb +1 -1
- data/lib/yogi_berra.rb +9 -8
- data/spec/spec_helper.rb +8 -19
- data/spec/yogi_berra_spec.rb +44 -46
- metadata +36 -2
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -12,12 +12,26 @@ GEM
|
|
12
12
|
bson (1.8.3)
|
13
13
|
bson_ext (1.8.3)
|
14
14
|
bson (~> 1.8.3)
|
15
|
+
builder (3.2.1)
|
16
|
+
diff-lcs (1.2.4)
|
15
17
|
mongo (1.8.3)
|
16
18
|
bson (~> 1.8.3)
|
19
|
+
rake (10.0.4)
|
20
|
+
rspec (2.13.0)
|
21
|
+
rspec-core (~> 2.13.0)
|
22
|
+
rspec-expectations (~> 2.13.0)
|
23
|
+
rspec-mocks (~> 2.13.0)
|
24
|
+
rspec-core (2.13.1)
|
25
|
+
rspec-expectations (2.13.0)
|
26
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
27
|
+
rspec-mocks (2.13.1)
|
17
28
|
|
18
29
|
PLATFORMS
|
19
30
|
ruby
|
20
31
|
|
21
32
|
DEPENDENCIES
|
33
|
+
builder (~> 3.2.1)
|
22
34
|
mongo (~> 1.8.3)
|
35
|
+
rake (~> 10.0.4)
|
36
|
+
rspec (~> 2.13.0)
|
23
37
|
yogi_berra!
|
data/README.md
CHANGED
@@ -33,6 +33,11 @@ Create a yogi.yml file in rails root config/ folder. Here is a sample:
|
|
33
33
|
database: yogi_berra
|
34
34
|
host: localhost
|
35
35
|
port: 27017
|
36
|
+
|
37
|
+
View
|
38
|
+
----
|
39
|
+
To view the exceptions you check them in the database or install this rails app.
|
40
|
+
https://github.com/earlonrails/yogi_berra_scoreboard.git
|
36
41
|
|
37
42
|
Thanks
|
38
43
|
------
|
data/Rakefile
CHANGED
data/lib/facets.rb
ADDED
@@ -0,0 +1,280 @@
|
|
1
|
+
# Taken from https://github.com/rubyworks/facets/blob/master/lib/core/facets/module/mattr.rb
|
2
|
+
module Facets
|
3
|
+
|
4
|
+
# Creates a class-variable attribute that can
|
5
|
+
# be accessed both on an instance and class level.
|
6
|
+
#
|
7
|
+
# class CARExample
|
8
|
+
# @@a = 10
|
9
|
+
# cattr :a
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# CARExample.a #=> 10
|
13
|
+
# CARExample.new.a #=> 10
|
14
|
+
#
|
15
|
+
# NOTE: This method is not a common core extension and is not
|
16
|
+
# loaded automatically when using <code>require 'facets'</code>.
|
17
|
+
#
|
18
|
+
# CREDIT: David Heinemeier Hansson
|
19
|
+
#
|
20
|
+
# @uncommon
|
21
|
+
# require 'facets/module/cattr'
|
22
|
+
#
|
23
|
+
def cattr(*syms)
|
24
|
+
writers, readers = syms.flatten.partition{ |a| a.to_s =~ /=$/ }
|
25
|
+
writers = writers.map{ |e| e.to_s.chomp('=').to_sym }
|
26
|
+
##readers.concat( writers ) # writers also get readers
|
27
|
+
|
28
|
+
cattr_reader(*readers)
|
29
|
+
cattr_writer(*writers)
|
30
|
+
|
31
|
+
return readers + writers
|
32
|
+
end
|
33
|
+
|
34
|
+
# Creates a class-variable attr_reader that can
|
35
|
+
# be accessed both on an instance and class level.
|
36
|
+
#
|
37
|
+
# class CARExample
|
38
|
+
# @@a = 10
|
39
|
+
# cattr_reader :a
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# CARExample.a #=> 10
|
43
|
+
# CARExample.new.a #=> 10
|
44
|
+
#
|
45
|
+
# NOTE: This method is not a common core extension and is not
|
46
|
+
# loaded automatically when using <code>require 'facets'</code>.
|
47
|
+
#
|
48
|
+
# CREDIT: David Heinemeier Hansson
|
49
|
+
#
|
50
|
+
# @uncommon
|
51
|
+
# require 'facets/module/cattr'
|
52
|
+
#
|
53
|
+
def cattr_reader(*syms)
|
54
|
+
syms.flatten.each do |sym|
|
55
|
+
module_eval(<<-EOS, __FILE__, __LINE__)
|
56
|
+
unless defined? @@#{sym}
|
57
|
+
@@#{sym} = nil
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.#{sym}
|
61
|
+
@@#{sym}
|
62
|
+
end
|
63
|
+
|
64
|
+
def #{sym}
|
65
|
+
@@#{sym}
|
66
|
+
end
|
67
|
+
EOS
|
68
|
+
end
|
69
|
+
return syms
|
70
|
+
end
|
71
|
+
|
72
|
+
# Creates a class-variable attr_writer that can
|
73
|
+
# be accessed both on an instance and class level.
|
74
|
+
#
|
75
|
+
# class CAWExample
|
76
|
+
# cattr_writer :a
|
77
|
+
# def self.a
|
78
|
+
# @@a
|
79
|
+
# end
|
80
|
+
# end
|
81
|
+
#
|
82
|
+
# CAWExample.a = 10
|
83
|
+
# CAWExample.a #=> 10
|
84
|
+
# CAWExample.new.a = 29
|
85
|
+
# CAWExample.a #=> 29
|
86
|
+
#
|
87
|
+
# NOTE: This method is not a common core extension and is not
|
88
|
+
# loaded automatically when using <code>require 'facets'</code>.
|
89
|
+
#
|
90
|
+
# CREDIT: David Heinemeier Hansson
|
91
|
+
#
|
92
|
+
# @uncommon
|
93
|
+
# require 'facets/module/cattr'
|
94
|
+
#
|
95
|
+
def cattr_writer(*syms)
|
96
|
+
syms.flatten.each do |sym|
|
97
|
+
module_eval(<<-EOS, __FILE__, __LINE__)
|
98
|
+
unless defined? @@#{sym}
|
99
|
+
@@#{sym} = nil
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.#{sym}=(obj)
|
103
|
+
@@#{sym} = obj
|
104
|
+
end
|
105
|
+
|
106
|
+
def #{sym}=(obj)
|
107
|
+
@@#{sym}=(obj)
|
108
|
+
end
|
109
|
+
EOS
|
110
|
+
end
|
111
|
+
return syms
|
112
|
+
end
|
113
|
+
|
114
|
+
# Creates a class-variable attr_accessor that can
|
115
|
+
# be accessed both on an instance and class level.
|
116
|
+
#
|
117
|
+
# class CAAExample
|
118
|
+
# cattr_accessor :a
|
119
|
+
# end
|
120
|
+
#
|
121
|
+
# CAAExample.a = 10
|
122
|
+
# CAAExample.a #=> 10
|
123
|
+
# mc = CAAExample.new
|
124
|
+
# mc.a #=> 10
|
125
|
+
#
|
126
|
+
# NOTE: This method is not a common core extension and is not
|
127
|
+
# loaded automatically when using <code>require 'facets'</code>.
|
128
|
+
#
|
129
|
+
# CREDIT: David Heinemeier Hansson
|
130
|
+
#
|
131
|
+
# @uncommon
|
132
|
+
# require 'facets/module/cattr'
|
133
|
+
#
|
134
|
+
def cattr_accessor(*syms)
|
135
|
+
cattr_reader(*syms) + cattr_writer(*syms)
|
136
|
+
end
|
137
|
+
|
138
|
+
# Creates a class-variable attribute that can
|
139
|
+
# be accessed both on an instance and class level.
|
140
|
+
#
|
141
|
+
# c = Class.new do
|
142
|
+
# mattr :a
|
143
|
+
# def initialize
|
144
|
+
# @@a = 10
|
145
|
+
# end
|
146
|
+
# end
|
147
|
+
#
|
148
|
+
# c.new.a #=> 10
|
149
|
+
# c.a #=> 10
|
150
|
+
#
|
151
|
+
# NOTE: The #mattr methods may not be as useful for modules as the #cattr
|
152
|
+
# methods are for classes, becuase class-level methods are not "inherited"
|
153
|
+
# across the metaclass for included modules.
|
154
|
+
#
|
155
|
+
# NOTE: This methiod is not a common core extension and is not
|
156
|
+
# loaded automatically when using <code>require 'facets'</code>.
|
157
|
+
#
|
158
|
+
# CREDIT: David Heinemeier Hansson
|
159
|
+
#
|
160
|
+
# @uncommon
|
161
|
+
# require 'facets/module/mattr'
|
162
|
+
#
|
163
|
+
def mattr(*syms)
|
164
|
+
writers, readers = syms.flatten.partition{ |a| a.to_s =~ /=$/ }
|
165
|
+
writers = writers.collect{ |e| e.to_s.chomp('=').to_sym }
|
166
|
+
##readers.concat( writers ) # writers also get readers
|
167
|
+
|
168
|
+
mattr_writer( *writers )
|
169
|
+
mattr_reader( *readers )
|
170
|
+
|
171
|
+
return readers + writers
|
172
|
+
end
|
173
|
+
|
174
|
+
# Creates a class-variable attr_reader that can
|
175
|
+
# be accessed both on an instance and class level.
|
176
|
+
#
|
177
|
+
# c = Class.new do
|
178
|
+
# @@a = 10
|
179
|
+
# mattr_reader :a
|
180
|
+
# end
|
181
|
+
#
|
182
|
+
# c.a #=> 10
|
183
|
+
# c.new.a #=> 10
|
184
|
+
#
|
185
|
+
# NOTE: This methiod is not a common core extension and is not
|
186
|
+
# loaded automatically when using <code>require 'facets'</code>.
|
187
|
+
#
|
188
|
+
# CREDIT: David Heinemeier Hansson
|
189
|
+
#
|
190
|
+
# @uncommon
|
191
|
+
# require 'facets/module/mattr'
|
192
|
+
#
|
193
|
+
def mattr_reader( *syms )
|
194
|
+
syms.flatten.each do |sym|
|
195
|
+
module_eval(<<-EOS, __FILE__, __LINE__)
|
196
|
+
unless defined? @@#{sym}
|
197
|
+
@@#{sym} = nil
|
198
|
+
end
|
199
|
+
|
200
|
+
def self.#{sym}
|
201
|
+
@@#{sym}
|
202
|
+
end
|
203
|
+
|
204
|
+
def #{sym}
|
205
|
+
@@#{sym}
|
206
|
+
end
|
207
|
+
EOS
|
208
|
+
end
|
209
|
+
return syms
|
210
|
+
end
|
211
|
+
|
212
|
+
# Creates a class-variable attr_writer that can
|
213
|
+
# be accessed both on an instance and class level.
|
214
|
+
#
|
215
|
+
# c = Class.new do
|
216
|
+
# mattr_writer :a
|
217
|
+
# def self.a
|
218
|
+
# @@a
|
219
|
+
# end
|
220
|
+
# end
|
221
|
+
#
|
222
|
+
# c.a = 10
|
223
|
+
# c.a #=> 10
|
224
|
+
#
|
225
|
+
# c.new.a = 29
|
226
|
+
# c.a #=> 29
|
227
|
+
#
|
228
|
+
# NOTE: This methiod is not a common core extension and is not
|
229
|
+
# loaded automatically when using <code>require 'facets'</code>.
|
230
|
+
#
|
231
|
+
# CREDIT: David Heinemeier Hansson
|
232
|
+
#
|
233
|
+
# @uncommon
|
234
|
+
# require 'facets/module/mattr'
|
235
|
+
#
|
236
|
+
def mattr_writer(*syms)
|
237
|
+
syms.flatten.each do |sym|
|
238
|
+
module_eval(<<-EOS, __FILE__, __LINE__)
|
239
|
+
unless defined? @@#{sym}
|
240
|
+
@@#{sym} = nil
|
241
|
+
end
|
242
|
+
|
243
|
+
def self.#{sym}=(obj)
|
244
|
+
@@#{sym} = obj
|
245
|
+
end
|
246
|
+
|
247
|
+
def #{sym}=(obj)
|
248
|
+
@@#{sym}=(obj)
|
249
|
+
end
|
250
|
+
EOS
|
251
|
+
end
|
252
|
+
return syms
|
253
|
+
end
|
254
|
+
|
255
|
+
# Creates a class-variable attr_accessor that can
|
256
|
+
# be accessed both on an instance and class level.
|
257
|
+
#
|
258
|
+
# c = Class.new do
|
259
|
+
# mattr_accessor :a
|
260
|
+
# end
|
261
|
+
#
|
262
|
+
# c.a = 10
|
263
|
+
# c.a #=> 10
|
264
|
+
#
|
265
|
+
# x = c.new
|
266
|
+
# x.a #=> 10
|
267
|
+
#
|
268
|
+
# NOTE: This methiod is not a common core extension and is not
|
269
|
+
# loaded automatically when using <code>require 'facets'</code>.
|
270
|
+
#
|
271
|
+
# CREDIT: David Heinemeier Hansson
|
272
|
+
#
|
273
|
+
# @uncommon
|
274
|
+
# require 'facets/module/mattr'
|
275
|
+
#
|
276
|
+
def mattr_accessor(*syms)
|
277
|
+
mattr_reader(*syms) + mattr_writer(*syms)
|
278
|
+
end
|
279
|
+
|
280
|
+
end
|
data/lib/yogi_berra/catcher.rb
CHANGED
@@ -1,18 +1,31 @@
|
|
1
1
|
require 'mongo'
|
2
|
+
require 'facets'
|
2
3
|
|
3
4
|
module YogiBerra
|
4
5
|
class Catcher
|
6
|
+
extend Facets
|
5
7
|
cattr_accessor :settings, :mongo_client, :connection
|
6
8
|
|
7
9
|
class << self
|
8
|
-
def load_db_settings
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
def load_db_settings(config_file = nil)
|
11
|
+
if config_file
|
12
|
+
database_config = config_file
|
13
|
+
elsif defined?(Rails)
|
14
|
+
database_config = "#{Rails.root}/config/yogi.yml"
|
15
|
+
else
|
16
|
+
YogiBerra::Logger.log("No config file specified!", :error)
|
17
|
+
end
|
18
|
+
if database_config
|
19
|
+
begin
|
20
|
+
File.open(database_config, 'r') do |f|
|
21
|
+
yaml_file = YAML.load(f)
|
22
|
+
environment = ENV["RAILS_ENV"] ? ENV["RAILS_ENV"] : ENV["YOGI_ENV"]
|
23
|
+
YogiBerra::Logger.log("I get here! #{environment.inspect}", :info)
|
24
|
+
@@settings = yaml_file["#{environment}"] if yaml_file
|
25
|
+
end
|
26
|
+
rescue
|
27
|
+
YogiBerra::Logger.log("No such file: #{database_config}", :error)
|
13
28
|
end
|
14
|
-
rescue
|
15
|
-
$stderr.puts "[YogiBerra Error] No such file: #{Rails.root}/config/yogi.yml"
|
16
29
|
end
|
17
30
|
end
|
18
31
|
|
@@ -21,12 +34,14 @@ module YogiBerra
|
|
21
34
|
# by not waiting for a response from mongodb
|
22
35
|
@@mongo_client = Mongo::MongoClient.new(host, port, :w => 0)
|
23
36
|
rescue
|
24
|
-
|
37
|
+
YogiBerra::Logger.log("Couldn't connect to the mongo database on host: #{host} port: #{port}.", :error)
|
25
38
|
nil
|
26
39
|
end
|
27
40
|
|
28
41
|
def quick_connection
|
42
|
+
YogiBerra::Logger.log("settings::::::::::: #{settings.inspect}", :info)
|
29
43
|
settings = @@settings || load_db_settings
|
44
|
+
|
30
45
|
if settings
|
31
46
|
host = settings["host"]
|
32
47
|
port = settings["port"]
|
@@ -34,10 +49,10 @@ module YogiBerra
|
|
34
49
|
if client
|
35
50
|
@@connection = client[settings["database"]]
|
36
51
|
else
|
37
|
-
|
52
|
+
YogiBerra::Logger.log("Couldn't connect to the mongo database on host: #{host} port: #{port}.", :error)
|
38
53
|
end
|
39
54
|
else
|
40
|
-
|
55
|
+
YogiBerra::Logger.log("Couldn't load the yogi.yml file.", :error)
|
41
56
|
end
|
42
57
|
end
|
43
58
|
end
|
data/lib/yogi_berra/data.rb
CHANGED
@@ -13,8 +13,10 @@ module YogiBerra
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.parse_exception(notice)
|
16
|
+
puts YogiBerra::Catcher.settings["project"].inspect
|
16
17
|
data_hash = {
|
17
18
|
:error_class => notice.error_class,
|
19
|
+
:project => YogiBerra::Catcher.settings["project"],
|
18
20
|
:error_message => notice.error_message
|
19
21
|
}
|
20
22
|
if notice.backtrace.lines.any?
|
@@ -7,10 +7,12 @@ module YogiBerra
|
|
7
7
|
|
8
8
|
def call(env)
|
9
9
|
begin
|
10
|
+
path_parameters = env['action_controller.request.path_parameters'] || {}
|
11
|
+
query_hash = env['rack.request.query_hash'] || {}
|
10
12
|
response = dup._call(env)
|
11
13
|
environment = {
|
12
14
|
:session => env['rack.session'],
|
13
|
-
:params =>
|
15
|
+
:params => path_parameters.merge(query_hash),
|
14
16
|
:user_agent => env['HTTP_USER_AGENT'],
|
15
17
|
:server_name => env['SERVER_NAME'],
|
16
18
|
:server_port => env['SERVER_PORT'],
|
data/lib/yogi_berra/rails.rb
CHANGED
@@ -18,8 +18,7 @@ module YogiBerra
|
|
18
18
|
end
|
19
19
|
|
20
20
|
if defined?(::Rails.configuration) && ::Rails.configuration.respond_to?(:middleware)
|
21
|
-
::Rails.configuration.middleware.insert_after
|
22
|
-
YogiBerra::ExceptionMiddleware
|
21
|
+
::Rails.configuration.middleware.insert_after('ActionController::Failsafe', YogiBerra::ExceptionMiddleware)
|
23
22
|
# ::Rails.configuration.middleware.insert_after 'Rack::Lock',
|
24
23
|
# YogiBerra::UserInformer
|
25
24
|
end
|
data/lib/yogi_berra/version.rb
CHANGED
data/lib/yogi_berra.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require 'yogi_berra/catcher'
|
2
|
+
require 'yogi_berra/backtrace'
|
3
|
+
require 'yogi_berra/notice'
|
4
|
+
require 'yogi_berra/exception_middleware'
|
5
|
+
require 'yogi_berra/data'
|
6
|
+
require 'yogi_berra/logger'
|
6
7
|
|
7
8
|
if defined?(::Rails.version) && ::Rails.version.to_f >= 3.0
|
8
|
-
require
|
9
|
+
require 'yogi_berra/engine'
|
9
10
|
else
|
10
|
-
require
|
11
|
+
require 'yogi_berra/rails'
|
11
12
|
end
|
12
13
|
|
13
14
|
module YogiBerra
|
@@ -22,7 +23,7 @@ module YogiBerra
|
|
22
23
|
if database
|
23
24
|
YogiBerra::Data.store!(notice, environment, database)
|
24
25
|
else
|
25
|
-
|
26
|
+
YogiBerra::Logger.log("No database connection!", :error)
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,28 +1,17 @@
|
|
1
1
|
# Configure Rails Envinronment
|
2
2
|
ENV["RAILS_ENV"] = "test"
|
3
3
|
|
4
|
-
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
-
|
6
|
-
ActionMailer::Base.delivery_method = :test
|
7
|
-
ActionMailer::Base.perform_deliveries = true
|
8
|
-
ActionMailer::Base.default_url_options[:host] = "test.com"
|
9
|
-
|
10
|
-
Rails.backtrace_cleaner.remove_silencers!
|
11
|
-
|
12
|
-
# Run any available migration
|
13
|
-
ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
|
14
|
-
|
15
4
|
# Load support files
|
5
|
+
$:.unshift("../lib/yogi_berra/*")
|
6
|
+
require 'yogi_berra'
|
16
7
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
17
8
|
|
18
9
|
# Helper methods
|
19
|
-
class ActiveSupport::TestCase
|
20
|
-
setup { YogiBerra::Data.delete_all }
|
21
10
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
11
|
+
# Creates RunTimeError
|
12
|
+
def build_exception
|
13
|
+
raise
|
14
|
+
rescue => caught_exception
|
15
|
+
caught_exception
|
28
16
|
end
|
17
|
+
|
data/spec/yogi_berra_spec.rb
CHANGED
@@ -2,51 +2,49 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe YogiBerra do
|
4
4
|
|
5
|
-
it "should call the upstream app with the environment"
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
#end
|
5
|
+
it "should call the upstream app with the environment" do
|
6
|
+
environment = { 'key' => 'value' }
|
7
|
+
app = lambda { |env| ['response', {}, env] }
|
8
|
+
stack = YogiBerra::ExceptionMiddleware.new(app)
|
9
|
+
|
10
|
+
response = stack.call(environment)
|
11
|
+
|
12
|
+
response[0].should == 'response'
|
13
|
+
response[1].should == {}
|
14
|
+
response[2].instance_variable_get("@response").should == { 'key' => 'value' }
|
15
|
+
end
|
16
|
+
|
17
|
+
it "deliver an exception raised while calling an upstream app" do
|
18
|
+
exception = build_exception
|
19
|
+
environment = { 'key' => 'value' }
|
20
|
+
app = lambda do |env|
|
21
|
+
raise exception
|
22
|
+
end
|
23
|
+
|
24
|
+
begin
|
25
|
+
stack = YogiBerra::ExceptionMiddleware.new(app)
|
26
|
+
stack.call(environment)
|
27
|
+
rescue Exception => raised
|
28
|
+
raised.should == exception
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should deliver an exception in rack.exception" do
|
33
|
+
exception = build_exception
|
34
|
+
environment = { 'key' => 'value' }
|
35
|
+
|
36
|
+
response = [200, {}, ['okay']]
|
37
|
+
app = lambda do |env|
|
38
|
+
env['rack.exception'] = exception
|
39
|
+
response
|
40
|
+
end
|
41
|
+
stack = YogiBerra::ExceptionMiddleware.new(app)
|
42
|
+
|
43
|
+
actual_response = stack.call(environment)
|
44
|
+
|
45
|
+
actual_response[0].should == 200
|
46
|
+
actual_response[1].should == {}
|
47
|
+
actual_response[2].instance_variable_get("@response").should == ["okay"]
|
48
|
+
end
|
51
49
|
|
52
50
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yogi_berra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,40 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - '='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 10.0.4
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 10.0.4
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - '='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.13.0
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - '='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.13.0
|
14
46
|
- !ruby/object:Gem::Dependency
|
15
47
|
name: bson
|
16
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,12 +98,14 @@ executables: []
|
|
66
98
|
extensions: []
|
67
99
|
extra_rdoc_files: []
|
68
100
|
files:
|
101
|
+
- lib/facets.rb
|
69
102
|
- lib/yogi_berra/action_controller_catcher.rb
|
70
103
|
- lib/yogi_berra/backtrace.rb
|
71
104
|
- lib/yogi_berra/catcher.rb
|
72
105
|
- lib/yogi_berra/data.rb
|
73
106
|
- lib/yogi_berra/engine.rb
|
74
107
|
- lib/yogi_berra/exception_middleware.rb
|
108
|
+
- lib/yogi_berra/logger.rb
|
75
109
|
- lib/yogi_berra/notice.rb
|
76
110
|
- lib/yogi_berra/rails.rb
|
77
111
|
- lib/yogi_berra/version.rb
|