Class: RdiffBackupWrapper::Backup
- Inherits:
-
Object
- Object
- RdiffBackupWrapper::Backup
- Defined in:
- lib/rdiff_backup_wrapper/backup.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #cmd ⇒ Object
- #destination ⇒ Object
- #ensure_slash_end(key) ⇒ Object
-
#initialize(config) ⇒ Backup
constructor
A new instance of Backup.
- #run ⇒ Object
- #source ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(config) ⇒ Backup
5 6 7 |
# File 'lib/rdiff_backup_wrapper/backup.rb', line 5 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
3 4 5 |
# File 'lib/rdiff_backup_wrapper/backup.rb', line 3 def config @config end |
Instance Method Details
#cmd ⇒ Object
35 36 37 |
# File 'lib/rdiff_backup_wrapper/backup.rb', line 35 def cmd ['rdiff-backup', source, destination] end |
#destination ⇒ Object
13 14 15 |
# File 'lib/rdiff_backup_wrapper/backup.rb', line 13 def destination ensure_slash_end('destination') end |
#ensure_slash_end(key) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/rdiff_backup_wrapper/backup.rb', line 17 def ensure_slash_end(key) if config[key].end_with? '/' return config[key] end config[key] + '/' end |
#run ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rdiff_backup_wrapper/backup.rb', line 24 def run command = [ 'nice', 'ionice', '-c', '3', ] + cmd Open3.popen3(command) do |i,o,e,t| p o.read p e.read end end |
#source ⇒ Object
9 10 11 |
# File 'lib/rdiff_backup_wrapper/backup.rb', line 9 def source ensure_slash_end('source') end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/rdiff_backup_wrapper/backup.rb', line 39 def to_s "<Backup name=#{config['name']}>" end |