class RBT::QueryHeaderToPackage

Constants

HASH_ALL_REGISTERED_HEADERS

Public Class Methods

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

RBT::QueryHeaderToPackage[]

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

initialize

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

Public Instance Methods

menu( i = commandline_arguments? ) click to toggle source
#

menu (menu tag)

#
obtain_all_headers() click to toggle source
#

obtain_all_headers

This method will obtain all .h files from the target directoy.

#
# File lib/rbt/utility_scripts/query_header_to_package.rb, line 218
def obtain_all_headers
  _ = target_directory?
  @array_headers = Dir["#{_}**/**.h"]
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::LeanPrototype#reset
# File lib/rbt/utility_scripts/query_header_to_package.rb, line 70
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @show_all_header_files
  # ======================================================================= #
  @show_all_header_files = false
  # ======================================================================= #
  # === @filter_for
  # ======================================================================= #
  @filter_for = nil # Whether to filter for an individual program only.
  set_target_directory # Must initialize it at the least once.
  set_commandline_arguments # Invoke it here because it is a bit different to regular @commandline_arguments.
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/query_header_to_package.rb, line 226
def run
  menu # Must come before obtain_all_headers is invoked.
  obtain_all_headers # ← Obtain all .h files.
  try_to_process_the_available_headers
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_header_to_package.rb, line 90
def set_commandline_arguments(i = ARGV)
  i = [i].flatten.compact
  i << return_pwd if i.empty?
  @internal_hash[:commandline_arguments] = i
end
set_target_directory( i = return_pwd ) click to toggle source
#

set_target_directory

#
# File lib/rbt/utility_scripts/query_header_to_package.rb, line 99
def set_target_directory(
    i = return_pwd
  )
  i = i.first if i.is_a? Array
  i = return_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/include/'
    end
  end if first_argument?
  @target_directory = i
end
Also aliased as: set_use_this_directory
set_use_this_directory( i = return_pwd )
show_help() click to toggle source
#

show_help (help tag)

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

target_directory?

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

try_to_process_the_available_headers

We work through the discovered .h files.

#
# File lib/rbt/utility_scripts/query_header_to_package.rb, line 170
def try_to_process_the_available_headers
  ljust_value = 55
  if @filter_for
  end
  if @array_headers.empty?
    opne 'No headers were found.'
  else
    @array_headers.each {|this_header|
      _ = this_header.sub(/\/usr\/include\//,'')
      # =================================================================== #
      # Query the big Hash next that includes all our .h files.
      # =================================================================== #
      if HASH_ALL_REGISTERED_HEADERS.has_key? _
        this_program = HASH_ALL_REGISTERED_HEADERS[_]
        if @filter_for and
           (@filter_for != this_program)
          # Filter for a specific program in this case.
        else
          e 'The header '+sfancy(this_header.ljust(ljust_value))+' belongs to '\
            'the program called `'+orange(this_program)+'`.'
        end
      else
        if @show_all_header_files
          e 'The header '+sfancy(this_header.ljust(ljust_value))+' is currently '\
            'unassigned. (An orphan header).'
        end
      end
    }
  end
end