execjs 0.3.4 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/execjs.rb +32 -26
- data/lib/execjs/support/jscript_runner.js +1 -1
- metadata +5 -5
data/lib/execjs.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require "rbconfig"
|
2
2
|
|
3
3
|
module ExecJS
|
4
|
-
class Error
|
5
|
-
class RuntimeError
|
6
|
-
class ProgramError
|
4
|
+
class Error < ::StandardError; end
|
5
|
+
class RuntimeError < Error; end
|
6
|
+
class ProgramError < Error; end
|
7
|
+
class RuntimeUnavailable < RuntimeError; end
|
7
8
|
|
8
9
|
autoload :ExternalRuntime, "execjs/external_runtime"
|
9
10
|
autoload :MustangRuntime, "execjs/mustang_runtime"
|
@@ -11,35 +12,40 @@ module ExecJS
|
|
11
12
|
autoload :RubyRhinoRuntime, "execjs/ruby_rhino_runtime"
|
12
13
|
autoload :Runtimes, "execjs/runtimes"
|
13
14
|
|
14
|
-
|
15
|
-
runtime
|
16
|
-
end
|
15
|
+
class << self
|
16
|
+
attr_reader :runtime
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
def exec(source)
|
19
|
+
runtime.exec(source)
|
20
|
+
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
def eval(source)
|
23
|
+
runtime.eval(source)
|
24
|
+
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
def compile(source)
|
27
|
+
runtime.compile(source)
|
28
|
+
end
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
30
|
+
def runtimes
|
31
|
+
Runtimes.runtimes
|
32
|
+
end
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
def runtime=(runtime)
|
35
|
+
raise RuntimeUnavailable, "#{runtime.name} is unavailable on this system" unless runtime.available?
|
36
|
+
@runtime = runtime
|
37
|
+
end
|
38
|
+
|
39
|
+
def root
|
40
|
+
@root ||= File.expand_path("../execjs", __FILE__)
|
41
|
+
end
|
38
42
|
|
39
|
-
|
40
|
-
|
43
|
+
def windows?
|
44
|
+
@windows ||= RbConfig::CONFIG["host_os"] =~ /mswin|mingw/
|
45
|
+
end
|
41
46
|
end
|
42
47
|
|
43
|
-
#
|
44
|
-
self.runtime
|
48
|
+
# Eagerly detect runtime
|
49
|
+
self.runtime ||= Runtimes.best_available ||
|
50
|
+
raise(RuntimeUnavailable, "Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.")
|
45
51
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: execjs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 3
|
9
8
|
- 4
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sam Stephenson
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-05-
|
19
|
+
date: 2011-05-17 00:00:00 -05:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
130
|
requirements: []
|
131
131
|
|
132
132
|
rubyforge_project: execjs
|
133
|
-
rubygems_version: 1.
|
133
|
+
rubygems_version: 1.5.0
|
134
134
|
signing_key:
|
135
135
|
specification_version: 3
|
136
136
|
summary: Run JavaScript code from Ruby
|