Created
July 13, 2010 21:27
-
-
Save royratcliffe/474564 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'optparse' | |
require 'ostruct' | |
options = OpenStruct.new | |
options.rows = 10 | |
options.columns = 10 | |
OptionParser.new do |opts| | |
opts.on('-r', '--rows [INTEGER]', 'Number of rows', Integer) do |x| | |
options.rows = x | |
end | |
opts.on('-c', '--columns [INTEGER]', 'Number of columns', Integer) do |x| | |
options.columns = x | |
end | |
end.parse! | |
require 'rubygems' | |
require 'fastercsv' | |
require 'webster' | |
webster = Webster.new | |
ARGV << '/dev/stdout' if ARGV.empty? | |
ARGV.each do |file_name| | |
FasterCSV.open(file_name, 'w') do |csv| | |
options.rows.times do |row_index| | |
row = [] | |
options.columns.times do |column_index| | |
row << webster.random_word | |
end | |
csv << row | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment