class RBT::BeautifyConfigureHelpOutput

Constants

R
#

R

#
RUN_THIS_COMMAND
#

RUN_THIS_COMMAND

This is the command we run to get some help.

#

Public Class Methods

new( run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/beautify_configure_help_output.rb, line 36
def initialize(
    run_already = true
  )
  reset
  run if run_already
end

Public Instance Methods

colourize_this(i) click to toggle source
#

colourize_this (colourize tag)

This method will colourize some words.

#
# File lib/rbt/utility_scripts/beautify_configure_help_output.rb, line 110
def colourize_this(i)
  if i.include? 'DATAROOTDIR'
    i.gsub!(/(DATAROOTDIR)/, slateblue('\1')+green)
  end
  if i.include? 'EPREFIX'
    i.gsub!(/(EPREFIX)/, orange('\1')+green)
  elsif i.include? 'PREFIX'
    i.gsub!(/(PREFIX)/, orchid('\1')+green)
  end
  if i.include? 'SUFFIX'
    i.gsub!(/(SUFFIX)/, powderblue('\1')+green)
  end
  return i
end
determine_result() click to toggle source
#

determine_result

@result will keep the result from running a sys-command.

#
# File lib/rbt/utility_scripts/beautify_configure_help_output.rb, line 96
def determine_result
  begin
    @result = `#{RUN_THIS_COMMAND}`.split("\n").map {|entry|
      entry.chomp.strip
    }
    reformat_result_string
  rescue Errno::ENOENT; end
end
find_all_entries_with( i = '--' ) click to toggle source
#

find_all_entries_with

All entries without a ‘–’ will be rejected from our dataset.

#
# File lib/rbt/utility_scripts/beautify_configure_help_output.rb, line 60
def find_all_entries_with(
    i = '--'
  )
  @result.select! {|entry| entry.include? i }
end
green() click to toggle source
#

green

#
# File lib/rbt/utility_scripts/beautify_configure_help_output.rb, line 69
def green
  Colours::GREEN
end
reformat_result_string() click to toggle source
#

reformat_result_string

We will reformat the @result string here.

#
# File lib/rbt/utility_scripts/beautify_configure_help_output.rb, line 78
def reformat_result_string
  _ = @result
  _ = _.split(N) unless _.is_a? Array
  return _
end
report_result() click to toggle source
#

report_result

#
# File lib/rbt/utility_scripts/beautify_configure_help_output.rb, line 128
def report_result
  n_options = @result.size
  opne 'These ('+simp(n_options.to_s)+') options are available '+
       'for '+simp(File.basename(return_pwd))+':'
  e
  n_ljust = 38
  l_padding = '    '.dup # Left padding.
  if @result.is_a? Array
    cliner {
      @result.sort.each {|entry|
        if entry.include? '  '
          splitted = entry.split('  ').reject {|inner_entry|
            inner_entry.empty?
          }
          splitted.map! {|inner_entry| inner_entry.tr(R,'').tr(T,'') }
          # We have a little leading '  ' padding.
          splitted[0]  = l_padding+(splitted[0].ljust(n_ljust))+green
          splitted[-1] = colourize_this(splitted[-1])
          splitted[-1] = splitted[-1].strip.ljust(40)+rev
          entry = splitted.join('  ')
        else # Else we have to pad too.
          entry = l_padding+entry.ljust(n_ljust)
        end
        efancy "  #{entry}"
      }
    }
  end
  e
end
reset() click to toggle source
#

reset

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/beautify_configure_help_output.rb, line 46
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @result
  # ======================================================================= #
  @result = nil
end
result?() click to toggle source
#

result?

#
# File lib/rbt/utility_scripts/beautify_configure_help_output.rb, line 87
def result?
  @result
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/beautify_configure_help_output.rb, line 161
def run
  determine_result
  if result?
    find_all_entries_with('--')
    report_result
  end
end