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

therubyracer gem is no longer maintained and is incompatible with Ruby 3.0

This commit is contained in:
Jean Boussier 2021-05-07 09:34:04 +02:00
parent ba0300d52a
commit e44130562d
5 changed files with 1 additions and 139 deletions

View file

@ -16,8 +16,6 @@ matrix:
env: EXECJS_RUNTIME=Node env: EXECJS_RUNTIME=Node
- rvm: 2.0.0 - rvm: 2.0.0
env: EXECJS_RUNTIME=Duktape env: EXECJS_RUNTIME=Duktape
- rvm: 2.0.0
env: EXECJS_RUNTIME=RubyRacer
- rvm: 2.0.0 - rvm: 2.0.0
env: EXECJS_RUNTIME=MiniRacer env: EXECJS_RUNTIME=MiniRacer
dist: trusty dist: trusty
@ -27,8 +25,6 @@ matrix:
env: EXECJS_RUNTIME=Node env: EXECJS_RUNTIME=Node
- rvm: 2.1.10 - rvm: 2.1.10
env: EXECJS_RUNTIME=Duktape env: EXECJS_RUNTIME=Duktape
- rvm: 2.1.10
env: EXECJS_RUNTIME=RubyRacer
- rvm: 2.1.10 - rvm: 2.1.10
env: EXECJS_RUNTIME=MiniRacer env: EXECJS_RUNTIME=MiniRacer
dist: trusty dist: trusty
@ -38,8 +34,6 @@ matrix:
env: EXECJS_RUNTIME=Node env: EXECJS_RUNTIME=Node
- rvm: 2.2.7 - rvm: 2.2.7
env: EXECJS_RUNTIME=Duktape env: EXECJS_RUNTIME=Duktape
- rvm: 2.2.7
env: EXECJS_RUNTIME=RubyRacer
- rvm: 2.2.7 - rvm: 2.2.7
env: EXECJS_RUNTIME=MiniRacer env: EXECJS_RUNTIME=MiniRacer
dist: trusty dist: trusty
@ -49,8 +43,6 @@ matrix:
env: EXECJS_RUNTIME=Node env: EXECJS_RUNTIME=Node
- rvm: 2.3.4 - rvm: 2.3.4
env: EXECJS_RUNTIME=Duktape env: EXECJS_RUNTIME=Duktape
- rvm: 2.3.4
env: EXECJS_RUNTIME=RubyRacer
- rvm: 2.3.4 - rvm: 2.3.4
env: EXECJS_RUNTIME=MiniRacer env: EXECJS_RUNTIME=MiniRacer
dist: trusty dist: trusty
@ -60,8 +52,6 @@ matrix:
env: EXECJS_RUNTIME=Node env: EXECJS_RUNTIME=Node
- rvm: 2.4.1 - rvm: 2.4.1
env: EXECJS_RUNTIME=Duktape env: EXECJS_RUNTIME=Duktape
- rvm: 2.4.1
env: EXECJS_RUNTIME=RubyRacer
- rvm: 2.4.1 - rvm: 2.4.1
env: EXECJS_RUNTIME=MiniRacer env: EXECJS_RUNTIME=MiniRacer
dist: trusty dist: trusty
@ -71,8 +61,6 @@ matrix:
env: EXECJS_RUNTIME=Node env: EXECJS_RUNTIME=Node
- rvm: ruby-head - rvm: ruby-head
env: EXECJS_RUNTIME=Duktape env: EXECJS_RUNTIME=Duktape
- rvm: ruby-head
env: EXECJS_RUNTIME=RubyRacer
- rvm: ruby-head - rvm: ruby-head
env: EXECJS_RUNTIME=MiniRacer env: EXECJS_RUNTIME=MiniRacer
dist: trusty dist: trusty
@ -89,8 +77,6 @@ matrix:
env: EXECJS_RUNTIME=Node env: EXECJS_RUNTIME=Node
- os: osx - os: osx
env: EXECJS_RUNTIME=Duktape env: EXECJS_RUNTIME=Duktape
- os: osx
env: EXECJS_RUNTIME=RubyRacer
- os: osx - os: osx
env: EXECJS_RUNTIME=V8 env: EXECJS_RUNTIME=V8
- os: osx - os: osx

View file

