class RBT::Cookbooks::RegisteredBinaries

Constants

NAMESPACE
#

NAMESPACE

#

Public Class Methods

location?() click to toggle source
#

RBT::Cookbooks::RegisteredBinaries.location?

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

initialize

#
# File lib/rbt/utility_scripts/registered_binaries.rb, line 37
def initialize(
    run_already = true
  )
  reset
  run if run_already
end
opnn() click to toggle source
#

RegisteredBinaries.opnn

#
# File lib/rbt/utility_scripts/registered_binaries.rb, line 102
def self.opnn
  Opn.opn(namespace: NAMESPACE)
end
search_for_this_program(i) click to toggle source
#

Cookbooks::RegisteredBinaries.search_for_this_program

#
# File lib/rbt/utility_scripts/registered_binaries.rb, line 93
def self.search_for_this_program(i)
  _ = Cookbooks::RegisteredBinaries.new(false)
  _.set_this_program(i)
  _.search_for_this_program(i)
end

Public Instance Methods

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

opnn

#
# File lib/rbt/utility_scripts/registered_binaries.rb, line 109
def opnn
  RegisteredBinaries.opnn
end
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_binaries.rb, line 57
def report_to_the_user_what_we_will_do
  opnn; e 'Obtaining Information about available binaries next.'
  opnn; e 'This may take a while.'
  opnn; e orange('Please be patient.')
end
reset() click to toggle source
#

reset

#
Calls superclass method RBT::Cookbooks::Registered#reset
# File lib/rbt/utility_scripts/registered_binaries.rb, line 47
def reset
  super()
  @hash_to_be_stored = {} # This is the hash that will be stored.
  @cookbook_dataset = nil
  @this_program = nil
end
run() click to toggle source
#

run

#
# File lib/rbt/utility_scripts/registered_binaries.rb, line 155
def run
  report_to_the_user_what_we_will_do
  available_programs?.each { |program_name|
    begin
      _ = RBT::Cookbooks::Cookbook.new(program_name) { :bypass_menu }
      binaries = _.binaries? # This is an Array.
      unless binaries.empty?
        e program_name if SHOW_PROGRAM_NAME
        binaries.each {|entry|
          @hash_to_be_stored[entry] = program_name
        }
      end
    rescue Exception => error
      opnn; e 'An error happened for the program '+
              sfile(program_name)+
              '. (Error: '+error.class.to_s+')'
      pp error
    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_binaries.rb, line 77
def save_yaml_file
  into = FILE_REGISTERED_BINARIES
  what = YAML.dump(hash?)
  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(into)}"
    e "Also storing into `#{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_binaries.rb, line 118
def search_for_this_program(
    i = @this_program
  )
  i = i.to_s
  if i.include? '/'
    i = File.basename(i)
    opnn; e "The input includes a #{simp('/')} token. We will "\
            "truncate this to the"
    opnn; e 'last part only, as we only keep the names registered, '\
            'not the paths.'
    opnn; e "Thus, our input will be #{sfancy(i)}."
  end
  opnn; e "Searching for `#{sfancy(i)}` now:"
  # ======================================================================= #
  # Query whether it is already included or not.
  # ======================================================================= #
  if RBT.does_include? i
    opnn; e "Yes, this appears to be already registered with the "\
            "same name #{simp(i)}."
    program_version = RBT.swift_return_version_of_this_program(i)
    opnn; e "Its program version is: #{lightblue(program_version)}"
  else
    hash = load_yaml(FILE_REGISTERED_BINARIES)
    if hash.keys.include? i
      opnn; e "The binary called `#{sfancy(i)}` was found."
      opnn; e "It is part of the package -> `#{simp(hash[i])}`."
    else
      opnn; e sfancy(i)+' is '+swarn('NOT')+' included. We could not '\
              'find any program'
      opnn; e 'including this program.'
    end
  end
end