class RBT::Cookbooks::RegisteredBinaries
Public Class Methods
location?()
click to toggle source
new( run_already = true ) { || ... }
click to toggle source
opnn()
click to toggle source
search_for_this_program(i, &block)
click to toggle source
Public Instance Methods
opnn()
click to toggle source
report_to_the_user_what_we_will_do()
click to toggle source
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
RBT::Cookbooks::Registered#reset
# File lib/rbt/registered/registered_binaries.rb, line 49 def reset super() infer_the_namespace # ======================================================================= # # === @hash_to_be_stored # ======================================================================= # @hash_to_be_stored = {} # This is the hash that will be stored. # ======================================================================= # # === @cookbook_dataset # ======================================================================= # @cookbook_dataset = nil # ======================================================================= # # === @this_program # ======================================================================= # @this_program = nil end
run()
click to toggle source
#¶ ↑
run¶ ↑
#¶ ↑
# File lib/rbt/registered/registered_binaries.rb, line 183 def run report_to_the_user_what_we_will_do # ======================================================================= # # We could rescue the following code, but I think it is better to fail, # and then correct the error. But in case we wish to change the # behaviour again, the rescue-clause below was retained in the comments. # ======================================================================= # available_programs?.each { |program_name| _ = RBT::Cookbooks::SanitizeCookbook.new(program_name) { :fast } 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 # opne '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/registered/registered_binaries.rb, line 89 def save_yaml_file into = RBT.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_for_the_registered_yaml_files?}"\ "#{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/registered/registered_binaries.rb, line 131 def search_for_this_program( i = @this_program ) be_verbose = be_verbose? i = i.to_s if i.include? '/' i = File.basename(i) opne "The input includes a #{simp('/')} token. We will "\ "truncate this to the" opne 'last part only, as we only keep the names registered, '\ 'not the paths.' opne "Thus, our input will be #{sfancy(i)}." end if be_verbose opne "Searching for `#{sfancy(i)}` now:" end # ======================================================================= # # Query whether it is already included or not. # ======================================================================= # if RBT.does_include? i if be_verbose opne "Yes, this appears to be already registered with the "\ "same name #{simp(i)}." end program_version = RBT.swift_return_version_of_this_program(i) if be_verbose opne "Its program version is: #{lightblue(program_version)}" end return i else hash = load_yaml(FILE_REGISTERED_BINARIES) if hash.keys.include?(i) result = hash[i] if be_verbose opne "The binary called `#{sfancy(i)}` was found." opne "It is part of the package → `#{simp(result)}`." end return result else if be_verbose opne sfancy(i)+' is '+swarn('NOT')+' included. We could not '\ 'find any program' opne 'including this program.' end end false # Not included, thus we return false. end end