Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

25 lines (18 sloc) 0.611 kb
# Exposing Ruby methods
require 'net/http'
require 'java'
require 'rubygems'
require 'mvn:rhino:js'
java_import org.mozilla.javascript.Context
java_import org.mozilla.javascript.NativeFunction
java_import org.mozilla.javascript.ScriptableObject
class HttpFunction < NativeFunction
def call(context, scope, scriptable, args)
Net::HTTP.get URI.parse(args[0])
end
end
context = Context.enter
scope = context.init_standard_objects
ScriptableObject.put_property scope, "http", HttpFunction.new
code = %[ http("http://www.webpop.com") ]
puts context.evaluate_string scope, code, "example-3.js", 1, nil
Jump to Line
Something went wrong with that request. Please try again.