@@ -4,27 +4,39 @@ class BacktraceCleaner < ActiveSupport::BacktraceCleaner
4
4
5
RAILS_GEMS = %w( actionpack activerecord actionmailer activesupport activeresource rails )
5
RAILS_GEMS = %w( actionpack activerecord actionmailer activesupport activeresource rails )
6
6
7
- VENDOR_DIRS = %w( vendor/gems vendor/ rails )
7
+ VENDOR_DIRS = %w( vendor/rails )
8
SERVER_DIRS = %w( lib/mongrel bin/mongrel
8
SERVER_DIRS = %w( lib/mongrel bin/mongrel
9
lib/passenger bin/passenger-spawn-server
9
lib/passenger bin/passenger-spawn-server
10
lib/rack )
10
lib/rack )
11
RAILS_NOISE = %w( script/server )
11
RAILS_NOISE = %w( script/server )
12
RUBY_NOISE = %w( rubygems/custom_require benchmark.rb )
12
RUBY_NOISE = %w( rubygems/custom_require benchmark.rb )
13
13
14
- GEMS_DIR = Gem . default_dir
15
-
16
ALL_NOISE = VENDOR_DIRS + SERVER_DIRS + RAILS_NOISE + RUBY_NOISE
14
ALL_NOISE = VENDOR_DIRS + SERVER_DIRS + RAILS_NOISE + RUBY_NOISE
17
15
18
def initialize
16
def initialize
19
super
17
super
20
add_filter { |line | line . sub ( "#{ RAILS_ROOT } /" , '' ) }
18
add_filter { |line | line . sub ( "#{ RAILS_ROOT } /" , '' ) }
21
add_filter { |line | line . sub ( ERB_METHOD_SIG , '' ) }
19
add_filter { |line | line . sub ( ERB_METHOD_SIG , '' ) }
22
add_filter { |line | line . sub ( './' , '/' ) } # for tests
20
add_filter { |line | line . sub ( './' , '/' ) } # for tests
23
- add_filter { |line | line . sub ( /(#{ GEMS_DIR } )\/ gems\/ ([a-z]+)-([0-9.]+)\/ (.*)/ , '\2 (\3) \4' ) } # http://gist.github.com/30430
21
+
22
+ add_gem_filters
23
+
24
add_silencer { |line | ALL_NOISE . any? { |dir | line . include? ( dir ) } }
24
add_silencer { |line | ALL_NOISE . any? { |dir | line . include? ( dir ) } }
25
add_silencer { |line | RAILS_GEMS . any? { |gem | line =~ /^#{ gem } / } }
25
add_silencer { |line | RAILS_GEMS . any? { |gem | line =~ /^#{ gem } / } }
26
add_silencer { |line | line =~ %r(vendor/plugins/[^\/ ]+/lib) }
26
add_silencer { |line | line =~ %r(vendor/plugins/[^\/ ]+/lib) }
27
end
27
end
28
+
29
+
30
+ private
31
+ def add_gem_filters
32
+ Gem . path . each do |path |
33
+ # http://gist.github.com/30430
34
+ add_filter { |line | line . sub ( /(#{ path } )\/ gems\/ ([a-z]+)-([0-9.]+)\/ (.*)/ , '\2 (\3) \4' ) }
35
+ end
36
+
37
+ vendor_gems_path = Rails ::GemDependency . unpacked_path . sub ( "#{ RAILS_ROOT } /" , '' )
38
+ add_filter { |line | line . sub ( /(#{ vendor_gems_path } )\/ ([a-z]+)-([0-9.]+)\/ (.*)/ , '\2 (\3) [v] \4' ) }
39
+ end
28
end
40
end
29
41
30
# For installing the BacktraceCleaner in the test/unit
42
# For installing the BacktraceCleaner in the test/unit
0 commit comments