class RBT::Cookbooks::FindAllArchiveTypes
Constants
- EXIT_ON_MISSING_ARCHIVE
#¶ ↑
EXIT_ON_MISSING_ARCHIVE
¶ ↑#¶ ↑
- LJUST
#¶ ↑
LJUST
¶ ↑#¶ ↑
- REPORT_POSSIBLE_PROBLEM
#¶ ↑
REPORT_POSSIBLE_PROBLEM
¶ ↑#¶ ↑
Public Class Methods
Public Instance Methods
add_count_for(i)
click to toggle source
#¶ ↑
add_count_for
¶ ↑
Use this method to keep track of all the entries that are part of our @hash. We will count +1 for each of .zip, .tar.bz2, .tar.gz and .tar.xz.
#¶ ↑
# File lib/rbt/cookbooks/find_all_archive_types.rb, line 109 def add_count_for(i) case i # case tag when /\.zip$/ @hash[ZIP] += 1 when /\.tar\.bz2$/ @hash[TAR_BZ2] += 1 when /\.tar\.gz$/ @hash[TAR_GZ] += 1 when /\.tar\.xz$/ @hash[TAR_XZ] += 1 end end
all_directories?()
click to toggle source
obtain_all_directories_from_the_source_directory()
click to toggle source
process_every_directory()
click to toggle source
#¶ ↑
process_every_directory
¶ ↑
#¶ ↑
# File lib/rbt/cookbooks/find_all_archive_types.rb, line 125 def process_every_directory all_directories?.each {|dir| found_entry = Dir["#{dir}*"].first if found_entry.nil? if @report_possible_problem opne "#{rev}There might be an error at `#{sdir(dir)}`." end if be_verbose? # Only if we are verbose. exit if @exit_on_missing_archive else if found_entry.include? TAR_BZ2 @array_for_tar_bz2 << found_entry elsif found_entry.include? TAR_GZ @array_for_tar_gz << found_entry end _ = File.basename(found_entry) add_count_for(_) end } end
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
RBT::LeanPrototype#reset
# File lib/rbt/cookbooks/find_all_archive_types.rb, line 59 def reset super() infer_the_namespace set_base_directory # ======================================================================= # # === @exit_on_missing_archive # ======================================================================= # @exit_on_missing_archive = EXIT_ON_MISSING_ARCHIVE # ======================================================================= # # === @report_possible_problem # ======================================================================= # @report_possible_problem = REPORT_POSSIBLE_PROBLEM # ======================================================================= # # === @hash # ======================================================================= # @hash = {} @hash.default = 0 # We start counting at 0. # ======================================================================= # # === @array_for_tar_bz2 # ======================================================================= # @array_for_tar_bz2 = [] # Store .tar.bz2 files here. # ======================================================================= # # === @array_for_tar_gz # ======================================================================= # @array_for_tar_gz = [] # Store .tar.gz files here. end
run()
click to toggle source
run_and_report()
click to toggle source
set_base_directory( i = source_directory? )
click to toggle source
show_results()
click to toggle source
#¶ ↑
show_results
¶ ↑
This method will show the results, in a pretty-printed fashion.
#¶ ↑
# File lib/rbt/cookbooks/find_all_archive_types.rb, line 208 def show_results opne "#{rev}We found these results:" e ' '+(TAR_XZ+': ' ).ljust(LJUST)+sfancy(@hash[TAR_XZ].to_s) e ' '+(TAR_BZ2+': ').ljust(LJUST)+sfancy(@hash[TAR_BZ2].to_s) e ' '+(TAR_GZ+': ' ).ljust(LJUST)+sfancy(@hash[TAR_GZ].to_s) e ' '+(ZIP+': ' ).ljust(LJUST)+sfancy(@hash[ZIP].to_s) end
Also aliased as: report
show_results_for( i = TAR_BZ2 )
click to toggle source
#¶ ↑
show_results_for
¶ ↑
#¶ ↑
# File lib/rbt/cookbooks/find_all_archive_types.rb, line 178 def show_results_for( i = TAR_BZ2 ) case i # === .tar.gz when TAR_GZ if @array_for_tar_gz.empty? opne 'No '+swarn('.tar.gz')+' entries were found.' else @array_for_tar_gz.each {|entry| e swarn(" #{entry}") } end # === .tar.bz2 when TAR_BZ2 if @array_for_tar_bz2.empty? opne 'No .tar.bz2 entries were found.' else @array_for_tar_bz2.each {|entry| e swarn(" #{entry}") } end end end