Class: Lzop

Inherits:
Rehabilitate::Plugin show all
Defined in:
lib/rehabilitate/plugins/lzop.rb

Instance Method Summary collapse

Methods inherited from Rehabilitate::Plugin

derivative_dirs, #log

Instance Method Details

#compress(options) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/rehabilitate/plugins/lzop.rb', line 4

def compress(options)
  options._backup_files.collect! do |backup_file|
    new_backup_name = "#{backup_file}.tar.lzop"
    log "Compressing files..."
    log "cd #{options.tmp} && tar --use-compress-program=lzop -cf #{new_backup_name} #{backup_file.split("/").last}"
    log %x[cd #{options.tmp} && tar --use-compress-program=lzop -cf #{new_backup_name} #{backup_file.split("/").last}]
    options._tmp_files << new_backup_name
    new_backup_name
  end
end

#uncompress(options) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/rehabilitate/plugins/lzop.rb', line 15

def uncompress(options)
  options._backup_files.collect! do |backup_file|
    new_backup_name = "#{options.tmp}/#{File.basename(backup_file).gsub(".tar.lzop", "")}"
    log "Uncompressing files to #{options.tmp}"
    log %{ cd #{options.tmp} && lzop -dq < #{options._backup_files.first} | tar -xvf - }
    log %x{ cd #{options.tmp} && lzop -dq < #{options._backup_files.first} | tar -xvf - }
    options._tmp_files << new_backup_name
    new_backup_name
  end
end