Class: Mundane::ZipsToFiles
- Inherits:
-
Object
- Object
- Mundane::ZipsToFiles
- Extended by:
- FileWorker, Prompter
- Defined in:
- lib/mundane/algos/zips_to_files.rb
Class Method Summary collapse
Methods included from FileWorker
count_targeted_files, get_files_in_current_folder, make_output_directory
Methods included from Prompter
construct_informative_message, prompt_user
Class Method Details
.decompress_files_and_dump_them_to_out(files) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/mundane/algos/zips_to_files.rb', line 17 def self.decompress_files_and_dump_them_to_out(files) incomplete_extractions = 0 # decompress each file in the list files.each do |zip| # TODO: next if zip.extension != 'zip' Zip::File.open(zip) do |archive| archive.each do |f| output_path = "out/#{f.name}" if File.exists? output_path # don't auto-overwrite anything... puts "#{output_path} ALREADY EXISTED, SKIPPING FILE. DELETE MANUALLY IF NEEDED =/" incomplete_extractions += 1 next end f.extract output_path end end end puts "\nOperation terminated, there were #{incomplete_extractions} incomplete extractions." if incomplete_extractions > 0 end |
.execute ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/mundane/algos/zips_to_files.rb', line 6 def self.execute user_wants_to_proceed = prompt_user("Are you sure you want to unzip %count_targeted_files% zip files and dump their contents into ./out/ ?\n[Y/n]") if user_wants_to_proceed make_output_directory files = get_files_in_current_folder decompress_files_and_dump_them_to_out(files) end end |