From fe55c294648ce329f5501fd1bfb38dcefcfa442e Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 19 May 2014 17:03:58 -0500 Subject: [PATCH] Use 1.9 syntax --- Gemfile | 4 ++-- README.md | 2 +- lib/execjs/external_runtime.rb | 6 +++--- lib/execjs/runtimes.rb | 30 +++++++++++++++--------------- test/test_execjs.rb | 8 ++++---- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Gemfile b/Gemfile index d2e9a06..0d13b86 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,6 @@ source 'https://rubygems.org' gemspec group :test do - gem 'therubyracer', :platform => :mri - gem 'therubyrhino', ">=1.73.3", :platform => :jruby + gem 'therubyracer', platform: :mri + gem 'therubyrhino', ">=1.73.3", platform: :jruby end diff --git a/README.md b/README.md index 32dd01a..92f812c 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ require "open-uri" source = open("http://coffeescript.org/extras/coffee-script.js").read context = ExecJS.compile(source) -context.call("CoffeeScript.compile", "square = (x) -> x * x", :bare => true) +context.call("CoffeeScript.compile", "square = (x) -> x * x", bare: true) # => "var square;\nsquare = function(x) {\n return x * x;\n};" ``` diff --git a/lib/execjs/external_runtime.rb b/lib/execjs/external_runtime.rb index 2a1a451..01c3fa8 100644 --- a/lib/execjs/external_runtime.rb +++ b/lib/execjs/external_runtime.rb @@ -15,7 +15,7 @@ module ExecJS source = encode(source) if /\S/ =~ source - exec("return eval(#{::JSON.generate("(#{source})", :quirks_mode => true)})") + exec("return eval(#{::JSON.generate("(#{source})", quirks_mode: true)})") end end @@ -49,7 +49,7 @@ module ExecJS end output.sub!('#{encoded_source}') do encoded_source = encode_unicode_codepoints(source) - ::JSON.generate("(function(){ #{encoded_source} })()", :quirks_mode => true) + ::JSON.generate("(function(){ #{encoded_source} })()", quirks_mode: true) end output.sub!('#{json2_source}') do IO.read(ExecJS.root + "/support/json2.js") @@ -58,7 +58,7 @@ module ExecJS end def extract_result(output) - status, value = output.empty? ? [] : ::JSON.parse(output, :create_additions => false) + status, value = output.empty? ? [] : ::JSON.parse(output, create_additions: false) if status == "ok" value elsif value =~ /SyntaxError:/ diff --git a/lib/execjs/runtimes.rb b/lib/execjs/runtimes.rb index a26435d..969e7a6 100644 --- a/lib/execjs/runtimes.rb +++ b/lib/execjs/runtimes.rb @@ -19,30 +19,30 @@ module ExecJS Mustang = MustangRuntime.new Node = ExternalRuntime.new( - :name => "Node.js (V8)", - :command => ["nodejs", "node"], - :runner_path => ExecJS.root + "/support/node_runner.js", - :encoding => 'UTF-8' + name: "Node.js (V8)", + command: ["nodejs", "node"], + runner_path: ExecJS.root + "/support/node_runner.js", + encoding: 'UTF-8' ) JavaScriptCore = ExternalRuntime.new( - :name => "JavaScriptCore", - :command => "/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc", - :runner_path => ExecJS.root + "/support/jsc_runner.js" + name: "JavaScriptCore", + command: "/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc", + runner_path: ExecJS.root + "/support/jsc_runner.js" ) SpiderMonkey = Spidermonkey = ExternalRuntime.new( - :name => "SpiderMonkey", - :command => "js", - :runner_path => ExecJS.root + "/support/spidermonkey_runner.js", - :deprecated => true + name: "SpiderMonkey", + command: "js", + runner_path: ExecJS.root + "/support/spidermonkey_runner.js", + deprecated: true ) JScript = ExternalRuntime.new( - :name => "JScript", - :command => "cscript //E:jscript //Nologo //U", - :runner_path => ExecJS.root + "/support/jscript_runner.js", - :encoding => 'UTF-16LE' # CScript with //U returns UTF-16LE + name: "JScript", + command: "cscript //E:jscript //Nologo //U", + runner_path: ExecJS.root + "/support/jscript_runner.js", + encoding: 'UTF-16LE' # CScript with //U returns UTF-16LE ) diff --git a/test/test_execjs.rb b/test/test_execjs.rb index 3ea7cee..e687937 100644 --- a/test/test_execjs.rb +++ b/test/test_execjs.rb @@ -17,20 +17,20 @@ end class TestExecJS < Test def test_runtime_available - runtime = ExecJS::ExternalRuntime.new(:command => "nonexistent") + runtime = ExecJS::ExternalRuntime.new(command: "nonexistent") assert !runtime.available? - runtime = ExecJS::ExternalRuntime.new(:command => "ruby") + runtime = ExecJS::ExternalRuntime.new(command: "ruby") assert runtime.available? end def test_runtime_assignment original_runtime = ExecJS.runtime - runtime = ExecJS::ExternalRuntime.new(:command => "nonexistent") + runtime = ExecJS::ExternalRuntime.new(command: "nonexistent") assert_raises(ExecJS::RuntimeUnavailable) { ExecJS.runtime = runtime } assert_equal original_runtime, ExecJS.runtime - runtime = ExecJS::ExternalRuntime.new(:command => "ruby") + runtime = ExecJS::ExternalRuntime.new(command: "ruby") ExecJS.runtime = runtime assert_equal runtime, ExecJS.runtime ensure