Class: Falkor::Extract::TarGz
- Inherits:
-
Object
- Object
- Falkor::Extract::TarGz
- Includes:
- TrackableProgress
- Defined in:
- lib/falkor/extract/tar_gz.rb
Constant Summary collapse
- TAR_LONGLINK =
"././@LongLink"
Instance Method Summary collapse
- #extract ⇒ Object
-
#initialize(file_name, has_root_dir: false) ⇒ TarGz
constructor
A new instance of TarGz.
Methods included from TrackableProgress
Constructor Details
#initialize(file_name, has_root_dir: false) ⇒ TarGz
Returns a new instance of TarGz.
13 14 15 16 17 18 19 20 21 |
# File 'lib/falkor/extract/tar_gz.rb', line 13 def initialize(file_name, has_root_dir: false) @file_name = file_name @extraction_destination = if has_root_dir File.dirname(file_name) else source_destination end end |
Instance Method Details
#extract ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/falkor/extract/tar_gz.rb', line 23 def extract return source_destination if Dir.exist? source_destination FileUtils.mkdir_p extraction_destination block = block_given? ? Proc.new : proc {} report_progress(:write_each_tarfile, open_file(&:count), &block) FileUtils.rm file_name source_destination end |