Class: Splitter

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

Constant Summary collapse

MAX_FILE_SIZE =

4.5TB

(4.5*1024*1024*1024*1024*10).to_i

Instance Method Summary collapse

Methods inherited from Rehabilitate::Plugin

derivative_dirs, #log

Instance Method Details

#join(files) ⇒ Object



6
7
8
9
10
11
# File 'lib/rehabilitate/plugins/splitter.rb', line 6

def join(files)
  base_file = files.first.match(/(.*)-.*/)[1]
  log %[ cat #{base_file}-[aa-zz] > #{base_file} ]
  log %x[ cat #{base_file}-[aa-zz] > #{base_file} ]
  base_file
end

#split(file, options) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/rehabilitate/plugins/splitter.rb', line 13

def split(file, options)
  log "Splitting file (#{file})"
  split_size = options.split_size || MAX_FILE_SIZE
  log "  => #{split_size} byte pieces"

  log %x{ split -b #{split_size} #{file} #{file}- }
  split_files = Dir.glob("#{file}-??")
  options._tmp_files << split_files
  split_files
end