From c87c363379f8f0a7ef8f2bfa0e03b14a4c9f8cff Mon Sep 17 00:00:00 2001 From: stereobooster Date: Thu, 17 May 2012 14:42:26 +0300 Subject: [PATCH] fix for rbx 1.9 workaround for rubinius/rubinius#1729 --- Rakefile | 1 + lib/execjs/mustang_runtime.rb | 6 +++--- lib/execjs/runtimes.rb | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Rakefile b/Rakefile index c29f78d..c562136 100644 --- a/Rakefile +++ b/Rakefile @@ -56,4 +56,5 @@ task :test do banner messages.join("\n") raise "test failures" if failed.any? + raise "all tests skipped" if !passed.any? end diff --git a/lib/execjs/mustang_runtime.rb b/lib/execjs/mustang_runtime.rb index bef85c3..69ba5a2 100644 --- a/lib/execjs/mustang_runtime.rb +++ b/lib/execjs/mustang_runtime.rb @@ -2,14 +2,14 @@ module ExecJS class MustangRuntime class Context def initialize(source = "") - source = source.encode('UTF-8') if source.respond_to?(:encode) + source = ExecJS::encode(source) if source.respond_to?(:encode) @v8_context = ::Mustang::Context.new @v8_context.eval(source) end def exec(source, options = {}) - source = source.encode('UTF-8') if source.respond_to?(:encode) + source = ExecJS::encode(source) if source.respond_to?(:encode) if /\S/ =~ source eval "(function(){#{source}})()", options @@ -17,7 +17,7 @@ module ExecJS end def eval(source, options = {}) - source = source.encode('UTF-8') if source.respond_to?(:encode) + source = ExecJS::encode(source) if source.respond_to?(:encode) if /\S/ =~ source unbox @v8_context.eval("(#{source})") diff --git a/lib/execjs/runtimes.rb b/lib/execjs/runtimes.rb index 52fd81c..a3a65db 100644 --- a/lib/execjs/runtimes.rb +++ b/lib/execjs/runtimes.rb @@ -92,12 +92,13 @@ module ExecJS end if defined? Encoding - if (!defined?(RUBY_ENGINE) || RUBY_ENGINE != "jruby") + if (!defined?(RUBY_ENGINE) || (RUBY_ENGINE != "jruby" && RUBY_ENGINE != "rbx")) def self.encode(string) string.encode('UTF-8') end else # workaround for jruby bug http://jira.codehaus.org/browse/JRUBY-6588 + # workaround for rbx bug https://github.com/rubinius/rubinius/issues/1729 def self.encode(string) if string.encoding.name == 'ASCII-8BIT' data = string.dup