clean_within.rb 228 字节
Newer Older
1 2 3 4 5 6 7
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
8 9 10
    end
  end
end