#!/usr/bin/ruby

$:.unshift( "../lib" )
require "xml/script"

if ARGV.size < 2 
  puts "usage: ruby test.rb <language> <file.xml>"
  exit
end

xLang = ARGV[0]
xFile = ARGV[1]
xData = IO::readlines( xFile )

rubyp = Proc.new{ |xCode|
  xCodePreCode = "<%\n## Example with pre-compilation proc\n"
  xCodePreCode = xCodePreCode + "## blah blah blah !!!\n%>\n"
  xCodePreCode + xCode
}

if xLang == "ruby"
  o = XML::Script::new( "language" => xLang, "precompile" => rubyp )
else
  o = XML::Script::new( "language" => xLang )
end
puts "GENERATED CODE -------------------------------"
puts o.script( xData )
puts "COMPILED CODE --------------------------------"
puts o.compile( )
