class RBT::ShowDescriptionAndExtraInformation

Public Class Methods

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

initialize

#
# File lib/rbt/utility_scripts/show_description_and_extra_information.rb, line 22
def initialize(
    commandline_arguments = ARGV,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Public Instance Methods

output_this_coloured_line(line) click to toggle source
#

output_this_coloured_line

#
# File lib/rbt/utility_scripts/show_description_and_extra_information.rb, line 51
def output_this_coloured_line(line)
  result = ''.dup
  result << '  ' if @pad_with_two_spaces_to_the_left
  # ======================================================================= #
  # The right-unicode arrow will always be colourized.
  # ======================================================================= #
  if line.include?('→') 
    result << lightgreen(line)
  elsif line.start_with? '  '
    result << olive(line)
  else
    result << olivedrab(line)
  end
  e result
end
reset() click to toggle source
#

reset

#
Calls superclass method RBT::LeanPrototype#reset
# File lib/rbt/utility_scripts/show_description_and_extra_information.rb, line 36
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @pad_with_two_spaces_to_the_left
  #
  # If the following variable is true then we will use two ' ' to pad
  # the line.
  # ======================================================================= #
  @pad_with_two_spaces_to_the_left = true
end
run() click to toggle source
#

run

#
# File lib/rbt/utility_scripts/show_description_and_extra_information.rb, line 70
def run
  this_program = first_argument?
  if is_this_program_included?(this_program)
    dataset = action(:SanitizeCookbook, this_program) { :fast }
    # ===================================================================== #
    # We need the raw description next, as that one preserves the
    # newlines in the .yml file.
    # ===================================================================== #
    description       = dataset.raw_description?
    extra_information = dataset.extra_information?
    if description and !description.empty?
      e steelblue('Description:')
      e
      description.split(N).each {|line|
        output_this_coloured_line(line)
      }
      e
    end
    if extra_information and !extra_information.empty?
      e steelblue('Extra information:')
      e
      extra_information.split(N).each {|line|
        output_this_coloured_line(line)
      }
      e
    end
  else
    opne "#{rev}The program #{steelblue(this_program)} #{rev}is not included."
  end
end