1
0
Fork 0
mirror of https://github.com/rails/execjs synced 2023-03-27 23:21:20 -04:00

Switch to multi_json lib

This commit is contained in:
Joshua Peek 2011-04-14 10:27:45 -05:00
parent 8701188f83
commit 3097959f64
2 changed files with 5 additions and 4 deletions

View file

@ -25,6 +25,7 @@ Gem::Specification.new do |s|
"README.md"
]
s.add_dependency "multi_json", ">=1.0.0"
s.add_development_dependency "mustang"
s.add_development_dependency "therubyracer"
s.add_development_dependency "therubyrhino"

View file

@ -1,4 +1,3 @@
require "json"
require "tempfile"
module ExecJS
@ -11,7 +10,7 @@ module ExecJS
def eval(source, options = {})
if /\S/ =~ source
exec("return eval(#{"(#{source})".to_json})")
exec("return eval(#{MultiJson.encode("(#{source})")})")
end
end
@ -22,7 +21,7 @@ module ExecJS
end
def call(identifier, *args)
eval "#{identifier}.apply(this, #{args.to_json})"
eval "#{identifier}.apply(this, #{MultiJson.encode(args)})"
end
protected
@ -47,7 +46,7 @@ module ExecJS
end
def extract_result(output)
status, value = output.empty? ? [] : JSON.parse(output)
status, value = output.empty? ? [] : MultiJson.decode(output)
if status == "ok"
value
else
@ -83,6 +82,7 @@ module ExecJS
end
def available?
require "multi_json"
@binary ? true : false
end