lib/nanoc/data_sources/filesystem/tools.rb in nanoc-4.12.0 vs lib/nanoc/data_sources/filesystem/tools.rb in nanoc-4.12.1
- old
+ new
@@ -79,9 +79,18 @@
raise UnsupportedFileTypeError.new(fn)
end
end.compact.flatten
end
+ # Expands the path (including resolving ~ for home directory) and returns
+ # a relative path to the expanded path.
+ def expand_and_relativize_path(path)
+ from = Pathname.new(Dir.getwd)
+ to = Pathname.new(File.expand_path(path))
+
+ to.relative_path_from(from).to_s
+ end
+
# Returns all files and directories in the given directory and
# directories below it.
#
# @param [String] dir_name The name of the directory whose contents to
# fetch