added missing line endings (-l) support for windows and solaris
This commit is contained in:
parent
ee552804c2
commit
41d8273dfe
1 changed files with 14 additions and 2 deletions
16
files/concatfragments.rb
Executable file → Normal file
16
files/concatfragments.rb
Executable file → Normal 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
|
||||
|
|
Loading…
Reference in a new issue