Class: Gonzui::AbstractExtractor

Inherits:
Object
  • Object
show all
Includes:
TemporaryDirectoryUtil, Util
Defined in:
lib/gonzui/extractor.rb

Instance Attribute Summary

Attributes included from TemporaryDirectoryUtil

#temporary_directory

Instance Method Summary collapse

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.

Raises:



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

#cleanObject



158
159
160
# File 'lib/gonzui/extractor.rb', line 158

def clean
  clean_temporary_directory
end

#extractObject



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.fix_permission(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