class RBT::Action::MapThisInputToThatRegisteredProgram
Public Class Methods
[](i = ARGV)
click to toggle source
#¶ ↑
RBT::Action::MapThisInputToThatRegisteredProgram
[]¶ ↑
This method will return nil if no registered program has been found for the given input. Otherwise it will return the real name of the program at hand.
.h files work as input as well.
Usage examples:
x = RBT::Action::MapThisInputToThatRegisteredProgram[:php] x = RBT::Action::MapThisInputToThatRegisteredProgram[:gee] x = RBT::Action::MapThisInputToThatRegisteredProgram[:foobar] x = RBT::Action::MapThisInputToThatRegisteredProgram['stdio.h'] x = RBT::Action::MapThisInputToThatRegisteredProgram[:soxi] # => "sox"
#¶ ↑
# File lib/rbt/actions/individual_actions/map_this_input_to_that_registered_program/map_this_input_to_that_registered_program.rb, line 322 def self.[](i = ARGV) new(i) { :be_quiet }.real_program_name? end
new( commandline_arguments = nil, run_already = true ) { || ... }
click to toggle source
#¶ ↑
initialize¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/map_this_input_to_that_registered_program/map_this_input_to_that_registered_program.rb, line 48 def initialize( commandline_arguments = nil, run_already = true ) reset set_commandline_arguments( commandline_arguments ) # ======================================================================= # # === Handle blocks next: # ======================================================================= # if block_given? yielded = yield case yielded # ===================================================================== # # === :be_quiet # ===================================================================== # when :be_quiet set_be_quiet end end run if run_already end
Public Instance Methods
real_program_name?()
click to toggle source
#¶ ↑
real_program_name?¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/map_this_input_to_that_registered_program/map_this_input_to_that_registered_program.rb, line 300 def real_program_name? @real_program_name end
Also aliased as: return_possible_match
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
RBT::Action#reset
# File lib/rbt/actions/individual_actions/map_this_input_to_that_registered_program/map_this_input_to_that_registered_program.rb, line 75 def reset super() infer_the_namespace # ======================================================================= # # === :be_verbose # ======================================================================= # set_be_verbose # ======================================================================= # # === @real_program_name # # This is always nil on startup. # ======================================================================= # @real_program_name = nil # ======================================================================= # # === @type # # @type can be :abbreviation, :library, :header, :pkgconfig_file, # :partial_header or a similar entry. # ======================================================================= # @type = nil end
Also aliased as: clear
run()
click to toggle source
#¶ ↑
run (run tag)¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/map_this_input_to_that_registered_program/map_this_input_to_that_registered_program.rb, line 117 def run i = first_argument?.to_s # Must work on a String. # ======================================================================= # # === Handle the real names # ======================================================================= # if RBT.is_this_a_registered_program?(i) @real_program_name = i if be_verbose? e "#{i} is a registered program." end # ======================================================================= # # === Handle input that incorrectly starts with "lib". # # Next, we handle input given to this class like "libcryptsetup", # which should really just be "cryptsetup" instead. # ======================================================================= # elsif i.start_with?('lib') and RBT.is_this_a_registered_program?(i.sub(/^lib/,'')) @real_program_name = i.sub(/^lib/,'') if be_verbose? e "#{i} is a registered program, if the leading 'lib' prefix is dropped." end set_type :program # ======================================================================= # # === Handle abbreviations next # ======================================================================= # elsif RBT.is_this_a_registered_abbreviation?(i) @real_program_name = RBT.hash_aliases_to_the_available_programs?[i] if be_verbose? e "#{i} is a registered abbreviation." e "It points to the program called `#{@real_program_name}`." end set_type :abbreviation # ======================================================================= # # === Handle binaries next # # Commandline usage example: # # map_this_input_to_that_registered_program soxi # # ======================================================================= # elsif RBT.is_this_a_registered_binary?(i) @real_program_name = RBT.hash_all_binaries[i] if be_verbose? e "#{i} is a registered binary (executable)." e "It points to the program called `#{@real_program_name}`." end set_type :binary # ======================================================================= # # === Handle binaries next, downcasing the input # # This entry point will find all registered binaries for all # available programs. # # Commandline usage example: # # map_this_input_to_that_registered_program soxi # # ======================================================================= # elsif RBT.is_this_a_registered_binary?(i.downcase) @real_program_name = RBT.hash_all_binaries[i.downcase] if be_verbose? e "#{i.downcase} is a registered binary (executable)." e "It points to the program called `#{@real_program_name}`." end set_type :binary # ======================================================================= # # === Handle binaries next, downcasing the input # # This entry point will find all registered binaries for all # available programs. # # Commandline usage example: # # map_this_input_to_that_registered_program soxi # # ======================================================================= # elsif RBT.is_this_a_registered_binary?(i.downcase, :deep_check) @real_program_name = RBT.hash_all_binaries[i.downcase] if be_verbose? e "#{i.downcase} is a registered binary (executable)." e "It points to the program called `#{@real_program_name}`." end set_type :binary # ======================================================================= # # === Handle libraries next # # Example: # # map_this_input_to_that_registered_program libc.so # # ======================================================================= # elsif ::RBT.is_this_library_included?(i) this_library = RBT.this_library_to_that_program(i) @real_program_name = this_library if be_verbose? e "#{i} is a registered library." e "It points to the program called `#{@real_program_name}`." end set_type :library # ======================================================================= # # === Handle headers next # # Commandline usage example: # # map_this_input_to_that_registered_program udev.h # map_this_input_to_that_registered_program wrap_init.h # # ======================================================================= # elsif RBT.is_this_header_included?(i) @real_program_name = RBT.all_headers?[i] if be_verbose? e "#{i} is a registered header file." e "It points to the program called `#{@real_program_name}`." end set_type :header # ======================================================================= # # === Handle partial headers next # # Commandline usage example: # # map_this_input_to_that_registered_program SMlib.h # # ======================================================================= # elsif RBT.is_this_partial_header_included?(i) selection = RBT.all_headers?.transform_keys {|entry| File.basename(entry) } if selection.has_key? i @real_program_name = selection[i] if be_verbose? e "#{i} is a registered partial header file - this means it" e "is in a subdirectory." e "It points to the program called `#{@real_program_name}`." end set_type :partial_header else opne "#{rev}The header #{steelblue(i)} was not found, oddly enough." end # ======================================================================= # # === Handle .pc pkgconfig-entries next # # Commandline usage example: # # map_this_input_to_that_registered_program xau.pc # # ======================================================================= # elsif RBT.is_this_pkgconfig_file_included?(i) @real_program_name = RBT.return_the_associated_program_for_this_pkgconfig_file(i) if be_verbose? e "#{i} is a registered .pc pkg-config file." e "It points to the program called `#{@real_program_name}`." end set_type :pkgconfig_file # ======================================================================= # # === Handle partial headers next # # Commandline usage example: # # map_this_input_to_that_registered_program wrap_init.h # # ======================================================================= # elsif RBT.is_this_partial_header_included?(i) _ = RBT.all_headers? # ===================================================================== # # Must find any partial match next. # ===================================================================== # possible_matches = _.select {|key, value| key.include?(i) } @real_program_name = possible_matches.first.last if be_verbose? e "#{i} is a registered header file." e "It points to the program called `#{@real_program_name}`." end set_type :header else if be_verbose? e "#{sfancy(i)} #{rev}is not registered." end end end
set_type(i = :abbreviation)
click to toggle source