Skip to content

Commit

Permalink
Add V8 engine
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Nov 12, 2010
1 parent d69b8ad commit 671dbaf
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion lib/coffee_script.rb
Expand Up @@ -62,9 +62,35 @@ def compile(script, options = {})
end
end

module V8
class << self
def supported?
require 'v8'
true
rescue LoadError
false
end

def compile(script, options = {})
coffee_module['compile'].call(script, Source.bare_option => options[:bare])
end

private
def coffee_module
@coffee_module ||= build_coffee_module
end

def build_coffee_module
context = ::V8::Context.new
context.eval(Source.read)
context['CoffeeScript']
end
end
end

class << self
def engines
[Node, JavaScriptCore]
[V8, Node, JavaScriptCore]
end

def engine
Expand Down

0 comments on commit 671dbaf

Please sign in to comment.