class 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
#

Cookbooks::RegisteredBinaries.location?

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

initialize

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

Public Instance Methods

available_programs?() click to toggle source
#

available_programs?

#
# File lib/cookbooks/utility_scripts/registered_headers.rb, line 116
def available_programs?
  Cookbooks.available_programs?
end
create_yaml_file()
Alias for: save_yaml_file
opnn() click to toggle source
#

opnn

#
Calls superclass method Cookbooks::Registered#opnn
# File lib/cookbooks/utility_scripts/registered_headers.rb, line 109
def opnn
  super(NAMESPACE)
end
report_to_the_user_what_we_will_do() click to toggle source
#

#report_to_the_user_what_we_will_do

#
# File lib/cookbooks/utility_scripts/registered_headers.rb, line 159
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 Cookbooks::Registered#reset
# File lib/cookbooks/utility_scripts/registered_headers.rb, line 82
def reset
  super()
  @hash_to_be_stored = {} # This is the hash that will be stored.
  @query = ::Cookbooks::Cookbook.new(:do_not_run_yet) { :bypass_menu }
end
run() click to toggle source
#

run

#
# File lib/cookbooks/utility_scripts/registered_headers.rb, line 130
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|
            inner_entry = File.basename(inner_entry)
            @hash_to_be_stored[inner_entry] = program_name
          }
        else
          entry = File.basename(entry)
          @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/cookbooks/utility_scripts/registered_headers.rb, line 172
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?
    into = ruby_src_dir?+'cookbooks/lib/cookbooks/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/cookbooks/utility_scripts/registered_headers.rb, line 93
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