Class: Backup::Splitter

Inherits:
Object
  • Object
show all
Includes:
Utilities::Helpers
Defined in:
lib/backup/splitter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, chunk_size, suffix_length) ⇒ Splitter

Returns a new instance of Splitter.



9
10
11
12
13
# File 'lib/backup/splitter.rb', line 9

def initialize(model, chunk_size, suffix_length)
  @package = model.package
  @chunk_size = chunk_size
  @suffix_length = suffix_length
end

Instance Attribute Details

#chunk_sizeObject (readonly)

Returns the value of attribute chunk_size.



7
8
9
# File 'lib/backup/splitter.rb', line 7

def chunk_size
  @chunk_size
end

#packageObject (readonly)

Returns the value of attribute package.



7
8
9
# File 'lib/backup/splitter.rb', line 7

def package
  @package
end

#suffix_lengthObject (readonly)

Returns the value of attribute suffix_length.



7
8
9
# File 'lib/backup/splitter.rb', line 7

def suffix_length
  @suffix_length
end

Instance Method Details

#split_with {|split_command| ... } ⇒ Object

This is called as part of the procedure used to build the final backup package file(s). It yields it’s portion of the command line for this procedure, which will split the data being piped into it into multiple files, based on the @chunk_size, using a suffix length as specified by @suffix_length. Once the packaging procedure is complete, it will return and

Yields:

  • (split_command)


23
24
25
26
27
28
# File 'lib/backup/splitter.rb', line 23

def split_with
  Logger.info "Splitter configured with a chunk size of #{ chunk_size }MB " +
              "and suffix length of #{ suffix_length }."
  yield split_command
  after_packaging
end