Class: Monsoon::Compress

Inherits:
Object
  • Object
show all
Defined in:
lib/monsoon/compress.rb

Instance Method Summary collapse

Constructor Details

#initialize(backup) ⇒ Compress

Returns a new instance of Compress.



6
7
8
# File 'lib/monsoon/compress.rb', line 6

def initialize(backup)
  @backup = backup
end

Instance Method Details

#cleanObject

Helper to delete the backup file once finished.

Examples

Monsoon::Compress(#<Monsoon::Backup>).clean
# => "app_development_1234.tar.gz"

Returns results of the command.



55
56
57
# File 'lib/monsoon/compress.rb', line 55

def clean
  FileUtils.rm filename, force: true
end

#compress_commandObject

Helper to form the tar compress command.

Examples

Monsoon::Compress(#<Monsoon::Backup>).compress_command
# => "tar -czf app_development_1234.tar.gz dump/app_development"

Returns the command as a String.



31
32
33
# File 'lib/monsoon/compress.rb', line 31

def compress_command
  "tar -czf #{filename} #{@backup.database}"
end

#filenameObject

Helper to form the tar compress command.

Examples

Monsoon::Compress(#<Monsoon::Backup>).filename
# => "app_development_1234.tar.gz"

Returns the filename as a String.



43
44
45
# File 'lib/monsoon/compress.rb', line 43

def filename
  @filename ||= "#{@backup.database}_#{Time.now.strftime('%Y%m%d_%H%M%S')}.tar.gz"
end

#runObject

Run the Monsoon Compress process.

Examples

Monsoon::Compress(#<Monsoon::Backup>).run
# => #<Monsoon::Compress>

Returns an instance of the Monsoon::Compress class



18
19
20
21
# File 'lib/monsoon/compress.rb', line 18

def run
  Kernel.system "#{compress_command}"
  self
end