Class: SolrWrapper::TgzExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/solr_wrapper/tgz_extractor.rb

Constant Summary collapse

'././@LongLink'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, destination: nil) ⇒ TgzExtractor

Returns a new instance of TgzExtractor.



10
11
12
13
# File 'lib/solr_wrapper/tgz_extractor.rb', line 10

def initialize(file, destination: nil)
  @file = file
  @destination = destination || Dir.mktmpdir
end

Instance Attribute Details

#destinationObject (readonly)

Returns the value of attribute destination.



6
7
8
# File 'lib/solr_wrapper/tgz_extractor.rb', line 6

def destination
  @destination
end

#fileObject (readonly)

Returns the value of attribute file.



6
7
8
# File 'lib/solr_wrapper/tgz_extractor.rb', line 6

def file
  @file
end

Instance Method Details

#extract!Object



15
16
17
18
19
# File 'lib/solr_wrapper/tgz_extractor.rb', line 15

def extract!
  Minitar.unpack(Zlib::GzipReader.open(file), destination)
rescue StandardError => e
  abort "Unable to extract #{file} into #{destination}: #{e.message}"
end