class RBT::Cookbooks::RegisteredLibraries

Constants

LOCATION_REGISTERED_LIBRARIES
#

LOCATION_REGISTERED_LIBRARIES

#
NAMESPACE
#

NAMESPACE

#
SHOW_PROGRAM_NAME
#

SHOW_PROGRAM_NAME

#

Public Class Methods

new( run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/registered_libraries.rb, line 42
def initialize(
    run_already = true
  )
  reset
  case run_already
  when :do_not_run_yet
    run_already = false
  end
  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_libraries.rb, line 67
def report_to_the_user_what_we_will_do
  opnn; e 'Obtaining Information about available libraries 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_libraries.rb, line 56
def reset
  super()
  @hash_to_be_stored = {} # This is the hash that will be stored.
  @query = nil
  @this_program = nil
  @namespace = NAMESPACE
end
run() click to toggle source
#

run

#
# File lib/rbt/utility_scripts/registered_libraries.rb, line 76
def run
  report_to_the_user_what_we_will_do
  available_programs?.each { |program_name|
    @query = RBT::Cookbooks::Cookbook.new(program_name) { :bypass_menu }
    data = @query.return_dataset
    libraries = data['libraries'] # This is an Array.
    unless libraries.empty?
      e program_name if SHOW_PROGRAM_NAME # <- This constant is defined in the file registered.rb
      libraries.each {|entry|
        @hash_to_be_stored[entry] = program_name
      }
    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 libraries (in hash format). Right now, we need to manually update this yaml file on our own.

#
# File lib/rbt/utility_scripts/registered_libraries.rb, line 99
def save_yaml_file
  what = YAML.dump(@hash_to_be_stored)
  into = LOCATION_REGISTERED_LIBRARIES
  e sfancy('Storing yaml dataset in ')
  e "  #{sfile(into)}"
  write_what_into(what, into)
  if is_on_roebe?
    into = "#{RUBY_SRC_DIR_AT_HOME}rbt/lib/rbt/yaml/"\
           "#{File.basename(LOCATION_REGISTERED_LIBRARIES)}"
    e 'Also storing into:'
    e "  #{sfile(into)}"
    write_what_into(what, into)
  end
end
Also aliased as: create_yaml_file
search_for_this_program( i = @this_program ) click to toggle source
#

search_for_this_program

Use this method to search for a specific program.

#
# File lib/rbt/utility_scripts/registered_libraries.rb, line 119
def search_for_this_program(
    i = @this_program
  )
  i = i.to_s
  opnn; e "Searching for #{sfancy(i)} now:"
  hash = load_yaml(LOCATION_REGISTERED_LIBRARIES)
  if hash.keys.include? i
    opnn; e "The library called `#{sfancy(i)}` was found."
    opnn; e "It is part of the package -> `#{simp(hash[i])}`."
  else
    opnn; e p+' is '+swarn('NOT')+' included. We could not '\
            'find any program'
    opnn; e 'including this program.'
  end
end