class RBT::Cookbooks::ValidateCookbookAliases

Constants

COOKBOOK_ALIASES_FILE
#

COOKBOOK_ALIASES_FILE

#
YAML_COOKBOOK_ALIASES

Public Class Methods

new( run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/checks_and_validations/validate_cookbook_aliases.rb, line 39
def initialize(
    run_already = true
  )
  reset
  case run_already
  when :do_not_run_yet
    run_already = false
  end
  run if run_already
end

Public Instance Methods

check_against_menu(i) click to toggle source
#

check_against_menu

#
# File lib/rbt/checks_and_validations/validate_cookbook_aliases.rb, line 66
def check_against_menu(i)
  if i.is_a? Array
    i.each {|entry| menu(entry) }
  else
    case i # case tag
    # ===================================================================== #
    # === validate_cookbook_aliases --help
    # ===================================================================== #
    when /^-?-?help$/i
      opne 'You can OPEN the aliases file.'
      exit
    # ===================================================================== #
    # === validate_cookbook_aliases --open
    # ===================================================================== #
    when /^-?-?open$/i
      opne 'Next opening the file '+sfile(COOKBOOK_ALIASES_FILE)
      esystem "#{editor?} #{COOKBOOK_ALIASES_FILE}"
      exit
    end
  end
end
Also aliased as: menu
check_integrity_of_cookbook_aliases()
Alias for: run
feedback_debug() click to toggle source
#

feedback_debug

#
# File lib/rbt/checks_and_validations/validate_cookbook_aliases.rb, line 131
def feedback_debug
  opne 'Debug: here is the main dataset:'
  pp return_sorted
end
find_out_which_files_are_missing() click to toggle source
#

find_out_which_files_are_missing

This method will find out which cookbook-files are missing.

#
# File lib/rbt/checks_and_validations/validate_cookbook_aliases.rb, line 109
def find_out_which_files_are_missing
  return_sorted.each {|value|
    # ===================================================================== #
    # The variable value is not allowed to include any '_' character.
    # ===================================================================== #
    value.delete!('_') if value.include? '_'
    # ===================================================================== #
    # Simply do a File.exist? check next.
    # ===================================================================== #
    _ = individual_cookbooks_directory?+value+'.yml'
    if File.exist?(_)
      # e 'The key `'+key.to_s+'` is pointing at `'+value.to_s+'`. '
      # e 'This is ok, it is a valid entry.'
    else # Does not exist.
      report_this_lateron(_)
    end
  }
end
menu(i)
Alias for: check_against_menu
report_everything_now() click to toggle source
#

report_everything_now

#
# File lib/rbt/checks_and_validations/validate_cookbook_aliases.rb, line 150
def report_everything_now
  @array_this_file.each { |file|
    value = File.basename(file).gsub(/\.yml/,'')
    opnwarn 'Nope, `'+sfile(file)+swarn('` does not exist.')
    opnwarn 'Consider fixing `'+sfancy(value)+swarn('` in order to '\
            'have a valid cookbook-aliases file.')
  }
  if @array_this_file.empty?
    e cyan('Everything is fine, all entries are correct! ')+
      yellow(cheering_person?)
  end
end
reset() click to toggle source
#

reset

#
Calls superclass method RBT::Base#reset
# File lib/rbt/checks_and_validations/validate_cookbook_aliases.rb, line 53
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @array_this_file
  # ======================================================================= #
  @array_this_file = []
  do_not_debug
end
return_sorted() click to toggle source
#

return_sorted

Return the aliases in a sorted manner.

#
# File lib/rbt/checks_and_validations/validate_cookbook_aliases.rb, line 100
def return_sorted
  YAML_COOKBOOK_ALIASES.values.sort
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/checks_and_validations/validate_cookbook_aliases.rb, line 166
def run
  inform_the_user_what_will_happen # We inform the user that we validate the cookbook-aliases file.
  find_out_which_files_are_missing
  report_everything_now
  feedback_debug if debug?
end

Private Instance Methods

inform_the_user_what_will_happen() click to toggle source
#

inform_the_user_what_will_happen

#
# File lib/rbt/checks_and_validations/validate_cookbook_aliases.rb, line 139
def inform_the_user_what_will_happen
  opne; e
  e 'We will next try to validate the following file:'
  e
  e "  #{sfile(FILE_COOKBOOK_ALIASES)}"
  e # Add a newline as well.
end
report_this_lateron(i) click to toggle source
#

report_this_lateron

#
# File lib/rbt/checks_and_validations/validate_cookbook_aliases.rb, line 91
def report_this_lateron(i)
  @array_this_file << i # Append into an Array.
end