Skip to content

Commit

Permalink
Currently sorting by numeric and the ruby file is not supported, this…
Browse files Browse the repository at this point in the history
… fixes that
  • Loading branch information
Travis Fields committed Feb 11, 2015
1 parent 7bc211c commit b9b13d2
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions files/concatfragments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
require 'fileutils'

settings = {
:outfile => "",
:workdir => "",
:test => false,
:force => false,
:warn => "",
:sortarg => "",
:newline => false
:outfile => "",
:workdir => "",
:test => false,
:force => false,
:warn => "",
:sortarg => "",
:newline => false
}

OptionParser.new do |opts|
Expand Down Expand Up @@ -116,15 +116,18 @@
Dir.chdir(settings[:workdir])

if settings[:warn].empty?
File.open("fragments.concat", 'w') {|f| f.write("") }
File.open("fragments.concat", 'w') { |f| f.write("") }
else
File.open("fragments.concat", 'w') {|f| f.write("#{settings[:warn]}\n") }
File.open("fragments.concat", 'w') { |f| f.write("#{settings[:warn]}\n") }
end

# 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|
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))
f << File.read(File.join("fragments", entry))

Expand Down

0 comments on commit b9b13d2

Please sign in to comment.