Class: Avm::Data::Package
- Inherits:
-
Object
- Object
- Avm::Data::Package
show all
- Includes:
- Callbacks
- Defined in:
- lib/avm/data/package.rb,
lib/avm/data/package/dump.rb,
lib/avm/data/package/load.rb,
lib/avm/data/package/clear.rb,
lib/avm/data/package/base_performer.rb,
lib/avm/data/package/build_directory.rb
Defined Under Namespace
Modules: BuildDirectory
Classes: BasePerformer, Clear, Dump, Load
Constant Summary
collapse
- DATA_FILE_EXTENSION =
'.tar'
Instance Method Summary
collapse
Constructor Details
#initialize(options) ⇒ Package
Returns a new instance of Package.
14
15
16
17
18
19
20
21
|
# File 'lib/avm/data/package.rb', line 14
def initialize(options)
options = options.to_options_consumer
units = options.consume(:units)
options.validate
units.if_present do |v|
v.each { |identifier, unit| add_unit(identifier, unit) }
end
end
|
Instance Method Details
24
25
26
27
28
|
# File 'lib/avm/data/package.rb', line 24
def add_unit(identifier, unit)
units[identifier.to_sym] = unit
self
end
|
#data_file_extension ⇒ String
31
32
33
|
# File 'lib/avm/data/package.rb', line 31
def data_file_extension
DATA_FILE_EXTENSION
end
|
#dump_units_to_directory(directory, selected_units = nil) ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/avm/data/package.rb', line 35
def dump_units_to_directory(directory, selected_units = nil)
run_callbacks :dump do
(selected_units || units).each do |identifier, unit|
unit.dump_to_directory(directory, identifier)
end
end
end
|
#load_units_from_directory(directory, selected_units = nil) ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/avm/data/package.rb', line 43
def load_units_from_directory(directory, selected_units = nil)
run_callbacks :load do
(selected_units || units).each do |identifier, unit|
unit.load_from_directory(directory, identifier)
end
end
end
|
53
54
55
|
# File 'lib/avm/data/package.rb', line 53
def unit(identifier)
units[identifier.to_sym] || raise("No unit found with identifier \"#{identifier}\"")
end
|
#units ⇒ Object
57
58
59
|
# File 'lib/avm/data/package.rb', line 57
def units
@units ||= {}
end
|
#units_ids ⇒ Enumerable<String>
62
63
64
|
# File 'lib/avm/data/package.rb', line 62
def units_ids
units.keys
end
|