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/cookbooks/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/cookbooks/check_for_existing_source_directories.rb, line 84
def check_commandline_arguments
  case first_argument? # case tag
  # ======================================================================= #
  # === --help
  # ======================================================================= #
  when /^-?-?help$/i
    show_help_then_exit
  end
end
check_each_entry() click to toggle source
#

check_each_entry

#
# File lib/rbt/cookbooks/check_for_existing_source_directories.rb, line 150
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/cookbooks/check_for_existing_source_directories.rb, line 143
def load_this_cookbook(i)
  RBT::Cookbooks::SanitizeCookbook.new(i) { :fast }
end
padding?() click to toggle source
#

padding?

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

register_target_does_not_exist

#
# File lib/rbt/cookbooks/check_for_existing_source_directories.rb, line 97
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/cookbooks/check_for_existing_source_directories.rb, line 106
def report_missing_entries # report them all now.
  sanitize_targets
  # ======================================================================= #
  # Next display all found targets:
  # ======================================================================= #
  e
  @array_targets.sort.each {|entry|
    e "  #{sdir(entry.squeeze('/').ljust(PADDING))} does "\
      "#{tomato('not')} exist."
  }
  e
  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/cookbooks/check_for_existing_source_directories.rb, line 47
def reset
  super()
  # ======================================================================= #
  # === @array_targets
  # ======================================================================= #
  @array_targets = []
  # ======================================================================= #
  # === :be_verbose
  # ======================================================================= #
  set_do_not_be_verbose # if true then we will also report directories that exist.
end
run() click to toggle source
#

run (run tag)

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

sanitize_targets

#
# File lib/rbt/cookbooks/check_for_existing_source_directories.rb, line 129
def sanitize_targets
  @array_targets.map! {|entry| entry << '/' }
end
show_help( optional_then_exit = false ) click to toggle source
#

show_help

#
# File lib/rbt/cookbooks/check_for_existing_source_directories.rb, line 69
def show_help(
    optional_then_exit = false
  )
  begin
    require 'class_docu_shower'
  rescue LoadError; end
  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/cookbooks/check_for_existing_source_directories.rb, line 62
def show_help_then_exit
  show_help :then_exit
end