Class: MetaBuild::Extractor::BaseExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/meta_build/extractor/base_extractor.rb

Direct Known Subclasses

EarExtractor, JarExtractor, WarExtractor

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ BaseExtractor

Returns a new instance of BaseExtractor.



9
10
11
12
13
14
# File 'lib/meta_build/extractor/base_extractor.rb', line 9

def initialize(options = {})
  @parent = options[:parent]
  @file = File.absolute_path options[:file]

  @artifact = File.basename @file.sub /\.(ear|war|jar)\z/, ''
end

Instance Attribute Details

#artifactObject (readonly)

Returns the value of attribute artifact.



7
8
9
# File 'lib/meta_build/extractor/base_extractor.rb', line 7

def artifact
  @artifact
end

#fileObject

Returns the value of attribute file.



6
7
8
# File 'lib/meta_build/extractor/base_extractor.rb', line 6

def file
  @file
end

#parentObject

Returns the value of attribute parent.



6
7
8
# File 'lib/meta_build/extractor/base_extractor.rb', line 6

def parent
  @parent
end

Instance Method Details

#create_tmp_dirObject



24
25
26
# File 'lib/meta_build/extractor/base_extractor.rb', line 24

def create_tmp_dir
  FileUtils.mkdir_p tmp_dir unless File.exist? tmp_dir
end

#extractObject



16
17
18
# File 'lib/meta_build/extractor/base_extractor.rb', line 16

def extract
  raise MetaBuild::Exceptions::MetaBuildException.new "#{self.class}.extract must be overridden."
end

#tmp_dirObject



20
21
22
# File 'lib/meta_build/extractor/base_extractor.rb', line 20

def tmp_dir
  @temp ||= File.join Dir.tmpdir, 'meta-build', 'artifacts', @parent.to_s, @artifact
end