class RBT::Cookbooks::RegisteredHeaders

Constants

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/registered/registered_headers.rb, line 154
def self.location?
  opn; e LOCATION_REGISTERED_HEADERS
end
new( run_already = true ) click to toggle source
#

initialize

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

Public Instance Methods

create_yaml_file( what = YAML.dump(@hash_to_be_stored), into = LOCATION_REGISTERED_HEADERS )
Alias for: save_yaml_file
iterate_over_the_available_programs() click to toggle source
#

iterate_over_the_available_programs

#
# File lib/rbt/registered/registered_headers.rb, line 161
def iterate_over_the_available_programs
  available_programs?.each {|program_name|
    headers = return_headers_of_this_program(program_name)
    unless headers.empty?
      if SHOW_PROGRAM_NAME
        opne "#{rev}The program called #{sfancy(program_name)} #{rev}has "\
             "some header files (#{headers.size} of them)."
      end
      headers.each {|entry|
        if entry.include? ','
          entry.split(',').each {|inner_entry|
            @hash_to_be_stored[inner_entry.dup] = program_name.dup
          }
        else
          @hash_to_be_stored[entry] = program_name.dup
        end
      }
    end
  }
end
report_to_the_user_what_we_will_do() click to toggle source
#

report_to_the_user_what_we_will_do

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

reset

#
Calls superclass method RBT::Cookbooks::Registered#reset
# File lib/rbt/registered/registered_headers.rb, line 92
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @hash_to_be_stored
  # ======================================================================= #
  @hash_to_be_stored = {} # This is the hash that will be stored.
  # ======================================================================= #
  # === @try_to_use_the_expanded_cookbook_dataset_if_available
  #
  # This option should be significantly faster, so we will try to
  # make use of it. The drawback is that we may have outdated
  # data, if we did not update the expanded dataset for a long
  # time - but the speed advantage is a big reason in keeping
  # this set to true.
  # ======================================================================= #
  @try_to_use_the_expanded_cookbook_dataset_if_available = true
end
return_headers_of_this_program(i) click to toggle source
#

return_headers_of_this_program

#
# File lib/rbt/registered/registered_headers.rb, line 114
def return_headers_of_this_program(i)
  use_this_key = :headers
  if @try_to_use_the_expanded_cookbook_dataset_if_available and
     does_this_expanded_cookbook_file_exist_for_this_program?(i)
    i = load_dataset_from_this_expanded_cookbook(i)
    headers = i[use_this_key]
  else
    headers = action(:SanitizeCookbook, i) { :fast }.headers?
  end
  return headers
end
run() click to toggle source
#

run

#
# File lib/rbt/registered/registered_headers.rb, line 216
def run
  report_to_the_user_what_we_will_do
  iterate_over_the_available_programs
  save_yaml_file
end
save_yaml_file( what = YAML.dump(@hash_to_be_stored), into = LOCATION_REGISTERED_HEADERS ) 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/registered/registered_headers.rb, line 198
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_for_the_registered_yaml_files?}#{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(i) click to toggle source
#

search_for_this_program

Use this method to search for a specific program.

#
# File lib/rbt/registered/registered_headers.rb, line 131
def search_for_this_program(i)
  i = i.to_s
  opne "Searching for #{simp(i)} now:"
  hash = load_yaml(RBT.file_registered_headers)
  if hash.has_key?(i)
    # This entry point means that we header was directly found.
    opne 'The header called `'+sfancy(i)+rev+'` was found.'
    it_is_part_of_the_package(hash[i])
  elsif hash.keys.map {|entry| File.basename(entry) }.include? i
    selection = hash.select {|key, value| key.include? i }
    this_program hash[selection.keys.first]
    opne 'Yes, is a sub-header and belongs to the '\
         'program `'+simp(this_program)+rev+'`.'
    return this_program
  else
    opne i+' is '+swarn('NOT')+' included. We could not find any program'
    opne 'including this header.'
  end
end