Permalink
Browse files

No need to create regular expression every time the BacktraceFilter#f…

  • Loading branch information...
floehopper committed Nov 26, 2010
1 parent f397388 commit 2b70431de641c88308dad0e8b2943be5522218bf
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/mocha/backtrace_filter.rb
@@ -5,11 +5,11 @@ class BacktraceFilter
LIB_DIRECTORY = File.expand_path(File.join(File.dirname(__FILE__), "..")) + File::SEPARATOR

def initialize(lib_directory = LIB_DIRECTORY)
@lib_directory = lib_directory
@path_pattern = Regexp.new(lib_directory)
end

def filtered(backtrace)
backtrace.reject { |location| Regexp.new(@lib_directory).match(File.expand_path(location)) }
backtrace.reject { |location| @path_pattern.match(File.expand_path(location)) }
end

end

0 comments on commit 2b70431

Please sign in to comment.