class RBT::Cookbooks::CheckForCorrectDependencies

Public Class Methods

[](i = ARGV) click to toggle source
#

RBT::Cookbooks::CheckForCorrectDependencies[]

#
# File lib/rbt/checks_and_validations/check_for_correct_dependencies.rb, line 180
def self.[](i = ARGV)
  new(i)
end
new( commandline_arguments = ARGV, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/checks_and_validations/check_for_correct_dependencies.rb, line 32
def initialize(
    commandline_arguments = ARGV,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Public Instance Methods

check_for_every_entry( use_this_as_the_key_for_required_deps_on = 'required_deps_on'.to_sym ) click to toggle source
#

check_for_every_entry

This method will check for every available (registered) program.

#
# File lib/rbt/checks_and_validations/check_for_correct_dependencies.rb, line 106
def check_for_every_entry(
    use_this_as_the_key_for_required_deps_on =
      'required_deps_on'.to_sym
  )
  opne 'Now checking every program. This may take a while.'
  available_programs?.each {|program|
    program = File.basename(program).sub(/\.yml$/,'')
    # ===================================================================== #
    # The next line is very verbose, so it may be best to enable it only
    # for debugging purposes really.
    # ===================================================================== #
    # opne 'Working on the program `'+sfancy(program)+'` next.'
    # ===================================================================== #
    # We have two ways for the next line - we will either instantiate a
    # new Cookbooks object - or we will make use of an already existing,
    # expanded .yml file that holds the dataset for the program at hand.
    # ===================================================================== #
    if expanded_directory_exists? and
       File.exist?(
         path_to_this_expanded_cookbooks_dataset(program)
       )
      dataset = YAML.load_file(
        path_to_this_expanded_cookbooks_dataset(program)
      )
      deps = dataset[use_this_as_the_key_for_required_deps_on]
    else
      @raw_cookbook.reset_the_main_hash
      dataset = @raw_cookbook.find(program)
      deps    = @raw_cookbook.deps?
    end
    result = nil
    if deps
      result = deps.all? {|entry|
        RBT.really_does_include?(entry)
      }
    end
    if result # Ok, in this case all entries were found.
    else # else it was not found, so work on that.
      if deps
        @n_erroneous_entries_were_found += 1
        deps.each {|entry|
          if entry.nil?
            opne 'Nil value found for `'+steelblue(program)+'`. '\
                 'This is probably an empty entry.'
          end
          if entry
            if entry.include?(' ')
              entry = entry.split(' ').first.strip
            end
            unless RBT.really_does_include? entry
              e "#{format_program(program)} No "\
                "entry for `#{simp(entry)}` was found."
            end
          end
        }
      end
    end
  }
end
format_program(i) click to toggle source
#

format_program

#
# File lib/rbt/checks_and_validations/check_for_correct_dependencies.rb, line 62
def format_program(i)
  _ = "#{i}:"
  _ = _.ljust(22)
  splitted = _.split(':')
  splitted[0] = sfancy(splitted.first)
  _ = splitted.join(':')
  _
end
menu( i = commandline_arguments? ) click to toggle source
#

menu (menu tag)

#
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Base#reset
# File lib/rbt/checks_and_validations/check_for_correct_dependencies.rb, line 46
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @raw_cookbook
  # ======================================================================= #
  @raw_cookbook = RBT.raw_cookbook
  # ======================================================================= #
  # === @n_erroneous_entries_were_found
  # ======================================================================= #
  @n_erroneous_entries_were_found = 0
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/checks_and_validations/check_for_correct_dependencies.rb, line 169
def run
  unless commandline_arguments?.empty?
    menu
  else # else check for every entry
    check_for_every_entry
  end
end
show_help() click to toggle source
#

show_help

#
# File lib/rbt/checks_and_validations/check_for_correct_dependencies.rb, line 74
def show_help
  e
  e 'Currently this class has no special commandline flags.'
  e
end