execjs 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -4,12 +4,14 @@ module ExecJS
|
|
4
4
|
class ExternalRuntime
|
5
5
|
class Context
|
6
6
|
def initialize(runtime, source = "")
|
7
|
+
source = source.encode('UTF-8') if source.respond_to?(:encode)
|
8
|
+
|
7
9
|
@runtime = runtime
|
8
10
|
@source = source
|
9
11
|
end
|
10
12
|
|
11
13
|
def eval(source, options = {})
|
12
|
-
|
14
|
+
source = source.encode('UTF-8') if source.respond_to?(:encode)
|
13
15
|
|
14
16
|
if /\S/ =~ source
|
15
17
|
exec("return eval(#{MultiJson.encode("(#{source})")})")
|
@@ -17,7 +19,7 @@ module ExecJS
|
|
17
19
|
end
|
18
20
|
|
19
21
|
def exec(source, options = {})
|
20
|
-
|
22
|
+
source = source.encode('UTF-8') if source.respond_to?(:encode)
|
21
23
|
|
22
24
|
compile_to_tempfile([@source, source].join("\n")) do |file|
|
23
25
|
extract_result(@runtime.send(:exec_runtime, file.path))
|
data/lib/execjs/module.rb
CHANGED
@@ -2,12 +2,14 @@ module ExecJS
|
|
2
2
|
class MustangRuntime
|
3
3
|
class Context
|
4
4
|
def initialize(source = "")
|
5
|
+
source = source.encode('UTF-8') if source.respond_to?(:encode)
|
6
|
+
|
5
7
|
@v8_context = ::Mustang::Context.new
|
6
8
|
@v8_context.eval(source)
|
7
9
|
end
|
8
10
|
|
9
11
|
def exec(source, options = {})
|
10
|
-
|
12
|
+
source = source.encode('UTF-8') if source.respond_to?(:encode)
|
11
13
|
|
12
14
|
if /\S/ =~ source
|
13
15
|
eval "(function(){#{source}})()", options
|
@@ -15,7 +17,7 @@ module ExecJS
|
|
15
17
|
end
|
16
18
|
|
17
19
|
def eval(source, options = {})
|
18
|
-
|
20
|
+
source = source.encode('UTF-8') if source.respond_to?(:encode)
|
19
21
|
|
20
22
|
if /\S/ =~ source
|
21
23
|
unbox @v8_context.eval("(#{source})")
|
@@ -2,12 +2,14 @@ module ExecJS
|
|
2
2
|
class RubyRacerRuntime
|
3
3
|
class Context
|
4
4
|
def initialize(source = "")
|
5
|
+
source = source.encode('UTF-8') if source.respond_to?(:encode)
|
6
|
+
|
5
7
|
@v8_context = ::V8::Context.new
|
6
8
|
@v8_context.eval(source)
|
7
9
|
end
|
8
10
|
|
9
11
|
def exec(source, options = {})
|
10
|
-
|
12
|
+
source = source.encode('UTF-8') if source.respond_to?(:encode)
|
11
13
|
|
12
14
|
if /\S/ =~ source
|
13
15
|
eval "(function(){#{source}})()", options
|
@@ -15,7 +17,7 @@ module ExecJS
|
|
15
17
|
end
|
16
18
|
|
17
19
|
def eval(source, options = {})
|
18
|
-
|
20
|
+
source = source.encode('UTF-8') if source.respond_to?(:encode)
|
19
21
|
|
20
22
|
if /\S/ =~ source
|
21
23
|
unbox @v8_context.eval("(#{source})")
|
@@ -2,12 +2,15 @@ module ExecJS
|
|
2
2
|
class RubyRhinoRuntime
|
3
3
|
class Context
|
4
4
|
def initialize(source = "")
|
5
|
+
source = source.encode('UTF-8') if source.respond_to?(:encode)
|
6
|
+
|
5
7
|
@rhino_context = ::Rhino::Context.new
|
8
|
+
fix_memory_limit! @rhino_context
|
6
9
|
@rhino_context.eval(source)
|
7
10
|
end
|
8
11
|
|
9
12
|
def exec(source, options = {})
|
10
|
-
|
13
|
+
source = source.encode('UTF-8') if source.respond_to?(:encode)
|
11
14
|
|
12
15
|
if /\S/ =~ source
|
13
16
|
eval "(function(){#{source}})()", options
|
@@ -15,7 +18,7 @@ module ExecJS
|
|
15
18
|
end
|
16
19
|
|
17
20
|
def eval(source, options = {})
|
18
|
-
|
21
|
+
source = source.encode('UTF-8') if source.respond_to?(:encode)
|
19
22
|
|
20
23
|
if /\S/ =~ source
|
21
24
|
unbox @rhino_context.eval("(#{source})")
|
@@ -51,6 +54,16 @@ module ExecJS
|
|
51
54
|
value
|
52
55
|
end
|
53
56
|
end
|
57
|
+
|
58
|
+
private
|
59
|
+
# Disables bytecode compiling which limits you to 64K scripts
|
60
|
+
def fix_memory_limit!(context)
|
61
|
+
if context.respond_to?(:optimization_level=)
|
62
|
+
context.optimization_level = -1
|
63
|
+
else
|
64
|
+
context.instance_eval { @native.setOptimizationLevel(-1) }
|
65
|
+
end
|
66
|
+
end
|
54
67
|
end
|
55
68
|
|
56
69
|
def name
|
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: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 1
|
10
|
+
version: 1.1.1
|
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-06-
|
19
|
+
date: 2011-06-07 00:00:00 -05:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -35,7 +35,7 @@ dependencies:
|
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
38
|
+
name: rake
|
39
39
|
prerelease: false
|
40
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
@@ -48,34 +48,6 @@ dependencies:
|
|
48
48
|
version: "0"
|
49
49
|
type: :development
|
50
50
|
version_requirements: *id002
|
51
|
-
- !ruby/object:Gem::Dependency
|
52
|
-
name: therubyracer
|
53
|
-
prerelease: false
|
54
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
|
-
requirements:
|
57
|
-
- - ">="
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
hash: 3
|
60
|
-
segments:
|
61
|
-
- 0
|
62
|
-
version: "0"
|
63
|
-
type: :development
|
64
|
-
version_requirements: *id003
|
65
|
-
- !ruby/object:Gem::Dependency
|
66
|
-
name: therubyrhino
|
67
|
-
prerelease: false
|
68
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
-
none: false
|
70
|
-
requirements:
|
71
|
-
- - ">="
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
hash: 3
|
74
|
-
segments:
|
75
|
-
- 0
|
76
|
-
version: "0"
|
77
|
-
type: :development
|
78
|
-
version_requirements: *id004
|
79
51
|
description: " ExecJS lets you run JavaScript code from Ruby.\n"
|
80
52
|
email:
|
81
53
|
- sstephenson@gmail.com
|
@@ -131,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
103
|
requirements: []
|
132
104
|
|
133
105
|
rubyforge_project: execjs
|
134
|
-
rubygems_version: 1.
|
106
|
+
rubygems_version: 1.6.2
|
135
107
|
signing_key:
|
136
108
|
specification_version: 3
|
137
109
|
summary: Run JavaScript code from Ruby
|