lrd_rack_bug 0.3.1.1 → 0.3.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,13 +11,22 @@ module Rack
11
11
  end
12
12
 
13
13
  def filtered_backtrace
14
- @filtered_backtrace ||= @backtrace.map{|l| l.to_s.strip }.select do |line|
15
- root_for_backtrace_filtering.nil? ||
16
- (line.index(root_for_backtrace_filtering) == 0) && !(line.index(root_for_backtrace_filtering("vendor")) == 0)
17
- end
14
+ @filtered_backtrace ||= @backtrace.grep(FilteredBacktrace.backtrace_regexp)
15
+ end
16
+
17
+ def self.backtrace_regexp
18
+ @backtrace_regexp ||=
19
+ begin
20
+ if true or (app_root = root_for_backtrace_filtering).nil?
21
+ /.*/
22
+ else
23
+ excludes = %w{vendor}
24
+ %r{^#{app_root}(?:#{::File::Separator}(?!#{excludes.join("|")}).+)$}
25
+ end
26
+ end
18
27
  end
19
28
 
20
- def root_for_backtrace_filtering(sub_path = nil)
29
+ def self.root_for_backtrace_filtering(sub_path = nil)
21
30
  if defined?(Rails) && Rails.respond_to?(:root)
22
31
  sub_path ? Rails.root.join(sub_path) : Rails.root
23
32
  else
@@ -13,16 +13,21 @@ module Rack
13
13
  PanelApp.new
14
14
  end
15
15
 
16
- def self.record(sql, backtrace = [], &block)
17
- return block.call unless Rack::Bug.enabled?
16
+ def self.record(sql, backtrace = [])
17
+ return yield unless Rack::Bug.enabled?
18
18
 
19
19
  start_time = Time.now
20
- result = block.call
21
- queries << QueryResult.new(sql, Time.now - start_time, backtrace)
20
+
21
+ result = nil
22
+ begin
23
+ result = yield
24
+ ensure
25
+ queries << QueryResult.new(sql, Time.now - start_time, backtrace, result)
26
+ end
22
27
 
23
28
  return result
24
29
  end
25
-
30
+
26
31
  def self.record_event(sql, duration, backtrace = [])
27
32
  return unless Rack::Bug.enabled?
28
33
  queries << QueryResult.new(sql, duration, backtrace)
@@ -37,8 +42,7 @@ module Rack
37
42
  end
38
43
 
39
44
  def self.total_time
40
- (queries.inject(0) do |memo, query|
41
- Rails.logger.debug{ "QTime: #{query.time}" }
45
+ (queries.inject(0) do |memo, query|
42
46
  memo + query.time
43
47
  end) * 1_000
44
48
  end
@@ -8,10 +8,12 @@ module Rack
8
8
  attr_reader :sql
9
9
  attr_reader :time
10
10
 
11
- def initialize(sql, time, backtrace = [])
11
+ def initialize(sql, time, backtrace = [], result=nil)
12
+ Rails.logger.debug{ "QueryResult: #{sql}" }
12
13
  @sql = sql
13
14
  @time = time
14
15
  @backtrace = backtrace
16
+ @result = result
15
17
  @results = nil
16
18
  end
17
19
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{lrd_rack_bug}
5
- s.version = "0.3.1.1"
5
+ s.version = "0.3.1.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Bryan Helmkamp", "Evan Dorn", "Judson Lester"]
@@ -27,11 +27,11 @@ Gem::Specification.new do |s|
27
27
  s.homepage = %q{http://github.com/lrdesign/lrd_rack_bug}
28
28
  s.require_paths = ["lib"]
29
29
  s.rubygems_version = %q{1.3.7}
30
- s.summary = %q{Debugging toolbar for Rack applications implemented as
31
- middleware. Rails 3 compatible version maintained by Logical Reality
30
+ s.summary = %q{Debugging toolbar for Rack applications implemented as
31
+ middleware. Rails 3 compatible version maintained by Logical Reality
32
32
  Design. }
33
- s.description = %q{Debugging toolbar for Rack applications implemented as
34
- middleware. Rails 3 compatible version maintained by Logical Reality
33
+ s.description = %q{Debugging toolbar for Rack applications implemented as
34
+ middleware. Rails 3 compatible version maintained by Logical Reality
35
35
  Design. }
36
36
  s.add_dependency("uuid", "~> 2.3.1")
37
37
  #s.test_files = Dir.glob("spec/**/*") gem test assumes Test::Unit
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lrd_rack_bug
3
3
  version: !ruby/object:Gem::Version
4
- hash: 81
4
+ hash: 87
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
9
  - 1
10
- - 1
11
- version: 0.3.1.1
10
+ - 2
11
+ version: 0.3.1.2
12
12
  platform: ruby
13
13
  authors:
14
14
  - Bryan Helmkamp
@@ -37,7 +37,7 @@ dependencies:
37
37
  version: 2.3.1
38
38
  type: :runtime
39
39
  version_requirements: *id001
40
- description: "Debugging toolbar for Rack applications implemented as \n middleware. Rails 3 compatible version maintained by Logical Reality \n Design. "
40
+ description: "Debugging toolbar for Rack applications implemented as\n middleware. Rails 3 compatible version maintained by Logical Reality\n Design. "
41
41
  email: evan@lrdesign.com judson@lrdesign.com
42
42
  executables: []
43
43
 
@@ -184,6 +184,6 @@ rubyforge_project:
184
184
  rubygems_version: 1.4.2
185
185
  signing_key:
186
186
  specification_version: 3
187
- summary: Debugging toolbar for Rack applications implemented as middleware. Rails 3 compatible version maintained by Logical Reality Design.
187
+ summary: Debugging toolbar for Rack applications implemented as middleware. Rails 3 compatible version maintained by Logical Reality Design.
188
188
  test_files: []
189
189