Class: Gonzui::AbstractExtractor
- Inherits:
-
Object
- Object
- Gonzui::AbstractExtractor
- Includes:
- TemporaryDirectoryUtil, Util
- Defined in:
- lib/gonzui/extractor.rb
Direct Known Subclasses
LZHExtractor, SRPMExtractor, TarBzip2Extractor, TarCompressExtractor, TarExtractor, TarGzipExtractor, ZipExtractor
Instance Attribute Summary
Attributes included from TemporaryDirectoryUtil
Instance Method Summary collapse
- #clean ⇒ Object
- #extract ⇒ Object
-
#initialize(config, file_name) ⇒ AbstractExtractor
constructor
A new instance of AbstractExtractor.
Methods included from TemporaryDirectoryUtil
#clean_temporary_directory, #prepare_temporary_directory, #set_temporary_directory
Methods included from Util
assert, assert_equal, assert_equal_all, assert_non_nil, assert_not_reached, benchmark, command_exist?, commify, eprintf, format_bytes, program_name, protect_from_signals, require_command, set_verbosity, shell_escape, unix?, vprintf, windows?, wprintf
Constructor Details
#initialize(config, file_name) ⇒ AbstractExtractor
Returns a new instance of AbstractExtractor.
69 70 71 72 73 74 75 76 77 |
# File 'lib/gonzui/extractor.rb', line 69 def initialize(config, file_name) @config = config @archive_directory = nil @file_name = file_name @extracted_files = [] raise ExtractorError.new("#{@file_name}: no such file") unless File.file?(@file_name) set_temporary_directory(config.temporary_directory) end |
Instance Method Details
#clean ⇒ Object
158 159 160 |
# File 'lib/gonzui/extractor.rb', line 158 def clean clean_temporary_directory end |
#extract ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/gonzui/extractor.rb', line 144 def extract prepare_temporary_directory begin do_extract FileUtils.(self.temporary_directory) raise_error_if_empty_archive? arrange_extracted_files return get_archive_directory rescue ExtractorError => e clean_temporary_directory raise(e) end end |