Merge pull request #205 from GeoffWilliams/windows_case_fix

added missing line endings (-l) support for windows and solaris
This commit is contained in:
Morgan Haskel 2014-09-11 11:33:01 -04:00
commit 84551cc4ec

16
files/concatfragments.rb Executable file → Normal file
View file

@ -45,7 +45,8 @@ settings = {
:test => false,
:force => false,
:warn => "",
:sortarg => ""
:sortarg => "",
:newline => false
}
OptionParser.new do |opts|
@ -77,6 +78,10 @@ OptionParser.new do |opts|
opts.on("-n", "--sort", "Sort the output numerically rather than the default alpha sort") do
settings[:sortarg] = "-n"
end
opts.on("-l", "--line", "Append a newline") do
settings[:newline] = true
end
end.parse!
# do we have -o?
@ -119,8 +124,15 @@ 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|
if File.file?(File.join("fragments", entry))
f << File.read(File.join("fragments", entry))
f << File.read(File.join("fragments", entry))
# append a newline if we were asked to (invoked with -l)
if settings[:newline]
f << "\n"
end
end
}
end