Class: Splitter

Inherits:
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 Plugin

derivative_dirs, #log

Instance Method Details

#join(files) ⇒ Object



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

def join(files)
  log %[ cat #{files.join(" ")} > #{files[0].split("-")[0..-2].join("-")} ]
  log %x[ cat #{files.join(" ")} > #{files[0].split("-")[0..-2].join("-")} ]
  files[0].split("-")[0..-2].join("-")
end

#split(file, options) ⇒ Object



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

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}- }
  Dir.glob("#{file}-??")
end