Module: DbAgile::FileSystemTools
- Extended by:
- FileSystemTools
- Included in:
- FileSystemTools
- Defined in:
- lib/dbagile/tools/file_system.rb
Instance Method Summary collapse
-
#friendly_path(path, from) ⇒ Object
Returns a friendly path for display.
-
#friendly_path!(path) ⇒ Object
Returns a friendly path, no matter what happens.
Instance Method Details
#friendly_path(path, from) ⇒ Object
Returns a friendly path for display
5 6 7 8 9 10 11 12 |
# File 'lib/dbagile/tools/file_system.rb', line 5 def friendly_path(path, from) from, path = Pathname.new(from), Pathname.new(path) if path.to_s[0...from.to_s.length] == from.to_s "~/#{path.relative_path_from(from)}" else nil end end |
#friendly_path!(path) ⇒ Object
Returns a friendly path, no matter what happens
15 16 17 18 19 |
# File 'lib/dbagile/tools/file_system.rb', line 15 def friendly_path!(path) friendly_path(path, ENV['HOME']) or friendly_path(path, File.('.')) or path end |