Class: Mundane::FilesToZips
- Inherits:
-
Object
- Object
- Mundane::FilesToZips
- Extended by:
- FileWorker, Prompter
- Defined in:
- lib/mundane/algos/files_to_zips.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
.compress_files_and_write_to_out_as_zips(files) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/mundane/algos/files_to_zips.rb', line 18 def self.compress_files_and_write_to_out_as_zips(files) files.each do |f| pretty_name = f.chomp(File.extname(f)) if File.exists?("out/#{pretty_name}.zip") puts "out/#{pretty_name}.zip ALREADY EXISTED, SKIPPING FILE. DELETE MANUALLY IF NEEDED =/" next end Zip::File.open("out/#{pretty_name}.zip", Zip::File::CREATE) do |zipfile| zipfile.add(f, f) end end end |
.execute ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/mundane/algos/files_to_zips.rb', line 6 def self.execute user_wants_to_proceed = prompt_user("Are you sure you want to make %count_targeted_files% zipped files and put them into ./out/ ?\n[Y/n]") if user_wants_to_proceed make_output_directory files = get_files_in_current_folder compress_files_and_write_to_out_as_zips(files) end end |