Method: RuboCop::PathUtil.relative_path
- Defined in:
- lib/rubocop/path_util.rb
.relative_path(path, base_dir = Dir.pwd) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/rubocop/path_util.rb', line 8 def relative_path(path, base_dir = Dir.pwd) # Optimization for the common case where path begins with the base # dir. Just cut off the first part. return path[(base_dir.length + 1)..-1] if path.start_with?(base_dir) path_name = Pathname.new(File.(path)) path_name.relative_path_from(Pathname.new(base_dir)).to_s end |