diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1fcb152 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +out diff --git a/savage.rb b/savage.rb new file mode 100644 index 0000000..05c3e8e --- /dev/null +++ b/savage.rb @@ -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