Module: PAC::Runtimes
- Defined in:
- lib/pac/runtimes.rb,
lib/pac/runtimes/johnson.rb,
lib/pac/runtimes/mustang.rb,
lib/pac/runtimes/rubyracer.rb,
lib/pac/runtimes/rubyrhino.rb
Defined Under Namespace
Classes: JohnsonRuntime, MustangRuntime, RubyRacerRuntime, RubyRhinoRuntime
Constant Summary
collapse
- RubyRacer =
RubyRacerRuntime.new
- RubyRhino =
RubyRhinoRuntime.new
- Johnson =
JohnsonRuntime.new
- Mustang =
MustangRuntime.new
Class Method Summary
collapse
Class Method Details
.autodetect ⇒ Object
14
15
16
|
# File 'lib/pac/runtimes.rb', line 14
def autodetect
from_environment || best_available || raise(RuntimeUnavailable, "Could not find a JavaScript runtime. See https://github.com/samuelkadolph/ruby-pac for a list of runtimes.")
end
|
.best_available ⇒ Object
32
33
34
|
# File 'lib/pac/runtimes.rb', line 32
def best_available
runtimes.find(&:available?)
end
|
.from_environment ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/pac/runtimes.rb', line 18
def from_environment
if name = ENV["JS_RUNTIME"]
if runtime = const_get(name)
if runtime.available?
runtime if runtime.available?
else
raise RuntimeUnavailable, "#{runtime.name} runtime is not available on this system"
end
elsif !name.empty?
raise RuntimeUnavailable, "#{name} runtime is not defined"
end
end
end
|