Sha256: 6b1718760300ceabdcae2adc0eafa6cdb285177cdb69e413c8edd9c9da5d8054

Contents?: true

Size: 519 Bytes

Versions: 4

Compression:

Stored size: 519 Bytes

Contents

# encoding: utf-8

module Rubocop
  # Common methods and behaviors for dealing with paths.
  module PathUtil
    module_function

    def relative_path(path, base_dir = Dir.pwd)
      Pathname.new(path).relative_path_from(Pathname.new(base_dir)).to_s
    end

    def match_path?(pattern, path)
      case pattern
      when String
        basename = File.basename(path)
        path == pattern || basename == pattern || File.fnmatch(pattern, path)
      when Regexp
        path =~ pattern
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.19.1 lib/rubocop/path_util.rb
rubocop-0.19.0 lib/rubocop/path_util.rb
rubocop-0.18.1 lib/rubocop/path_util.rb
rubocop-0.18.0 lib/rubocop/path_util.rb