Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 30 lines (28 sloc) 0.84 kB
def split(file_path, dest_dir, allowed_length = 5000000)
p = Pathname.new(file_path)
temp_line = ''
full_line = ''
i = 0
dest_filename_arr = []
p.each_line do |line|
temp_line += line
if line.match(/^--------\n$/)
if ((full_line.length + temp_line.length) < allowed_length)
full_line += temp_line
temp_line = ''
else
((full_line.length + temp_line.length) > allowed_length)
if full_line == ''
full_line = temp_line
temp_line = ''
end
File.open("#{dest_dir}/#{$split_filename}_#{i}", 'w') {|f| f.write(full_line) }
dest_filename_arr << "#{$split_filename}_#{i}"
full_line = ''
i += 1
end
end
end
File.open("#{dest_dir}/#{$split_filename}_#{i}", 'w') {|f| f.write(full_line) }
dest_filename_arr << "#{$split_filename}_#{i}"
end
Jump to Line
Something went wrong with that request. Please try again.