Class: BackItUp::Config
- Inherits:
-
Object
- Object
- BackItUp::Config
- Defined in:
- lib/back_it_up/config.rb
Instance Attribute Summary collapse
-
#dest_filename ⇒ Object
readonly
Returns the value of attribute dest_filename.
-
#dirs ⇒ Object
readonly
Returns the value of attribute dirs.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
- #backup ⇒ Object
-
#destination_file(filename) ⇒ Object
Full path and name of the package file to create.
- #file(filename = nil) ⇒ Object (also: #dir)
-
#initialize(file_handle) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(file_handle) ⇒ Config
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/back_it_up/config.rb', line 5 def initialize(file_handle) @files = [] @dirs = [] file_content = "" while l = file_handle.gets do file_content << l end eval(file_content) end |
Instance Attribute Details
#dest_filename ⇒ Object (readonly)
Returns the value of attribute dest_filename.
3 4 5 |
# File 'lib/back_it_up/config.rb', line 3 def dest_filename @dest_filename end |
#dirs ⇒ Object (readonly)
Returns the value of attribute dirs.
3 4 5 |
# File 'lib/back_it_up/config.rb', line 3 def dirs @dirs end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
3 4 5 |
# File 'lib/back_it_up/config.rb', line 3 def files @files end |
Instance Method Details
#backup ⇒ Object
18 19 20 |
# File 'lib/back_it_up/config.rb', line 18 def backup yield end |
#destination_file(filename) ⇒ Object
Full path and name of the package file to create. A timestamp will be appended to the filename and the extension is determined by the packager used.
# Using the zip packager with a destination file setting:
/var/backup/mybackup
# ...then the final result might be:
/var/backup/mybackup_200900527_053032.zip
31 32 33 34 |
# File 'lib/back_it_up/config.rb', line 31 def destination_file(filename) raise "Invalid destination file." if File.directory?(filename) @dest_filename = filename end |
#file(filename = nil) ⇒ Object Also known as: dir
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/back_it_up/config.rb', line 36 def file(filename = nil) unless (filename == "" || filename == nil) if File.exists?(filename) if File.directory? filename @dirs << filename else @files << filename end else puts "WARNING: File #{filename} could not be found" end end end |