Class: BackItUp::FilePackager

Inherits:
Object
  • Object
show all
Defined in:
lib/back_it_up/file_packager.rb

Constant Summary collapse

INVALID_CONFIG_MSG =
"Invalid config"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ FilePackager

Returns a new instance of FilePackager.

Raises:



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_fileObject (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

#packageObject



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