Class: UnzipmeUnzipper
- Inherits:
-
Object
- Object
- UnzipmeUnzipper
- Defined in:
- lib/unzip_me/unzipme_unzipper.rb
Instance Method Summary collapse
- #file_list ⇒ Object
-
#initialize(file, args = {}) ⇒ UnzipmeUnzipper
constructor
A new instance of UnzipmeUnzipper.
- #unzip ⇒ Object
Constructor Details
#initialize(file, args = {}) ⇒ UnzipmeUnzipper
Returns a new instance of UnzipmeUnzipper.
4 5 6 7 8 |
# File 'lib/unzip_me/unzipme_unzipper.rb', line 4 def initialize(file, args={}) validate_file(file) @args = args @file = file end |
Instance Method Details
#file_list ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/unzip_me/unzipme_unzipper.rb', line 15 def file_list files = [] listing_lines = IO.popen("unzip -l '#{@file}' 2>/dev/null") { |f| f.readlines } if @command == UnzipmeValidator::COMMAND_UNZIP listing_lines = IO.popen("7za l '#{@file}' 2>/dev/null") {|f| f.readlines} if @command == UnzipmeValidator::COMMAND_7ZIP listing_lines[0..-3].each_with_index do |line, idx| # The slice means ignore the last 3 lines of the list (just trailer information) next if idx < 3 # Skip the first three lines; just header information files << line.rstrip[27 + 1..-1] # The file name is the last column in the listing. end files end |
#unzip ⇒ Object
10 11 12 13 |
# File 'lib/unzip_me/unzipme_unzipper.rb', line 10 def unzip run_system_unzip if @command == UnzipmeValidator::COMMAND_UNZIP run_system_7zip if @command == UnzipmeValidator::COMMAND_7ZIP end |