Currently sorting by numeric and the ruby file is not supported, this fixes that
This commit is contained in:
parent
7bc211ceba
commit
b9b13d2806
1 changed files with 14 additions and 11 deletions
|
@ -40,13 +40,13 @@ require 'optparse'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
|
|
||||||
settings = {
|
settings = {
|
||||||
:outfile => "",
|
:outfile => "",
|
||||||
:workdir => "",
|
:workdir => "",
|
||||||
:test => false,
|
:test => false,
|
||||||
:force => false,
|
:force => false,
|
||||||
:warn => "",
|
:warn => "",
|
||||||
:sortarg => "",
|
:sortarg => "",
|
||||||
:newline => false
|
:newline => false
|
||||||
}
|
}
|
||||||
|
|
||||||
OptionParser.new do |opts|
|
OptionParser.new do |opts|
|
||||||
|
@ -116,15 +116,18 @@ end
|
||||||
Dir.chdir(settings[:workdir])
|
Dir.chdir(settings[:workdir])
|
||||||
|
|
||||||
if settings[:warn].empty?
|
if settings[:warn].empty?
|
||||||
File.open("fragments.concat", 'w') {|f| f.write("") }
|
File.open("fragments.concat", 'w') { |f| f.write("") }
|
||||||
else
|
else
|
||||||
File.open("fragments.concat", 'w') {|f| f.write("#{settings[:warn]}\n") }
|
File.open("fragments.concat", 'w') { |f| f.write("#{settings[:warn]}\n") }
|
||||||
end
|
end
|
||||||
|
|
||||||
# find all the files in the fragments directory, sort them numerically and concat to fragments.concat in the working dir
|
# find all the files in the fragments directory, sort them numerically and concat to fragments.concat in the working dir
|
||||||
open('fragments.concat', 'a') do |f|
|
open('fragments.concat', 'a') do |f|
|
||||||
Dir.entries("fragments").sort.each{ |entry|
|
fragments = Dir.entries("fragments").sort
|
||||||
|
if settings[:sortarg] == '-n'
|
||||||
|
fragments = fragments.sort_by { |v| v.split('_').map(&:to_i) }
|
||||||
|
end
|
||||||
|
fragments.each { |entry|
|
||||||
if File.file?(File.join("fragments", entry))
|
if File.file?(File.join("fragments", entry))
|
||||||
f << File.read(File.join("fragments", entry))
|
f << File.read(File.join("fragments", entry))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue