Sha256: c8d6a9a8746368c99af4cf7f71e4d1ac610872810617abfa5b2402673008a01c
Contents?: true
Size: 1.32 KB
Versions: 6
Compression:
Stored size: 1.32 KB
Contents
# Module 'Helpers' containing assorted helper functions required elsewhere module Helpers # will remove the FIRST 'how_many' root levels from a directory path 'dir'.. # @param dir [string] Path to be truncated # @param how_many [integer] How many levels to be dropped from path. # @return [string] the properly truncated path 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 # mark these as private simply so that 'reek' wont flag as utility function. private def gitdir?(dirpath) gitpath = dirpath + '/.git' File.exist?(gitpath) && File.directory?(gitpath) end def show_time(duration) time_taken = Time.at(duration).utc time_taken.strftime('%-H hours, %-M Minutes and %-S seconds') end # helper function to call the Logger class output method. # @param *string [Array] Array of strings to be passed to the 'print' fn # @return [*string] Output of the Logger def print_log(*string) @log.output(*string) end def repo_url `git config remote.origin.url`.chomp end end
Version data entries
6 entries across 6 versions & 1 rubygems