class RBT::Cookbooks::CheckIfSourceDirectoriesExist

Constants

PADDING
#

PADDING

#

Public Class Methods

new( optional_input = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/check_for_existing_source_directories.rb, line 33
def initialize(
    optional_input = nil,
    run_already    = true
  )
  reset
  set_commandline_arguments(optional_input)
  run if run_already
end

Public Instance Methods

check_commandline_arguments() click to toggle source
#

check_commandline_arguments

#
# File lib/rbt/utility_scripts/check_for_existing_source_directories.rb, line 79
def check_commandline_arguments
  case @commandline_arguments.first # case tag
  # === --helpHELP
  when /^-?-?help$/i
    show_help_then_exit
  end
end
check_each_entry() click to toggle source
#

check_each_entry

#
# File lib/rbt/utility_scripts/check_for_existing_source_directories.rb, line 130
def check_each_entry
  available_programs?.each {|entry|
    target = source_directory?+File.basename(entry).sub(/\.yml$/,'')+'/'
    shall_we_check_this_target = false
    if File.exist? target # ok, the target exists, all may be fine, so we pass through.
      shall_we_check_this_target = true
    end
    # ===================================================================== #
    # Some entries in the yaml file have a "do_not_download"
    # entry. In that case we will ignore them.
    # ===================================================================== #
    location = individual_cookbooks_directory?+File.basename(entry)
    if File.exist? location
      hash = load_this_cookbook(location) # in module_methods.rb
      unless hash['do_not_download'].nil?
      end
    end
    if shall_we_check_this_target
      if be_verbose?
        e 'Target '+sfile(target.ljust(padding?))+' does exist.'
      end
    else # does not exist, report
      register_target_does_not_exist(target)
    end
  }
end
load_this_cookbook(i) click to toggle source
#

load_this_cookbook

#
# File lib/rbt/utility_scripts/check_for_existing_source_directories.rb, line 160
def load_this_cookbook(i)
  RBT::Cookbooks::Cookbook.new(i) { :bypass_menu_check }
end
padding?() click to toggle source
#

padding?

#
# File lib/rbt/utility_scripts/check_for_existing_source_directories.rb, line 123
def padding?
  PADDING
end
register_target_does_not_exist(i) click to toggle source
#

register_target_does_not_exist

#
# File lib/rbt/utility_scripts/check_for_existing_source_directories.rb, line 90
def register_target_does_not_exist(i)
  @array_targets << i
end
report_missing_entries() click to toggle source
#

report_missing_entries

Report all missing entries here.

#
# File lib/rbt/utility_scripts/check_for_existing_source_directories.rb, line 99
def report_missing_entries # report them all now.
  sanitize_targets
  @array_targets.sort.each {|entry|
    e sdir(entry.squeeze('/').ljust(PADDING))+' does not exist.'
  }
  unless @array_targets.empty?
    _ = @array_targets.size.to_s
    # ===================================================================== #
    # Always report non-existing directories.
    # ===================================================================== #
    opn; e "We found #{simp(_)} non-existing directories."
  end
end
reset() click to toggle source
#

reset

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/check_for_existing_source_directories.rb, line 45
def reset
  super()
  @array_targets = []
  @be_verbose = false # if true then we will also report directories that exist.
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/check_for_existing_source_directories.rb, line 167
def run
  check_commandline_arguments
  check_each_entry
  report_missing_entries
end
sanitize_targets() click to toggle source
#

sanitize_targets

#
# File lib/rbt/utility_scripts/check_for_existing_source_directories.rb, line 116
def sanitize_targets
  @array_targets.map! {|entry| entry << '/' }
end
set_commandline_arguments(i = nil) click to toggle source
#

set_commandline_arguments

#
# File lib/rbt/utility_scripts/check_for_existing_source_directories.rb, line 54
def set_commandline_arguments(i = nil)
  i = [i].flatten.compact
  @commandline_arguments = i
end
show_help(optional_then_exit = false) click to toggle source
#

show_help

#
# File lib/rbt/utility_scripts/check_for_existing_source_directories.rb, line 69
def show_help(optional_then_exit = false)
  if Object.const_defined? :ClassDocuShower
    ClassDocuShower.new(__FILE__)
  end
  exit if optional_then_exit
end
show_help_then_exit() click to toggle source
#

show_help_then_exit

#
# File lib/rbt/utility_scripts/check_for_existing_source_directories.rb, line 62
def show_help_then_exit
  show_help :then_exit
end