Skip to content

Instantly share code, notes, and snippets.

@brianstorti
Created August 22, 2011 16:00
Show Gist options
  • Save brianstorti/1162756 to your computer and use it in GitHub Desktop.
Save brianstorti/1162756 to your computer and use it in GitHub Desktop.
Generate monkey code
require 'rubygems'
require 'spreadsheet'
TEMPLATE = "template.xls"
LOCAL_FILE_NAME = "generated.txt"
Spreadsheet.client_encoding = 'UTF-8'
def inspect_sheet sheet
File.open(LOCAL_FILE_NAME, 'w') {|f|
sheet.each do |row|
if true
type = "TextVariableField"
end
line = "lineLayout.addField(new #{type}('IDC-REG', #{row[2]}));"
f.puts(line)
end
}
end
template = Spreadsheet.open TEMPLATE
sheet = template.worksheet 0
inspect_sheet(sheet)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment