Class: UpdateRepo::WalkRepo

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/update_repo.rb

Overview

An encapsulated class to walk the repo directories and update all Git repositories found therein. rubocop:disable Metrics/ClassLength

Instance Method Summary collapse

Methods included from Helpers

#print_log, #trunc_dir

Constructor Details

#initializevoid

Class constructor. No parameters required.



23
24
25
26
27
28
29
30
31
32
# File 'lib/update_repo.rb', line 23

def initialize
  @metrics = { processed: 0, skipped: 0, failed: 0, updated: 0,
               start_time: 0, failed_list: [] }
  @summary = { processed: 'green', updated: 'cyan', skipped: 'yellow',
               failed: 'red' }
  # create a new instance of the CmdConfig class then read the config var
  @cmd = CmdConfig.new
  # set up the logfile if needed
  setup_logfile if cmd(:log)
end

Instance Method Details

#startObject

This function will perform the required actions to traverse the Repo.

Examples:

walk_repo = UpdateRepo::WalkRepo.new
walk_repo.start


38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/update_repo.rb', line 38

def start
  String.disable_colorization = !cmd(:color)
  # make sure we dont have bad cmd-line parameter combinations ...
  @cmd.check_params # TODO - check this since is already called in @cmd.init
  # print out our header unless we are dumping / importing ...
  show_header unless dumping?
  config['location'].each do |loc|
    cmd(:dump_tree) ? dump_tree(File.join(loc)) : recurse_dir(loc)
  end
  # print out an informative footer unless dump / import ...
  footer unless dumping?
end