module Wisp::Runtime

Public Instance Methods

exec(*arguments) click to toggle source
# File lib/wisp/runtime.rb, line 4
def exec *arguments
  check_availability!
  context.call *arguments
end

Private Instance Methods

check_availability!() click to toggle source
# File lib/wisp/runtime.rb, line 11
def check_availability!
  unless runtime.available?
    message = "The Node.JS runtime isn't available to Stylus."
    message << "Ensure that the 'node' (or 'nodejs') executable is present in your $PATH."
    raise RuntimeError, message
  end
end
context() click to toggle source
# File lib/wisp/runtime.rb, line 19
def context
  @context ||= runtime.compile script
end
runtime() click to toggle source
# File lib/wisp/runtime.rb, line 27
def runtime
  @runtime ||= ExecJS::ExternalRuntime.new(
    :name => 'Node.js (V8)',
    :command => ["nodejs", "node"],
    :runner_path => File.expand_path("../runtime/runner.js", __FILE__)
  )
end
script() click to toggle source
# File lib/wisp/runtime.rb, line 23
def script
  File.read File.expand_path('../runtime/compiler.js',__FILE__)
end