From bd84b820188daed991756531071137dc7e0876a0 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 17 Apr 2009 21:49:57 -0700 Subject: Eliminate Pathname extensions --- activesupport/lib/active_support/core_ext/exception.rb | 17 ++++++++++++----- activesupport/lib/active_support/core_ext/pathname.rb | 5 ----- .../active_support/core_ext/pathname/clean_within.rb | 10 ---------- 3 files changed, 12 insertions(+), 20 deletions(-) delete mode 100644 activesupport/lib/active_support/core_ext/pathname.rb delete mode 100644 activesupport/lib/active_support/core_ext/pathname/clean_within.rb (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/core_ext/exception.rb b/activesupport/lib/active_support/core_ext/exception.rb index 9564591e36..b594fbae8e 100644 --- a/activesupport/lib/active_support/core_ext/exception.rb +++ b/activesupport/lib/active_support/core_ext/exception.rb @@ -1,13 +1,19 @@ -require 'active_support/core_ext/pathname' - module ActiveSupport FrozenObjectError = RUBY_VERSION < '1.9' ? TypeError : RuntimeError end # TODO: Turn all this into using the BacktraceCleaner. class Exception # :nodoc: + # Clean the paths contained in the message. + def self.clean_paths(string) + require 'pathname' unless defined? Pathname + string.gsub(%r{[\w. ]+(/[\w. ]+)+(\.rb)?(\b|$)}) do |path| + Pathname.new(path).cleanpath + end + end + def clean_message - Pathname.clean_within message + Exception.clean_paths(message) end TraceSubstitutions = [] @@ -16,9 +22,10 @@ class Exception # :nodoc: def clean_backtrace backtrace.collect do |line| - Pathname.clean_within(TraceSubstitutions.inject(line) do |result, (regexp, sub)| + substituted = TraceSubstitutions.inject(line) do |result, (regexp, sub)| result.gsub regexp, sub - end) + end + Exception.clean_paths(substituted) end end diff --git a/activesupport/lib/active_support/core_ext/pathname.rb b/activesupport/lib/active_support/core_ext/pathname.rb deleted file mode 100644 index 04862aea45..0000000000 --- a/activesupport/lib/active_support/core_ext/pathname.rb +++ /dev/null @@ -1,5 +0,0 @@ -if defined? Pathname - require 'active_support/core_ext/pathname/clean_within' -else - autoload :Pathname, 'active_support/core_ext/pathname/clean_within' -end diff --git a/activesupport/lib/active_support/core_ext/pathname/clean_within.rb b/activesupport/lib/active_support/core_ext/pathname/clean_within.rb deleted file mode 100644 index 89690252b1..0000000000 --- a/activesupport/lib/active_support/core_ext/pathname/clean_within.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'pathname' - -class Pathname - # Clean the paths contained in the provided string. - def self.clean_within(string) - string.gsub(%r{[\w. ]+(/[\w. ]+)+(\.rb)?(\b|$)}) do |path| - new(path).cleanpath - end - end -end -- cgit v1.2.3