class Cookbooks::FindAllArchiveTypes
Constants
- EXIT_ON_MISSING_ARCHIVE
#¶ ↑
Cookbooks::FindAllArchiveTypes::EXIT_ON_MISSING_ARCHIVE¶ ↑
#¶ ↑
- LJUST
#¶ ↑
Cookbooks::FindAllArchiveTypes::LJUST¶ ↑
#¶ ↑
- NAMESPACE
#¶ ↑
Cookbooks::FindAllArchiveTypes::NAMESPACE¶ ↑
#¶ ↑
- REPORT_POSSIBLE_PROBLEM
#¶ ↑
Cookbooks::FindAllArchiveTypes::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.
#¶ ↑
# File lib/cookbooks/utility_scripts/find_all_archive_types.rb, line 90 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
opnn()
click to toggle source
process_every_directory()
click to toggle source
#¶ ↑
#process_every_directory¶ ↑
#¶ ↑
# File lib/cookbooks/utility_scripts/find_all_archive_types.rb, line 106 def process_every_directory all_directories?.each {|dir| found_entry = Dir[dir+'*'].first if found_entry.nil? if @report_possible_problem opnn; e '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
Cookbooks::Base#reset
# File lib/cookbooks/utility_scripts/find_all_archive_types.rb, line 59 def reset super() set_base_directory @exit_on_missing_archive = EXIT_ON_MISSING_ARCHIVE @report_possible_problem = REPORT_POSSIBLE_PROBLEM @hash = {} @hash.default = 0 # We start counting at 0. @array_for_tar_bz2 = [] # Store .tar.bz2 files here. @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/cookbooks/utility_scripts/find_all_archive_types.rb, line 183 def show_results opnn; e '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/cookbooks/utility_scripts/find_all_archive_types.rb, line 157 def show_results_for(i = TAR_BZ2) case i when TAR_GZ if @array_for_tar_gz.empty? opnn; e 'No '+swarn('.tar.gz')+' entries were found.' else @array_for_tar_gz.each {|entry| e swarn(' '+entry) } end when TAR_BZ2 if @array_for_tar_bz2.empty? opnn; e 'No .tar.bz2 entries were found.' else @array_for_tar_bz2.each {|entry| e swarn(' '+entry) } end end end