quietbacktrace 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/History.txt +5 -0
  2. data/Rakefile +1 -1
  3. data/lib/quietbacktrace.rb +26 -15
  4. metadata +1 -1
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.0.5 / 2007-12-03
2
+
3
+ * Improved the API with James Golick's code
4
+ * Dan Croak renamed the methods silences_backtrace and filters_backtrace
5
+
1
6
  == 0.0.4 / 2007-12-03
2
7
 
3
8
  * Added an init file so it can be added to Rails with gemsonrails
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rubygems'
4
4
  require 'hoe'
5
5
  require './lib/quietbacktrace.rb'
6
6
 
7
- Hoe.new('quietbacktrace', '0.0.4') do |p|
7
+ Hoe.new('quietbacktrace', '0.0.5') do |p|
8
8
  p.rubyforge_name = 'quietbacktrace'
9
9
  p.author = 'Dan Croak'
10
10
  p.email = 'dcroak@thoughtbot.com'
@@ -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 = { :test_unit => lambda { |line| (line.include?("ruby") && line.include?("/test/unit")) },
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.4
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: