From 4d265b8361c6326714e3f4f6b731dc763fafcadb Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Sat, 11 May 2013 21:16:51 -0700 Subject: [PATCH 1/4] The source :rubygems is deprecated because HTTP requests are insecure --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 264d795..8af537b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ -source :rubygems +source 'https://rubygems.org' gemspec From 5b17fbc6661830ff738b5e434c1147085f4969a5 Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Sat, 11 May 2013 21:17:01 -0700 Subject: [PATCH 2/4] Require Ruby 1.9.2 --- .travis.yml | 12 ++++-------- execjs.gemspec | 2 ++ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4d4472b..81e812d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,7 @@ +language: ruby rvm: - - 1.8.7 + - rbx-19mode + - ruby-head - 1.9.2 - 1.9.3 - - jruby-18mode - - jruby-19mode - - jruby-head - - rbx-18mode - - rbx-19mode - - ree - - ruby-head + - 2.0.0 diff --git a/execjs.gemspec b/execjs.gemspec index 8ecabc3..340f568 100644 --- a/execjs.gemspec +++ b/execjs.gemspec @@ -14,6 +14,8 @@ Gem::Specification.new do |s| s.add_dependency "multi_json", "~>1.0" s.add_development_dependency "rake" + s.required_ruby_version = '>= 1.9.2' + s.authors = ["Sam Stephenson", "Josh Peek"] s.email = ["sstephenson@gmail.com", "josh@joshpeek.com"] end From 79698e8bc6f0c7da9b008a62d22a55946a9eee51 Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Sat, 11 May 2013 21:17:04 -0700 Subject: [PATCH 3/4] Specify license in gemspec --- execjs.gemspec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/execjs.gemspec b/execjs.gemspec index 340f568..c71681f 100644 --- a/execjs.gemspec +++ b/execjs.gemspec @@ -16,6 +16,8 @@ Gem::Specification.new do |s| s.required_ruby_version = '>= 1.9.2' + s.licenses = ['MIT'] + s.authors = ["Sam Stephenson", "Josh Peek"] s.email = ["sstephenson@gmail.com", "josh@joshpeek.com"] end From 6548dab51f346e82ae2cedfe59924e2bfc0a81d6 Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Sat, 11 May 2013 21:17:10 -0700 Subject: [PATCH 4/4] Replace multi_json with json --- lib/execjs/external_runtime.rb | 10 +++++----- lib/execjs/json.rb | 23 ----------------------- 2 files changed, 5 insertions(+), 28 deletions(-) delete mode 100644 lib/execjs/json.rb diff --git a/lib/execjs/external_runtime.rb b/lib/execjs/external_runtime.rb index 4877975..469cc3d 100644 --- a/lib/execjs/external_runtime.rb +++ b/lib/execjs/external_runtime.rb @@ -16,7 +16,7 @@ module ExecJS source = encode(source) if /\S/ =~ source - exec("return eval(#{JSON.encode("(#{source})")})") + exec("return eval(#{::JSON.dump("(#{source})")})") end end @@ -30,7 +30,7 @@ module ExecJS end def call(identifier, *args) - eval "#{identifier}.apply(this, #{JSON.encode(args)})" + eval "#{identifier}.apply(this, #{::JSON.dump(args)})" end protected @@ -50,7 +50,7 @@ module ExecJS end output.sub!('#{encoded_source}') do encoded_source = encode_unicode_codepoints(source) - JSON.encode("(function(){ #{encoded_source} })()") + ::JSON.dump("(function(){ #{encoded_source} })()") end output.sub!('#{json2_source}') do IO.read(ExecJS.root + "/support/json2.js") @@ -59,7 +59,7 @@ module ExecJS end def extract_result(output) - status, value = output.empty? ? [] : JSON.decode(output) + status, value = output.empty? ? [] : ::JSON.load(output) if status == "ok" value elsif value =~ /SyntaxError:/ @@ -100,7 +100,7 @@ module ExecJS end def available? - require "execjs/json" + require 'json' binary ? true : false end diff --git a/lib/execjs/json.rb b/lib/execjs/json.rb deleted file mode 100644 index d6b135f..0000000 --- a/lib/execjs/json.rb +++ /dev/null @@ -1,23 +0,0 @@ -require "multi_json" - -module ExecJS - module JSON - if MultiJson.respond_to?(:dump) - def self.decode(obj) - MultiJson.load(obj) - end - - def self.encode(obj) - MultiJson.dump(obj) - end - else - def self.decode(obj) - MultiJson.decode(obj) - end - - def self.encode(obj) - MultiJson.encode(obj) - end - end - end -end