class RBT::ShowAllAbout

Constants

NAMESPACE
#

NAMESPACE

#

Public Class Methods

new( this_program = ARGV, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/show_all_about.rb, line 32
def initialize(
    this_program = ARGV,
    run_already  = true
  )
  reset
  set_program(this_program)
  run if run_already
end

Public Instance Methods

determine_available_programs() click to toggle source
#

determine_available_programs

#
# File lib/rbt/utility_scripts/show_all_about.rb, line 149
def determine_available_programs
  @available_programs = available_programs?
end
menu(i) click to toggle source
#

menu (menu tag)

#
program_name?() click to toggle source
#

program_name?

#
# File lib/rbt/utility_scripts/show_all_about.rb, line 142
def program_name?
  @program
end
reset() click to toggle source
#

reset

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/show_all_about.rb, line 44
def reset
  super()
  @namespace = NAMESPACE
end
run() click to toggle source
#

run

#
# File lib/rbt/utility_scripts/show_all_about.rb, line 156
def run
  _ = program_name?.downcase # Must downcae it since as of Jan 2018.
  determine_available_programs
  if @available_programs.include? _
    opnn; e "Now showing all about `#{seagreen(_)}`.#{N}#{N}"
    cookbook_location = "#{individual_cookbooks_directory?}#{_}.yml"
    if File.exist? cookbook_location
      # =================================================================== #
      # Since as of January 2018, we will also check this cookbooks file
      # for errors.
      # =================================================================== #
      if Object.const_defined?(:RBT) and
        RBT.respond_to? :does_this_cookbook_file_have_any_erroneous_entry?
        if RBT.does_this_cookbook_file_have_any_erroneous_entry?(cookbook_location)
          opnn; e 'Note that the file `'+sfile(cookbook_location)+'`'
          opnn; e 'has at the least one erroneous entry.'
          RBT.check_this_cookbook_file_for_errors(cookbook_location)
        end
      end
    end
    # ======================================================================= #
    # Simply use File.readlines() rather than YAML.load_file() next.
    # ======================================================================= #
    dataset = readlines_with_proper_encoding(cookbook_location).map {|entry|
      "  #{entry}"
    } 
    # ======================================================================= #
    # Pad it with two ' ' on the left side.
    # ======================================================================= #
    dataset = dataset.join
    cliner { e dataset }
  else
    opnn; e "No program called `#{seagreen(_)}` appears to be registered.#{N}"
  end
end
set_program(i) click to toggle source
#

set_program

This method will set the program name.

#
# File lib/rbt/utility_scripts/show_all_about.rb, line 54
def set_program(i)
  if i.is_a? Array
    i = i.first
  end
  if i.nil?
    # ===================================================================== #
    # In this case, if the user did not provide anything useful, we will
    # simply try to use a name inferred from the current working directory.
    # ===================================================================== #
    possible_name = ::ProgramInformation.return_program_name(
      File.basename(Dir.pwd)
    )
    i = possible_name if possible_name
  end
  original_input = i.dup
  # ======================================================================= #
  # The input may include '_', '-' or '.', which are not a valid name
  # for a cookbook-recipe, so we get rid of these characters.
  # ======================================================================= #
  i = i.dup if i.frozen?
  i.delete!('-') if i.include? '-'
  i.delete!('_') if i.include? '_'
  i.delete!('.') if i.include? '.' # <- Trailing '.' are disallowed.
  i = RBT.return_alias_program_name_for(i)
  if original_input != i
    opnn; e "Using the alias name `#{sfancy(i)}` rather "\
            "than `#{royalblue(original_input)}`."
  end
  # ======================================================================= #
  # Make use of Cookbook-aliases next, so that "libatomic" is a valid
  # alias for "libatomic_ops".
  # ======================================================================= #
  unless RBT.does_include?(i)
    # ===================================================================== #
    # Ok the program is not there.
    # ===================================================================== #
    possible_new_name = RBT.return_alias_program_name_for(i)
    unless possible_new_name == i
      i = possible_new_name
    end
    unless RBT.does_include?(i)
      # =================================================================== #
      # Try to prepend 'lib' there and try again.
      # =================================================================== #
      if RBT.does_include?("lib#{i}")
        i = i.dup if i.frozen?
        i.prepend('lib')
        opnn; e 'We found another program name ('+sfancy(i)+') - '\
                'will use this one instead.'
      elsif i.start_with?('lib') and RBT.does_include?(i[3..-1])
        i = i[3..-1]
      end
    end
  end
  @program = i
  menu(i)
end
show_help() click to toggle source
#

show_help (help tag)

#
# File lib/rbt/utility_scripts/show_all_about.rb, line 133
def show_help
  opnn; e 'This is what this class will do:'
  e
  ClassDocuShower[__FILE__]
end