Class: Monsoon::Compress
- Inherits:
-
Object
- Object
- Monsoon::Compress
- Defined in:
- lib/monsoon/compress.rb
Instance Method Summary collapse
-
#clean ⇒ Object
Helper to delete the backup file once finished.
-
#compress_command ⇒ Object
Helper to form the tar compress command.
-
#filename ⇒ Object
Helper to form the tar compress command.
-
#initialize(backup) ⇒ Compress
constructor
A new instance of Compress.
-
#run ⇒ Object
Run the Monsoon Compress process.
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
#clean ⇒ Object
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_command ⇒ Object
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 |
#filename ⇒ Object
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 |
#run ⇒ Object
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 |