["@Server", "@ASPGLOBALTLB", "@Request", "@Application", "@Session", "@_asr_default_object", "@Response", "@ObjectContext"]

--------------------------------------------------------------------------------
Calling a Ruby function
--------------------------------------------------------------------------------
Hello World

--------------------------------------------------------------------------------
Ruby Version
--------------------------------------------------------------------------------
1.8.7

--------------------------------------------------------------------------------
Calling a Ruby class
--------------------------------------------------------------------------------
Hi ASPer!
Bye ASPer, come back soon.

--------------------------------------------------------------------------------
Calling an ActiveX component
--------------------------------------------------------------------------------
Fabio Zendhi Nagao
nagaozen

--------------------------------------------------------------------------------
Calling ASP objects
--------------------------------------------------------------------------------
BUG: It's odd, while you can retrive Session values, you cannot set them.
This is mostly because of the syntax conflict Session(key) = value which seems
to Ruby that you are assigning a value to the return of a function.



{ALL_HTTP:HTTP_ACCEPT:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_ACCEPT_ENCODING:x-gzip, gzip, deflate
HTTP_HOST:evolved.com.br
HTTP_USER_AGENT:CCBot/2.0 (http://commoncrawl.org/faq/)
HTTP_X_FORWARDED_PROTO:https
HTTP_X_FORWARDED_FOR:23.22.136.56
,ALL_RAW:Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: x-gzip, gzip, deflate
Host: evolved.com.br
User-Agent: CCBot/2.0 (http://commoncrawl.org/faq/)
X-Forwarded-Proto: https
X-Forwarded-For: 23.22.136.56
,APPL_MD_PATH:/LM/W3SVC/873784055/Root,APPL_PHYSICAL_PATH:C:\var\www\unittest.evolved.com.br\,AUTH_PASSWORD:,AUTH_TYPE:,AUTH_USER:,CERT_COOKIE:,CERT_FLAGS:,CERT_ISSUER:,CERT_KEYSIZE:,CERT_SECRETKEYSIZE:,CERT_SERIALNUMBER:,CERT_SERVER_ISSUER:,CERT_SERVER_SUBJECT:,CERT_SUBJECT:,CONTENT_LENGTH:0,CONTENT_TYPE:,GATEWAY_INTERFACE:CGI/1.1,HTTPS:off,HTTPS_KEYSIZE:,HTTPS_SECRETKEYSIZE:,HTTPS_SERVER_ISSUER:,HTTPS_SERVER_SUBJECT:,INSTANCE_ID:873784055,INSTANCE_META_PATH:/LM/W3SVC/873784055,LOCAL_ADDR:192.168.5.20,LOGON_USER:,PATH_INFO:/ruby.lang.asp,PATH_TRANSLATED:C:\var\www\unittest.evolved.com.br\ruby.lang.asp,QUERY_STRING:,REMOTE_ADDR:192.168.5.19,REMOTE_HOST:192.168.5.19,REMOTE_USER:,REQUEST_METHOD:GET,SCRIPT_NAME:/ruby.lang.asp,SERVER_NAME:evolved.com.br,SERVER_PORT:80,SERVER_PORT_SECURE:0,SERVER_PROTOCOL:HTTP/1.0,SERVER_SOFTWARE:Microsoft-IIS/6.0,URL:/ruby.lang.asp,HTTP_ACCEPT:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8,HTTP_ACCEPT_ENCODING:x-gzip, gzip, deflate,HTTP_HOST:evolved.com.br,HTTP_USER_AGENT:CCBot/2.0 (http://commoncrawl.org/faq/),HTTP_X_FORWARDED_PROTO:https,HTTP_X_FORWARDED_FOR:23.22.136.56,}

--------------------------------------------------------------------------------
Calling RubyGem (gem install htmlentities, gem install sass)
--------------------------------------------------------------------------------
<élan>

#main {
  background-color: #0000ff; }


--------------------------------------------------------------------------------
This source
--------------------------------------------------------------------------------
<%@
	language = "RubyScript"
	codepage = 65001
	lcid     = 1033
%><pre><%

require 'rubygems'
require 'htmlentities'
require 'sass'

Response.Write instance_variables.inspect
Response.Write "\n\n"

def read_text_file(path)
	s = WIN32OLE.new("ADODB.Stream")
	s.type = 2
	s.mode = 3
	s.charset = "UTF-8"
	s.Open()

	s.loadFromFile(path)
	s.position = 0
	txt = s.ReadText()

	s.Close();
	s = nil

	return txt.gsub("<", "<")
end

def hello_world
	"Hello World"
end

class Greeter

	def initialize(name = "human")
		@name = name
	end

	def say_hi
		"Hi #{@name}!"
	end

	def say_bye
		"Bye #{@name}, come back soon."
	end

end

Response.write( "--------------------------------------------------------------------------------\n" )
Response.write( "Calling a Ruby function\n" )
Response.write( "--------------------------------------------------------------------------------\n" )
Response.write( hello_world() + "\n" )
Response.write( "\n" )

Response.write( "--------------------------------------------------------------------------------\n" )
Response.write( "Ruby Version\n" )
Response.write( "--------------------------------------------------------------------------------\n" )
Response.write( "#{RUBY_VERSION}\n" )
Response.write( "\n" )

Response.write( "--------------------------------------------------------------------------------\n" )
Response.write( "Calling a Ruby class\n" )
Response.write( "--------------------------------------------------------------------------------\n" )
g = Greeter.new("ASPer")
Response.write( g.say_hi() + "\n" )
Response.write( g.say_bye + "\n" )
g = nil
Response.write( "\n" )

Response.write( "--------------------------------------------------------------------------------\n" )
Response.write( "Calling an ActiveX component\n" )
Response.write( "--------------------------------------------------------------------------------\n" )
d = WIN32OLE.new("Scripting.Dictionary")
d.add("name", "Fabio Zendhi Nagao")
d.add("nickname", "nagaozen")
Response.write( d.item("name") + "\n" )
Response.write( d.item("nickname") + "\n" )
d = nil
Response.write( "\n" )

Response.write( "--------------------------------------------------------------------------------\n" )
Response.write( "Calling ASP objects\n" )
Response.write( "--------------------------------------------------------------------------------\n" )
Response.write( "BUG: It's odd, while you can retrive Session values, you cannot set them.
This is mostly because of the syntax conflict Session(key) = value which seems
to Ruby that you are assigning a value to the return of a function." )
Response.write( Session.Contents("key") )
Response.write( "\n" )
Response.write( "\n" )
Response.write( Request.QueryString("qrystr") )
Response.write( "\n" )
Response.write( "\n" )
Response.write( "{" )
for variable in Request.ServerVariables
	Response.write( variable + ":" )
	Response.write( Request.ServerVariables(variable) )
	Response.write( "," )
end
Response.write( "}\n" )
Response.write( "\n" )

Response.write( "--------------------------------------------------------------------------------\n" )
	Response.write( "Calling RubyGem (gem install htmlentities, gem install sass)\n" )
Response.write( "--------------------------------------------------------------------------------\n" )

coder = HTMLEntities.new
Response.write( coder.encode("<élan>") + "\n" )
Response.write( "\n" )

engine = Sass::Engine.new("#main {background-color: #0000ff}", :syntax => :scss)
Response.write( engine.render + "\n" )
Response.write( "\n" )

Response.write( "--------------------------------------------------------------------------------\n" )
Response.write( "This source\n" )
Response.write( "--------------------------------------------------------------------------------\n" )
Response.write( read_text_file( Server.mapPath("ruby.lang.asp") ) )
#Response.write( read_text_file( Server.mapPath("vbErrors.txt") ) )

%></pre>