quietbacktrace 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/Rakefile +1 -1
- data/lib/quietbacktrace.rb +26 -15
- metadata +1 -1
data/History.txt
CHANGED
data/Rakefile
CHANGED
data/lib/quietbacktrace.rb
CHANGED
@@ -84,16 +84,8 @@ module QuietBacktrace # :nodoc: all
|
|
84
84
|
klass.class_eval { alias_method_chain :filter_backtrace, :quieting }
|
85
85
|
end
|
86
86
|
|
87
|
-
mattr_accessor :silencers
|
88
|
-
self.silencers = {
|
89
|
-
:gem_root => lambda { |line| line =~ /ruby\/gems/i },
|
90
|
-
:e1 => lambda { |line| line == "-e:1" },
|
91
|
-
:rails_vendor => lambda { |line| (line.include?("vendor/plugins") || line.include?("vendor/gems") || line.include?("vendor/rails")) }
|
92
|
-
}
|
93
|
-
|
94
|
-
mattr_accessor :filters
|
95
|
-
self.filters = { :method_name => lambda { |line| line.slice!((line =~ /:in /)..line.length) if (line =~ /:in /) },
|
96
|
-
:rails_root => lambda { |line| line.sub!("#{RAILS_ROOT}/", '') if (defined?(RAILS_ROOT) && line.include?(RAILS_ROOT)) }}
|
87
|
+
mattr_accessor :silencers, :filters
|
88
|
+
self.silencers, self.filters = {}, {}
|
97
89
|
|
98
90
|
def filter_backtrace_with_quieting(backtrace)
|
99
91
|
filter_backtrace_without_quieting(backtrace)
|
@@ -120,16 +112,35 @@ module QuietBacktrace # :nodoc: all
|
|
120
112
|
module TestCase
|
121
113
|
def self.included(klass)
|
122
114
|
klass.class_eval do
|
123
|
-
cattr_accessor :quiet_backtrace
|
115
|
+
cattr_accessor :quiet_backtrace, :backtrace_silencers, :backtrace_filters
|
116
|
+
self.backtrace_filters, self.backtrace_silencers = [], []
|
117
|
+
|
118
|
+
extend ClassMethods
|
119
|
+
silences_backtrace(:test_unit) { |line| (line.include?("ruby") && line.include?("/test/unit")) }
|
120
|
+
silences_backtrace(:gem_root) { |line| line =~ /ruby\/gems/i }
|
121
|
+
silences_backtrace(:e1) { |line| line == "-e:1" }
|
122
|
+
silences_backtrace(:rails_vendor) { |line| (line.include?("vendor/plugins") || line.include?("vendor/gems") || line.include?("vendor/rails")) }
|
123
|
+
|
124
|
+
filters_backtrace(:method_name) { |line| line.slice!((line =~ /:in /)..line.length) if (line =~ /:in /) }
|
125
|
+
filters_backtrace(:rails_root) { |line| line.sub!("#{RAILS_ROOT}/", '') if (defined?(RAILS_ROOT) && line.include?(RAILS_ROOT)) }
|
126
|
+
|
124
127
|
self.quiet_backtrace = true
|
125
|
-
|
126
|
-
cattr_accessor :backtrace_silencers
|
127
128
|
self.backtrace_silencers = [:test_unit, :gem_root, :e1]
|
128
|
-
|
129
|
-
cattr_accessor :backtrace_filters
|
130
129
|
self.backtrace_filters = [:method_name]
|
131
130
|
end
|
132
131
|
end
|
132
|
+
|
133
|
+
module ClassMethods
|
134
|
+
def silences_backtrace(symbol, &block)
|
135
|
+
QuietBacktrace::BacktraceFilter.silencers[symbol] = block
|
136
|
+
backtrace_silencers << symbol
|
137
|
+
end
|
138
|
+
|
139
|
+
def filters_backtrace(symbol, &block)
|
140
|
+
QuietBacktrace::BacktraceFilter.filters[symbol] = block
|
141
|
+
backtrace_filters << symbol
|
142
|
+
end
|
143
|
+
end
|
133
144
|
end
|
134
145
|
end
|
135
146
|
|
metadata
CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: quietbacktrace
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
6
|
+
version: 0.0.5
|
7
7
|
date: 2007-12-03 00:00:00 -05:00
|
8
8
|
summary: quiet_backtrace suppresses the noise in your Test::Unit backtrace. It also provides hooks for you to add additional filters.
|
9
9
|
require_paths:
|