lib/execjs/external_runtime.rb in execjs-0.3.3 vs lib/execjs/external_runtime.rb in execjs-0.3.4
- old
+ new
@@ -7,16 +7,20 @@
@runtime = runtime
@source = source
end
def eval(source, options = {})
+ souce = source.encode('UTF-8') if source.respond_to?(:encode)
+
if /\S/ =~ source
exec("return eval(#{MultiJson.encode("(#{source})")})")
end
end
def exec(source, options = {})
+ souce = source.encode('UTF-8') if source.respond_to?(:encode)
+
compile_to_tempfile([@source, source].join("\n")) do |file|
extract_result(@runtime.send(:exec_runtime, file.path))
end
end
@@ -24,10 +28,10 @@
eval "#{identifier}.apply(this, #{MultiJson.encode(args)})"
end
protected
def compile_to_tempfile(source)
- tempfile = Tempfile.open(["execjs",".js"])
+ tempfile = Tempfile.open(['execjs', '.js'])
tempfile.write compile(source)
tempfile.close
yield tempfile
ensure
tempfile.close!