class RBT::QueryBinaryToPackage

Constants

HASH_ALL_REGISTERED_BINARIES
NAMESPACE
#

NAMESPACE

#

Public Class Methods

[](i = '') click to toggle source
#

RBT::QueryBinaryToPackage[]

#
# File lib/rbt/utility_scripts/query_binary_to_package.rb, line 257
def self.[](i = '')
  self.new(i)
end
new( commandline_arguments = ARGV, run_already = true ) click to toggle source
#

initialize

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

Public Instance Methods

commandline_arguments?() click to toggle source
#

commandline_arguments?

#
# File lib/rbt/utility_scripts/query_binary_to_package.rb, line 231
def commandline_arguments?
  @commandline_arguments
end
Also aliased as: input?
first_argument?() click to toggle source
#

first_argument?

#
# File lib/rbt/utility_scripts/query_binary_to_package.rb, line 102
def first_argument?
  if @commandline_arguments
    @commandline_arguments.first
  else
    nil
  end
end
input?()
menu( i = commandline_arguments? ) click to toggle source
#

menu (menu tag)

#
obtain_all_binaries() click to toggle source
#

obtain_all_binaries

This method will obtain all “binaries” from the target directoy.

#
# File lib/rbt/utility_scripts/query_binary_to_package.rb, line 240
def obtain_all_binaries
  _ = target_directory?
  @array_binaries = Dir["#{_}**/**"].select {|entry| File.file?(entry) }
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/query_binary_to_package.rb, line 79
def reset
  super()
  @namespace = NAMESPACE
  @commandline_arguments = [] # <- Iniitialize it first.
  @show_all_binary_files = false
  @filter_for = nil # Whether to filter for an individual program only.
  set_target_directory # Must initialize it at the least once.
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/query_binary_to_package.rb, line 248
def run
  menu(commandline_arguments?) # Must come before obtain_all_binaries is invoked.
  obtain_all_binaries # <- Obtain all binaries.
  try_to_process_the_available_binaries
end
set_commandline_arguments(i = ARGV) click to toggle source
#

set_commandline_arguments

Keep track of the commandline arguments used.

#
# File lib/rbt/utility_scripts/query_binary_to_package.rb, line 93
def set_commandline_arguments(i = ARGV)
  i = [i].flatten.compact
  i << Dir.pwd if i.empty?
  @commandline_arguments = i
end
set_target_directory( i = Dir.pwd ) click to toggle source
#

set_target_directory

#
# File lib/rbt/utility_scripts/query_binary_to_package.rb, line 113
def set_target_directory(
    i = Dir.pwd
  )
  i = i.first if i.is_a? Array
  i = Dir.pwd if i.nil?
  i = i.to_s.dup
  unless i.end_with? '/'
    i << '/'
  end
  if first_argument?.is_a? Symbol
    case first_argument?
    when :default
      i = '/usr/bin/'
    end
  end if first_argument?
  @target_directory = i
end
Also aliased as: set_use_this_directory
set_use_this_directory( i = Dir.pwd )
show_help() click to toggle source
#

show_help (help tag)

#
# File lib/rbt/utility_scripts/query_binary_to_package.rb, line 219
def show_help
  opnn; e 'The following options are available:'
  e
  e '  --unassigned            # Show entries without an attribute as well.'
  e '  --filter_for=xorgserver # Show only binary files belonging to '\
    'this program (e. g. the xorgserver in this example)'
  e
end
target?()
Alias for: target_directory?
target_directory?() click to toggle source
#

target_directory?

#
# File lib/rbt/utility_scripts/query_binary_to_package.rb, line 134
def target_directory?
  @target_directory
end
Also aliased as: target?
try_to_process_the_available_binaries() click to toggle source
#

try_to_process_the_available_binaries

We work through the discovered binaries.

#
# File lib/rbt/utility_scripts/query_binary_to_package.rb, line 184
def try_to_process_the_available_binaries
  ljust_value = 55
  if @filter_for
  end
  array = @array_binaries
  if array.empty?
    opnn; e 'No binaries were found.'
  else
    array.each {|this_binary|
      _ = this_binary.sub(/\/usr\/bin\//,'')
      # =================================================================== #
      # Query the big Hash next that includes all our binary files.
      # =================================================================== #
      if HASH_ALL_REGISTERED_BINARIES.has_key? _
        this_program = HASH_ALL_REGISTERED_BINARIES[_]
        if @filter_for and
           (@filter_for != this_program)
          # Filter for a specific program in this case.
        else
          e 'The binary '+sfancy(this_binary.ljust(ljust_value))+' belongs to '\
            'the program called `'+orange(this_program)+'`.'
        end
      else
        if @show_all_binary_files
          e 'The binary '+sfancy(this_header.ljust(ljust_value))+' is currently '\
            'unassigned. (An orphan binary).'
        end
      end
    }
  end
end