class Kellerkind::Compress
Public: Compresses a mongodb dump directory by using Gzip and tar.
Public Instance Methods
find_at_source_path()
click to toggle source
Public: Duplicate some text an arbitrary number of times.
Returns the duplicated String.
# File lib/kellerkind/system/compress.rb, line 23 def find_at_source_path @find_at_source_path ||= false end
find_at_source_path=(flag)
click to toggle source
Public: Duplicate some text an arbitrary number of times.
flag -
Returns the duplicated String.
# File lib/kellerkind/system/compress.rb, line 32 def find_at_source_path=(flag) @find_at_source_path = flag end
gzip()
click to toggle source
Public: Initialises compressing of the dumps directory.
# File lib/kellerkind/system/compress.rb, line 37 def gzip traverse_and_gzip end
succeeded?()
click to toggle source
Public: Checks if tar file exists.
If tar file exists we assume compressing succeeds
Returns true if file exists otherwise false.
# File lib/kellerkind/system/compress.rb, line 46 def succeeded? File.exists?(File.join(self.target_path, @actual_tar_name)) end
tarball_name()
click to toggle source
# File lib/kellerkind/system/compress.rb, line 50 def tarball_name "#{self.tarball_prefix}_#{Time.now.to_i}.tar.gz" end
Private Instance Methods
db_dump_gz_file()
click to toggle source
# File lib/kellerkind/system/compress.rb, line 63 def db_dump_gz_file File.open(tar_location, 'wb') end
define_lookup_path()
click to toggle source
# File lib/kellerkind/system/compress.rb, line 72 def define_lookup_path if find_at_source_path if File.directory?(self.source_path) self.source_path else File.dirname(self.source_path) end else self.target_path end end
tar_location()
click to toggle source
# File lib/kellerkind/system/compress.rb, line 67 def tar_location @actual_tar_name = tarball_name File.join(define_lookup_path, @actual_tar_name) end
traverse_and_gzip()
click to toggle source
# File lib/kellerkind/system/compress.rb, line 56 def traverse_and_gzip Find.find(self.source_path).each do |file| tgz = Zlib::GzipWriter.new(db_dump_gz_file) Minitar.pack(file, tgz) end end