@ -4,11 +4,7 @@ gemspec
group :test do group :test do
gem 'duktape', platform: :mri gem 'duktape', platform: :mri
if ENV['EXECJS_RUNTIME'] == 'MiniRacer' gem 'mini_racer', platform: :mri
gem 'mini_racer', '0.1.0.beta.3', platform: :mri
else
gem 'therubyracer', platform: :mri
end
gem 'therubyrhino', '>=1.73.3', platform: :jruby gem 'therubyrhino', '>=1.73.3', platform: :jruby
gem 'minitest', require: false gem 'minitest', require: false
end end

View file

@ -7,8 +7,6 @@ returns the result to you as a Ruby object.
ExecJS supports these runtimes: ExecJS supports these runtimes:
* [therubyracer](https://github.com/cowboyd/therubyracer) - Google V8
embedded within Ruby
* [therubyrhino](https://github.com/cowboyd/therubyrhino) - Mozilla * [therubyrhino](https://github.com/cowboyd/therubyrhino) - Mozilla
Rhino embedded within JRuby Rhino embedded within JRuby
* [Duktape.rb](https://github.com/judofyr/duktape.rb) - Duktape JavaScript interpreter * [Duktape.rb](https://github.com/judofyr/duktape.rb) - Duktape JavaScript interpreter

View file

@ -1,114 +0,0 @@
require "execjs/runtime"
module ExecJS
class RubyRacerRuntime < Runtime
class Context < Runtime::Context
def initialize(runtime, source = "", options = {})
source = encode(source)
lock do
@v8_context = ::V8::Context.new
begin
@v8_context.eval(source)
rescue ::V8::JSError => e
raise wrap_error(e)
end
end
end
def exec(source, options = {})
source = encode(source)
if /\S/ =~ source
eval "(function(){#{source}})()", options
end
end
def eval(source, options = {})
source = encode(source)
if /\S/ =~ source
lock do
begin
unbox @v8_context.eval("(#{source})")
rescue ::V8::JSError => e
raise wrap_error(e)
end
end
end
end
def call(properties, *args)
lock do
begin
unbox @v8_context.eval("(#{properties})").call(*args)
rescue ::V8::JSError => e
raise wrap_error(e)
end
end
end
def unbox(value)
case value
when ::V8::Function
nil
when ::V8::Array
value.map { |v| unbox(v) }
when ::V8::Object
value.inject({}) do |vs, (k, v)|
vs[k] = unbox(v) unless v.is_a?(::V8::Function)
vs
end
when String
value.force_encoding('UTF-8')
else
value
end
end
private
def lock
result, exception = nil, nil
V8::C::Locker() do
begin
result = yield
rescue Exception => e
exception = e
end
end
if exception
raise exception
else
result
end
end
def wrap_error(e)
error_class = e.value["name"] == "SyntaxError" ? RuntimeError : ProgramError
stack = e.value["stack"] || ""
stack = stack.split("\n")
stack.shift
stack = [e.message[/<eval>:\d+:\d+/, 0]].compact if stack.empty?
stack = stack.map { |line| line.sub(" at ", "").sub("<eval>", "(execjs)").strip }
error = error_class.new(e.value.to_s)
error.set_backtrace(stack + caller)
error
end
end
def name
"therubyracer (V8)"
end
def available?
require "v8"
true
rescue LoadError
false
end
end
end

View file

@ -2,7 +2,6 @@ require "execjs/module"
require "execjs/disabled_runtime" require "execjs/disabled_runtime"
require "execjs/duktape_runtime" require "execjs/duktape_runtime"
require "execjs/external_runtime" require "execjs/external_runtime"
require "execjs/ruby_racer_runtime"
require "execjs/ruby_rhino_runtime" require "execjs/ruby_rhino_runtime"
require "execjs/mini_racer_runtime" require "execjs/mini_racer_runtime"
@ -12,8 +11,6 @@ module ExecJS
Duktape = DuktapeRuntime.new Duktape = DuktapeRuntime.new
RubyRacer = RubyRacerRuntime.new
RubyRhino = RubyRhinoRuntime.new RubyRhino = RubyRhinoRuntime.new
MiniRacer = MiniRacerRuntime.new MiniRacer = MiniRacerRuntime.new
@ -81,7 +78,6 @@ module ExecJS
def self.runtimes def self.runtimes
@runtimes ||= [ @runtimes ||= [
RubyRacer,
RubyRhino, RubyRhino,
Duktape, Duktape,
MiniRacer, MiniRacer,