Class: BackItUp::FilePackager
- Inherits:
-
Object
- Object
- BackItUp::FilePackager
- Defined in:
- lib/back_it_up/file_packager.rb
Constant Summary collapse
- INVALID_CONFIG_MSG =
"Invalid config"
Instance Attribute Summary collapse
-
#produced_file ⇒ Object
readonly
Returns the value of attribute produced_file.
Instance Method Summary collapse
-
#initialize(config) ⇒ FilePackager
constructor
A new instance of FilePackager.
- #package ⇒ Object
Constructor Details
#initialize(config) ⇒ FilePackager
Returns a new instance of FilePackager.
9 10 11 12 |
# File 'lib/back_it_up/file_packager.rb', line 9 def initialize(config) raise INVALID_CONFIG_MSG if config == nil || !config.is_a?(Config) @config = config end |
Instance Attribute Details
#produced_file ⇒ Object (readonly)
Returns the value of attribute produced_file.
7 8 9 |
# File 'lib/back_it_up/file_packager.rb', line 7 def produced_file @produced_file end |
Instance Method Details
#package ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/back_it_up/file_packager.rb', line 14 def package Zip::ZipFile.open(target_filename, Zip::ZipFile::CREATE) do |zip| @config.each_file { |filename| zip.add( zip_entry_name(filename), filename ) } end @produced_file = target_filename end |