class RBT::BeautifyConfigureHelpOutput

Constants

NAMESPACE
#

NAMESPACE

#
R
#

R

#
RUN_THIS_COMMAND
#

RUN_THIS_COMMAND

This is the command we run to get some help.

#
T

Public Class Methods

new( run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/beautify_configure_help_output.rb, line 40
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 117
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 103
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 85
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 135
def report_result
  n_options = @result.size
  opnn; e 'These ('+simp(n_options.to_s)+') options are available '+
          'for '+simp(File.basename(Dir.pwd))+':'
  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
end
reset() click to toggle source
#

reset

#
# File lib/rbt/utility_scripts/beautify_configure_help_output.rb, line 50
def reset
  @result = nil
  @namespace = NAMESPACE
end
result?() click to toggle source
#

result?

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

rev

#
# File lib/rbt/utility_scripts/beautify_configure_help_output.rb, line 76
def rev
  Colours.rev
end
run() click to toggle source
#

run (run tag)

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