class RBT::Cookbooks::RegisteredHeaders

Constants

NAMESPACE
#

NAMESPACE

#
SHOW_PROGRAM_NAME
#

SHOW_PROGRAM_NAME

Whether to show the program name as well, as we iterate over our dataset.

#

Public Class Methods

location?() click to toggle source
#

RegisteredBinaries.location?

#
# File lib/rbt/utility_scripts/registered_headers.rb, line 124
def self.location?
  opn; e LOCATION_REGISTERED_HEADERS
end
new( run_already = true ) click to toggle source
#

initialize

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

Public Instance Methods

create_yaml_file()
Alias for: save_yaml_file
report_to_the_user_what_we_will_do() click to toggle source
#

report_to_the_user_what_we_will_do

#
# File lib/rbt/utility_scripts/registered_headers.rb, line 158
def report_to_the_user_what_we_will_do
  opnn; e 'Obtaining Information about available headers next.'
  opnn; e 'This may take a while.'
  opnn; e 'Please be patient.'
end
reset() click to toggle source
#

reset

#
Calls superclass method RBT::Cookbooks::Registered#reset
# File lib/rbt/utility_scripts/registered_headers.rb, line 96
def reset
  super()
  @namespace = NAMESPACE
  @hash_to_be_stored = {} # This is the hash that will be stored.
  @query = RBT::Cookbooks::Cookbook.new(:do_not_run_yet) { :bypass_menu }
end
run() click to toggle source
#

run

#
# File lib/rbt/utility_scripts/registered_headers.rb, line 131
def run
  report_to_the_user_what_we_will_do
  available_programs?.each { |program_name|
    @query.update_with_this_program(program_name)
    headers = @query.headers? # This is guaranteed to be an Array.
    unless headers.empty?
      if SHOW_PROGRAM_NAME
        opnn; e "The program called #{sfancy(program_name)} has "\
                "some header files."
      end
      headers.each {|entry|
        if entry.include? ','
          entry.split(',').each {|inner_entry|
            @hash_to_be_stored[inner_entry] = program_name
          }
        else
          @hash_to_be_stored[entry] = program_name
        end
      }
    end
  }
  save_yaml_file
end
save_yaml_file() click to toggle source
#

save_yaml_file

The method `save_yaml_file` will create the yaml file which lists our binaries (in hash format). Right now, we need to manually update this yaml file on our own.

#
# File lib/rbt/utility_scripts/registered_headers.rb, line 171
def save_yaml_file
  what = YAML.dump(@hash_to_be_stored)
  into = LOCATION_REGISTERED_HEADERS
  e sfancy('Storing yaml dataset in')
  e "  #{sfile(into)}"
  write_what_into(what, into)
  if on_roebe? # <- Store on my home dir as well.
    into = ruby_src_dir?+'rbt/lib/rbt/yaml/'+
           File.basename(into)
    e sfancy('Storing the yaml dataset also in')
    e '  '+sfile(into)
    write_what_into(what, into)
  end
end
Also aliased as: create_yaml_file
search_for_this_program(p) click to toggle source
#

search_for_this_program

Use this method to search for a specific program.

#
# File lib/rbt/utility_scripts/registered_headers.rb, line 108
def search_for_this_program(p)
  p = p.to_s
  opnn; e 'Searching for '+simp(p)+' now:'
  hash = load_yaml(LOCATION_REGISTERED_HEADERS)
  if hash.keys.include? p
    opnn; e 'The header called `'+sfancy(p)+'` was found.'
    opnn; e 'It is part of the package `'+simp(hash[p])+'`.'
  else
    opnn; e p+' is '+swarn('NOT')+' included. We could not find any program'
    opnn; e 'including this header.'
  end
end