Add savage tool

This commit is contained in:
Wilfried OLLIVIER 2021-08-05 14:23:30 +02:00
parent 068e19bacf
commit 90ed96d524
2 changed files with 22 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
out

21
savage.rb Normal file
View File

@ -0,0 +1,21 @@
require 'optparse'
options = { input: 'input', output: 'out', tracks: 40, generate: 0 }
OptionParser.new do |opts|
opts.banner = 'savage blind test generator'
opts.on('-i', '--input=FOLDER', 'select input folder') do |i|
options[:input] = i
end
end.parse!
entries = []
Dir["#{options[:input]}/*.csv"].each do |path|
entries.concat(File.readlines(path).select { |l| !l.start_with?('#') && !l.start_with?('!') })
end
entries.shuffle!
(0..options[:generate]).each do |index|
File.open("#{options[:output]}/#{index}.csv", 'w') { |f| f.write(entries.sample(options[:tracks]).join('')) }
end