Class: Avm::Data::Package::Load

Inherits:
Object
  • Object
show all
Defined in:
lib/avm/data/package/load.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(package, data_file_path) ⇒ Load

Returns a new instance of Load.



14
15
16
17
# File 'lib/avm/data/package/load.rb', line 14

def initialize(package, data_file_path)
  @package = package
  @data_file_path = data_file_path
end

Instance Attribute Details

#data_file_pathObject (readonly)

Returns the value of attribute data_file_path.



12
13
14
# File 'lib/avm/data/package/load.rb', line 12

def data_file_path
  @data_file_path
end

#packageObject (readonly)

Returns the value of attribute package.



12
13
14
# File 'lib/avm/data/package/load.rb', line 12

def package
  @package
end

Instance Method Details

#cannot_run_reasonObject



23
24
25
26
27
# File 'lib/avm/data/package/load.rb', line 23

def cannot_run_reason
  return nil if data_file_exist?

  "Data file \"#{data_file_path}\" does not exist"
end

#data_file_exist?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/avm/data/package/load.rb', line 36

def data_file_exist?
  ::File.exist?(data_file_path)
end

#extract_packages_to_build_directoryObject



40
41
42
43
44
# File 'lib/avm/data/package/load.rb', line 40

def extract_packages_to_build_directory
  dir = ::Dir.mktmpdir
  ::Minitar.unpack(data_file_path, dir)
  dir
end

#runObject



29
30
31
32
33
34
# File 'lib/avm/data/package/load.rb', line 29

def run
  raise "Cannot run: #{cannot_run_reason}" unless runnable?

  build_dir = extract_packages_to_build_directory
  package.load_units_from_directory(build_dir)
end

#runnable?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/avm/data/package/load.rb', line 19

def runnable?
  cannot_run_reason.blank?
end