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
Returns a new instance of Backup.
7 8 9 |
# File 'lib/rdiff_backup_wrapper/backup.rb', line 7 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/rdiff_backup_wrapper/backup.rb', line 5 def config @config end |
Instance Method Details
#cmd ⇒ Object
43 44 45 |
# File 'lib/rdiff_backup_wrapper/backup.rb', line 43 def cmd ['rdiff-backup', source, destination] end |
#destination ⇒ Object
15 16 17 |
# File 'lib/rdiff_backup_wrapper/backup.rb', line 15 def destination ensure_slash_end('destination') end |
#ensure_slash_end(key) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/rdiff_backup_wrapper/backup.rb', line 19 def ensure_slash_end(key) if config[key].end_with? '/' return config[key] end config[key] + '/' end |
#run ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rdiff_backup_wrapper/backup.rb', line 26 def run output = {} command = [ 'nice', 'ionice', '-c', '3', ] + cmd Open3.popen3(*command) do |i,o,e,t| output[:name] = config['name'] output[:stdout] = o.read output[:stderr] = e.read output[:retval] = t.value end output end |
#source ⇒ Object
11 12 13 |
# File 'lib/rdiff_backup_wrapper/backup.rb', line 11 def source ensure_slash_end('source') end |
#to_s ⇒ Object
47 48 49 |
# File 'lib/rdiff_backup_wrapper/backup.rb', line 47 def to_s "<Backup name=#{config['name']}>" end |