class RBT::Action::Extract
Public Class Methods
new( i = nil, run_already = true ) { || ... }
click to toggle source
#¶ ↑
initialize¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/extract/extract.rb, line 20 def initialize( i = nil, run_already = true, &block ) reset case i # ======================================================================= # # === :do_not_run_yet # ======================================================================= # when :do_not_run_yet i = nil run_already = false end set_commandline_arguments(i) do_assume_that_all_commandline_arguments_are_programs_we_seek_to_extract # ======================================================================= # # === Handle blocks given to this class next # ======================================================================= # if block_given? yielded = yield case yielded # ===================================================================== # # === :do_not_run_yet # ===================================================================== # when :do_not_run_yet run_already = false # ===================================================================== # # === :be_silent # # This entry point forces this class to be quiet - aka to output # significantly less to the user. # ===================================================================== # when :be_silent, :be_quiet @internal_hash[:be_silent_or_verbose] = :be_silent end end run if run_already end
Public Instance Methods
be_silent_or_verbose?()
click to toggle source
delegate_towards_class_extracter( what, extract_to = :default )
click to toggle source
#¶ ↑
delegate_towards_class_extracter
¶ ↑
This method will delegate towards class Extracter.
#¶ ↑
# File lib/rbt/actions/individual_actions/extract/extract.rb, line 150 def delegate_towards_class_extracter( what, extract_to = :default ) case what # ======================================================================= # # === :default_programs # ======================================================================= # when :default_programs what = extract_these_programs? end flattened = [what].flatten.compact flattened.each {|this_entry| if this_entry.is_a?(String) and this_entry.start_with?(':') this_entry = try_to_find_an_alternative_path_for_this_source_archive(this_entry.delete(':')) elsif this_entry.is_a?(Symbol) this_entry = try_to_find_an_alternative_path_for_this_source_archive(this_entry.to_s) end case extract_to # ======================================================================= # # === :default # ======================================================================= # when :default extract_to = extract_to?(this_entry) end # ======================================================================= # # Finally, delegate towards Extracter: # ======================================================================= # Extracter.extract_what_to(this_entry, to: extract_to) { be_silent_or_verbose? } } end
Also aliased as: invoke_class_extracter
do_assume_that_all_commandline_arguments_are_programs_we_seek_to_extract()
click to toggle source
#¶ ↑
do_assume_that_all_commandline_arguments_are_programs_we_seek_to_extract
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/extract/extract.rb, line 98 def do_assume_that_all_commandline_arguments_are_programs_we_seek_to_extract _ = commandline_arguments? if _ and !_.empty? set_extract_these_programs(_) end end
do_extract_all_programs_supplied_to_this_class( i = extract_these_programs? )
click to toggle source
#¶ ↑
do_extract_all_programs_supplied_to_this_class
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/extract/extract.rb, line 192 def do_extract_all_programs_supplied_to_this_class( i = extract_these_programs? ) i.flatten.each {|entry| if entry.is_a?(String) and entry.start_with?(':') # =================================================================== # # Query RawCookbook for the assumed path next: # =================================================================== # raw_cookbook = action(:raw_cookbook, entry.to_s.delete(':')) program_path = raw_cookbook.program_path? if File.file?(program_path) @extract_to = extract_to?(entry).delete(':') message_to_the_user_next_extracting_to_this_directory(program_path, @extract_to) return delegate_towards_class_extracter(program_path, @extract_to) else entry = try_to_find_an_alternative_path_for_this_source_archive(entry) end end entry = entry.first if entry.is_a?(Array) if is_this_an_archive? entry entry = absolute_path(entry) # Work with the absolute path here. # =================================================================== # # The target is an archive, so we can extract it: # =================================================================== # @extract_to = extract_to?(entry) message_to_the_user_next_extracting_to_this_directory(entry, @extract_to) _result = delegate_towards_class_extracter(entry, @extract_to) else opne sfile(entry)+rev+' does not appear to be a registered archive type.' end } end
extract_these_programs?()
click to toggle source
message_to_the_user_next_extracting_to_this_directory( entry, extract_to )
click to toggle source
#¶ ↑
message_to_the_user_next_extracting_to_this_directory
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/extract/extract.rb, line 131 def message_to_the_user_next_extracting_to_this_directory( entry, extract_to ) opne "#{rev}Next extracting #{sfile(entry)}#{rev} "\ "to #{sdir(extract_to)}#{rev}." end
path?()
click to toggle source
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
RBT::Action#reset
# File lib/rbt/actions/individual_actions/extract/extract.rb, line 64 def reset super() try_to_require_the_extracter_gem # ======================================================================= # # === :extract_these_programs # ======================================================================= # @internal_hash[:extract_these_programs] = [] # ======================================================================= # # === :be_silent_or_verbose # ======================================================================= # @internal_hash[:be_silent_or_verbose] = :be_verbose end
run()
click to toggle source
set_extract_these_programs(i)
click to toggle source
#¶ ↑
set_extract_these_programs
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/extract/extract.rb, line 87 def set_extract_these_programs(i) unless @internal_hash[:extract_these_programs].include? i @internal_hash[:extract_these_programs] << i @internal_hash[:extract_these_programs].flatten! @internal_hash[:extract_these_programs].compact end end
Also aliased as: set_extract_this_program
set_extract_to(i)
click to toggle source
try_to_find_an_alternative_path_for_this_source_archive(entry)
click to toggle source
#¶ ↑
try_to_find_an_alternative_path_for_this_source_archive
¶ ↑
#¶ ↑
# File lib/rbt/actions/individual_actions/extract/extract.rb, line 115 def try_to_find_an_alternative_path_for_this_source_archive(entry) # =================================================================== # # Assume pseudo-symbol here, such as :htop # =================================================================== # entry = "#{src_dir?}#{entry.to_s.delete(':')}/" # =================================================================== # # We get the first entry anyway. # =================================================================== # possible_files = Dir["#{entry}*"] entry = possible_files.first unless possible_files.empty? return entry end