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

#trunc_dir

Constructor Details

#initializevoid

Class constructor. No parameters required.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/update_repo.rb', line 22

def initialize
  @metrics = { count: 0, skipped: 0, failed: 0, updated: 0, start_time: 0 }
  # read the options from Trollop and store in temp variable.
  # we do it this way around otherwise if configuration file is missing it
  # gives the error messages even on '--help' and '--version'
  temp_opt = set_options
  # @config - Class. Reads the configuration from a file in YAML format and
  # allows easy access to the configuration data
  @config = Confoog::Settings.new(filename: CONFIG_FILE,
                                  prefix: 'update_repo',
                                  autoload: true,
                                  autosave: false)
  # store the command line variables in a configuration variable
  @config['cmd'] = temp_opt
  config_error unless @config.status[:errors] == Status::INFO_FILE_LOADED
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


43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/update_repo.rb', line 43

def start
  String.disable_colorization = true unless param_set('color')
  no_import_export if dumping? && importing?
  show_header
  if importing?

  else
    @config['location'].each do |loc|
      recurse_dir(loc)
    end
  end
  # print out an informative footer...
  footer
end