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.

Instance Method Summary collapse

Methods included from Helpers

#trunc_dir

Constructor Details

#initializevoid

Class constructor. No parameters required.



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

def initialize
  # create a new instance of the CmdConfig class then read the config var
  @cmd = CmdConfig.new
  # die if there is no Internet connection with a return code of 2...
  exit 2 unless internet?(@cmd)
  # set up the output and logging class
  @log = Logger.new(@cmd)
  # create instance of the Metrics class
  @metrics = Metrics.new
  # instantiate the console output class for header, footer etc
  @cons = ConsoleOutput.new(@log, @metrics, @cmd)
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
57
58
# File 'lib/update_repo.rb', line 43

def start
  String.disable_colorization = !@cmd[:color]
  # check for existence of 'Git' and exit otherwise...
  checkgit
  # print out our header unless we are dumping / importing ...
  @cons.show_header unless dumping?
  if !@cmd[:show_errors]
    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 ...
    @cons.show_footer unless dumping?
  else
    @cons.show_last_errors
  end
end