diff options
Diffstat (limited to 'activesupport/lib/active_support/core_ext/pathname/clean_within.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/pathname/clean_within.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/pathname/clean_within.rb b/activesupport/lib/active_support/core_ext/pathname/clean_within.rb new file mode 100644 index 0000000000..ae03e1bc5a --- /dev/null +++ b/activesupport/lib/active_support/core_ext/pathname/clean_within.rb @@ -0,0 +1,14 @@ +module ActiveSupport #:nodoc: + module CoreExtensions #:nodoc: + module Pathname #:nodoc: + module CleanWithin + # Clean the paths contained in the provided string. + def clean_within(string) + string.gsub(%r{[\w. ]+(/[\w. ]+)+(\.rb)?(\b|$)}) do |path| + new(path).cleanpath + end + end + end + end + end +end |