class RBT::ShowCompileChain

Public Class Methods

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

initialize

#
# File lib/rbt/utility_scripts/show_compile_chain.rb, line 31
def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end
of(i = ARGV) click to toggle source
#

RBT::ShowCompileChain.of

#
# File lib/rbt/utility_scripts/show_compile_chain.rb, line 153
def self.of(i = ARGV)
  [i].flatten.compact.each {|this_program|
    new(this_program)
  }
end

Public Instance Methods

chained_programs?() click to toggle source
#

chained_programs?

#
# File lib/rbt/utility_scripts/show_compile_chain.rb, line 64
def chained_programs?
  RBT.return_chained_programs
end
dataset?() click to toggle source
#

dataset?

#
# File lib/rbt/utility_scripts/show_compile_chain.rb, line 57
def dataset?
  @dataset
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/show_compile_chain.rb, line 45
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @dataset
  # ======================================================================= #
  @dataset = chained_programs?
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/show_compile_chain.rb, line 98
def run
  sanitize_commandline_arguments
  i = first_argument?
  # ======================================================================= #
  # The next variable will have a format such as:
  #   {"kde5_plasma"=> ["bluedevil"
  # ======================================================================= #
  selection = @dataset.select {|key, value|
    key.downcase.include? i.downcase
  }
  if selection.empty?
    # ===================================================================== #
    # Enter this clause when no match was found.
    # ===================================================================== #
    opne "No match was found for `#{slateblue(i)}`."
    opne 'The available chained programs are:'
    e
    available_programs = "  #{chained_programs?.keys.join(' ').strip}"
    available_programs = wrap_at(available_programs, 54)
    array_available_programs = available_programs.split(N).map(&:strip)
    array_available_programs.each_with_index {|these_programs, index| index += 1
      padded_index = index.to_s.ljust(4)
      e '  '+padded_index+
        royalblue(
        these_programs.tr(' ',', ')
      )
    }
    e
  else
    # ===================================================================== #
    # Else we have at the least one entry in the Array called "selection".
    # ===================================================================== #
    first_entry = selection.keys.first
    array_available_programs = selection[first_entry]
    if array_available_programs.is_a?(String) and
       array_available_programs.include?(',')
      array_available_programs = array_available_programs.split(',').map(&:strip)
    end
    if array_available_programs.is_a?(Array) and
      !array_available_programs.empty?
      opne "The following entries belong to the group "\
           "`#{sfancy(first_entry)}`:"
      e
      array_available_programs.each_with_index {|this_entry, index| index += 1
        padded_index = (index.to_s.rjust(3)).ljust(6)
        e "#{lightgreen(padded_index)}#{royalblue(this_entry)}"
      }
      e
    end
  end
end
sanitize_commandline_arguments() click to toggle source
#

sanitize_commandline_arguments

#
# File lib/rbt/utility_scripts/show_compile_chain.rb, line 71
def sanitize_commandline_arguments
  commandline_arguments?.map! {|entry|
    entry = entry.to_s unless entry.is_a? String
    case entry # case tag
    # ===================================================================== #
    # === kde_apps
    # ===================================================================== #
    when /^kde(_|-)?apps$/
      entry = 'kde5_applications'
    # ===================================================================== #
    # === mate
    # ===================================================================== #
    when 'mate' # <- ShowCompileChainOf mate
      entry = 'all_of_the_mate_desktop'
    # ===================================================================== #
    # === portingaids
    # ===================================================================== #
    when 'portingaids' # <- ShowCompileChainOf portingaids
      entry = 'kde5_porting_aids'
    end
    entry
  }
end