Module: Helpers
- Included in:
- UpdateRepo::CmdConfig, UpdateRepo::ConsoleOutput, UpdateRepo::GitControl, UpdateRepo::Logger, UpdateRepo::Metrics, UpdateRepo::WalkRepo
- Defined in:
- lib/update_repo/helpers.rb
Overview
Module ‘Helpers’ containing assorted helper functions required elsewhere
Instance Method Summary collapse
-
#trunc_dir(dir, how_many) ⇒ string
will remove the FIRST ‘how_many’ root levels from a directory path ‘dir’..
Instance Method Details
#trunc_dir(dir, how_many) ⇒ string
will remove the FIRST ‘how_many’ root levels from a directory path ‘dir’..
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/update_repo/helpers.rb', line 11 def trunc_dir(dir, how_many) # make sure we don't lose any root slash if '--prune' is NOT specified return dir if how_many.zero? # convert to array then lose the first 'how_many' parts path_array = Pathname(dir).each_filename.to_a path_array = path_array.drop(how_many) # join it all back up again and return it File.join(path_array) end |