Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'stereobooster-happy-travis-ci'

  • Loading branch information...
commit 4cd4e4570893128fe81cea22f0688c91484ac3ff 2 parents 457c4f2 + 3514c7b
@josh josh authored
View
14 .travis.yml
@@ -1,13 +1,11 @@
-env: CI=1
-
rvm:
- 1.8.7
- - 1.9.1
- 1.9.2
- - jruby
- - rbx
+ - 1.9.3
+ - jruby-18mode
+ - jruby-19mode
+ - jruby-head
+ - rbx-18mode
+ - rbx-19mode
- ree
- ruby-head
-
-notifications:
- disabled: true
View
12 Gemfile
@@ -3,9 +3,13 @@ source :rubygems
gemspec
group :test do
- gem 'johnson', :platform => :mri_18
gem 'json'
- gem 'mustang', :platform => :ruby
- gem 'therubyracer', :platform => :ruby
- gem 'therubyrhino', :platform => :jruby
+ # see https://github.com/jbarnette/johnson/issues/21
+ gem 'johnson', :platform => :mri_18
+ # see https://github.com/nu7hatch/mustang/issues/18
+ gem 'mustang', :platform => :ruby,
+ :git => "https://github.com/nu7hatch/mustang.git", :ref => "2a3bcfbd9fd0f34e9b004fcd92188f326b40ec2a"
+ # disabled for rbx, because of https://github.com/cowboyd/therubyracer/issues/157
+ gem 'therubyracer', :platform => :mri
+ gem 'therubyrhino', ">=1.73.3", :platform => :jruby
end
View
3  Rakefile
@@ -7,7 +7,7 @@ require "execjs/runtimes"
tests = namespace :test do |tests|
ExecJS::Runtimes.names.each do |name|
- next if name == :Disabled
+ next if name.to_s == "Disabled"
task(name.downcase) do
ENV["EXECJS_RUNTIME"] = name.to_s
@@ -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
View
8 execjs.gemspec
@@ -7,18 +7,12 @@ Gem::Specification.new do |s|
s.homepage = "https://github.com/sstephenson/execjs"
s.summary = "Run JavaScript code from Ruby"
- s.description = <<-EOS
- ExecJS lets you run JavaScript code from Ruby.
- EOS
+ s.description = "ExecJS lets you run JavaScript code from Ruby."
s.files = Dir["README.md", "LICENSE", "lib/**/*"]
s.add_dependency "multi_json", "~>1.0"
- s.add_development_dependency "johnson"
- s.add_development_dependency "mustang"
s.add_development_dependency "rake"
- s.add_development_dependency "therubyracer"
- s.add_development_dependency "therubyrhino"
s.authors = ["Sam Stephenson", "Josh Peek"]
s.email = ["sstephenson@gmail.com", "josh@joshpeek.com"]
View
6 lib/execjs/external_runtime.rb
@@ -6,14 +6,14 @@ module ExecJS
class ExternalRuntime
class Context
def initialize(runtime, source = "")
- source = source.encode('UTF-8') if source.respond_to?(:encode)
+ source = ExecJS.encode(source)
@runtime = runtime
@source = source
end
def eval(source, options = {})
- source = source.encode('UTF-8') if source.respond_to?(:encode)
+ source = ExecJS.encode(source)
if /\S/ =~ source
exec("return eval(#{json_encode("(#{source})")})")
@@ -21,7 +21,7 @@ def eval(source, options = {})
end
def exec(source, options = {})
- source = source.encode('UTF-8') if source.respond_to?(:encode)
+ source = ExecJS.encode(source)
source = "#{@source}\n#{source}" if @source
compile_to_tempfile(source) do |file|
View
29 lib/execjs/module.rb
@@ -34,5 +34,34 @@ def root
def windows?
@windows ||= RbConfig::CONFIG["host_os"] =~ /mswin|mingw/
end
+
+ if defined? Encoding
+ if (!defined?(RUBY_ENGINE) || (RUBY_ENGINE != "jruby" && RUBY_ENGINE != "rbx"))
+ def 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 encode(string)
+ if string.encoding.name == 'ASCII-8BIT'
+ data = string.dup
+ data.force_encoding('utf-8')
+
+ unless data.valid_encoding?
+ raise Encoding::UndefinedConversionError, "Could not encode ASCII-8BIT data #{string.dump} as UTF-8"
+ end
+ else
+ data = string.encode('utf-8')
+ end
+ data
+ end
+ end
+ else
+ # Define no-op on 1.8
+ def encode(string)
+ string
+ end
+ end
end
end
View
6 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)
@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 /\S/ =~ source
eval "(function(){#{source}})()", options
@@ -17,7 +17,7 @@ def exec(source, options = {})
end
def eval(source, options = {})
- source = source.encode('UTF-8') if source.respond_to?(:encode)
+ source = ExecJS.encode(source)
if /\S/ =~ source
unbox @v8_context.eval("(#{source})")
View
20 lib/execjs/ruby_rhino_runtime.rb
@@ -2,7 +2,7 @@ module ExecJS
class RubyRhinoRuntime
class Context
def initialize(source = "")
- source = source.encode('UTF-8') if source.respond_to?(:encode)
+ source = ExecJS.encode(source)
@rhino_context = ::Rhino::Context.new
fix_memory_limit! @rhino_context
@@ -10,7 +10,7 @@ def initialize(source = "")
end
def exec(source, options = {})
- source = source.encode('UTF-8') if source.respond_to?(:encode)
+ source = ExecJS.encode(source)
if /\S/ =~ source
eval "(function(){#{source}})()", options
@@ -18,13 +18,13 @@ def exec(source, options = {})
end
def eval(source, options = {})
- source = source.encode('UTF-8') if source.respond_to?(:encode)
+ source = ExecJS.encode(source)
if /\S/ =~ source
unbox @rhino_context.eval("(#{source})")
end
- rescue ::Rhino::JavascriptError => e
- if e.message == "syntax error"
+ rescue ::Rhino::JSError => e
+ if e.message =~ /^syntax error/
raise RuntimeError, e.message
else
raise ProgramError, e.message
@@ -33,7 +33,7 @@ def eval(source, options = {})
def call(properties, *args)
unbox @rhino_context.eval(properties).call(*args)
- rescue ::Rhino::JavascriptError => e
+ rescue ::Rhino::JSError => e
if e.message == "syntax error"
raise RuntimeError, e.message
else
@@ -42,13 +42,13 @@ def call(properties, *args)
end
def unbox(value)
- case value = ::Rhino::To.ruby(value)
- when ::Rhino::NativeFunction
+ case value = ::Rhino::to_ruby(value)
+ when Java::OrgMozillaJavascript::NativeFunction
nil
- when ::Rhino::NativeObject
+ when Java::OrgMozillaJavascript::NativeObject
value.inject({}) do |vs, (k, v)|
case v
- when ::Rhino::NativeFunction, ::Rhino::J::Function
+ when Java::OrgMozillaJavascript::NativeFunction, ::Rhino::JS::Function
nil
else
vs[k] = unbox(v)
Please sign in to comment.
Something went wrong with that request. Please try again.