class Cookbooks::ValidateCookbookAliases

Constants

COOKBOOK_ALIASES_FILE
#

COOKBOOK_ALIASES_FILE

#
NAMESPACE
#

NAMESPACE

#
YAML_COOKBOOK_ALIASES

Public Class Methods

new(run_already = true) click to toggle source
#

initialize

#
Calls superclass method
# File lib/cookbooks/validation/validate_cookbook_aliases.rb, line 41
def initialize(run_already = true)
  super()
  reset
  run if run_already
end

Public Instance Methods

check_against_menu(i) click to toggle source
#

#check_against_menu

#
# File lib/cookbooks/validation/validate_cookbook_aliases.rb, line 59
def check_against_menu(i)
  case i # case tag
  # ======================================================================= #
  # === validate_cookbook_aliases --help
  # ======================================================================= #
  when 'HELP',/-?-?help/
    opnn; e 'You can OPEN the aliases file.'
    exit
  # ======================================================================= #
  # === validate_cookbook_aliases --open
  # ======================================================================= #
  when 'OPEN',/-?-?open/
    opnn; e 'Next opening the file '+sfile(COOKBOOK_ALIASES_FILE)
    esystem 'bluefish '+COOKBOOK_ALIASES_FILE
    exit
  end
end
Also aliased as: menu
check_integrity_of_cookbook_aliases()
Alias for: run
feedback_debug() click to toggle source
#

#feedback_debug

#
# File lib/cookbooks/validation/validate_cookbook_aliases.rb, line 135
def feedback_debug
  opnn; e '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/cookbooks/validation/validate_cookbook_aliases.rb, line 113
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.
    # ===================================================================== #
    _ = 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
opnn() click to toggle source
#

opnn

#
Calls superclass method Cookbooks::Base#opnn
# File lib/cookbooks/validation/validate_cookbook_aliases.rb, line 153
def opnn
  super(NAMESPACE)
end
report_everything_now() click to toggle source
#

#report_everything_now

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

reset

#
Calls superclass method Cookbooks::Base#reset
# File lib/cookbooks/validation/validate_cookbook_aliases.rb, line 50
def reset
  super()
  @array_this_file = []
  do_not_debug
end
return_sorted() click to toggle source
#

#return_sorted

Return the aliases in a sorted manner.

#
# File lib/cookbooks/validation/validate_cookbook_aliases.rb, line 104
def return_sorted
  YAML_COOKBOOK_ALIASES.values.sort
end
run() click to toggle source
#

run (run tag)

#
# File lib/cookbooks/validation/validate_cookbook_aliases.rb, line 160
def run
  inform_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_user_what_will_happen() click to toggle source
#

#inform_user_what_will_happen

#
# File lib/cookbooks/validation/validate_cookbook_aliases.rb, line 143
def inform_user_what_will_happen
  opnn; e 'We will next try to validate the file'
  opnn; e
  opnn; e '  `'+sfile(COOKBOOK_ALIASES_FILE)+'`.'
  opnn; e # Add a newline as well.
end
report_this_lateron(i) click to toggle source
#

#report_this_lateron

#
# File lib/cookbooks/validation/validate_cookbook_aliases.rb, line 95
def report_this_lateron(i)
  @array_this_file << i # Append into an Array.
end