therubyrhino 2.0.4 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: eee1c4a4933c0a914ccffeb49c390807403d25e1
4
- data.tar.gz: 38c583809186d31db93ff6f5ddcfa996532a181c
2
+ SHA256:
3
+ metadata.gz: 2e15819e51a33cdf6ad48d5ccdbe29732ed6c845e46c7052d7899a1ddb6fa80a
4
+ data.tar.gz: 2c7d2c651436969c0ef632857bf42dcd43ce88ee85717a032328c3c003f3ab02
5
5
  SHA512:
6
- metadata.gz: 001058b9b1923bb6f29c21ba8e0c1a007c54057a7307f4d0c4e12681073b050c4ffe9420921b0431696e44a2cddf1f7bf2ad4e61d6c76dcf6cc3500af1ef0bf1
7
- data.tar.gz: 3dba6c0a9383181e58534561860f29be78e85b524b9ccfc7f29c97eadf2511ac8e77f1521d29781d2b6ac5976c5f82cc1d61695819f728ba7050899b9c498230
6
+ metadata.gz: c173fc94ff7c4a34642671dc86b22e826ca3659ff4677989ff99d9d9a2d9589de0c381890ac5a0e6012b2e4ee9e3390e0c1da645edf0493ccf30c80af3aa1efb
7
+ data.tar.gz: bc8cee36e858478f88adbc39c073a0108d87f5d56e6cb375f1cb4165d343bb0186e6890d1caf65e586663da722d594818e2a781a1b1478660f51c9166bf07a47
@@ -1,10 +1,8 @@
1
+ language: ruby
2
+ jdk:
3
+ - openjdk8
1
4
  rvm:
2
- - jruby-18mode
3
- - jruby-19mode
4
- - jruby-head
5
- #env:
6
- # - JRUBY_OPTS="--1.8"
7
- # - JRUBY_OPTS="--1.9"
8
- branches:
9
- only:
10
- - master
5
+ - jruby-1.7.24
6
+ - jruby-1.7.27
7
+ - jruby-9.1
8
+ - jruby-9.2
data/Gemfile CHANGED
@@ -17,5 +17,4 @@ group :test do
17
17
  gem 'less', '>= 2.2.1', :require => nil
18
18
  end
19
19
 
20
- gem 'rake', :require => false, :group => :development
21
- gem 'jruby-openssl', :group => :development if JRUBY_VERSION < '1.7'
20
+ gem 'rake', '< 11', :require => false, :group => :development
data/History.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## jar-1.7.6 2015-04-29
2
+
3
+ * updated to Mozilla's Rhino 1.7R5 release from 2015-04-15, notes:
4
+ https://github.com/mozilla/rhino/releases/tag/Rhino1_7_6_RELEASE
5
+
6
+ ## jar-1.7.5 2015-04-29
7
+
8
+ * updated to Mozilla's Rhino 1.7R5 release from 2015-01-29, notes:
9
+ https://github.com/mozilla/rhino/releases/tag/Rhino1_7R5_RELEASE
10
+
1
11
  ## 2.0.3 2014-02-20
2
12
 
3
13
  * minor fix for time_to_js when scope not set (#27)
data/README.md CHANGED
@@ -240,7 +240,7 @@ require 'rhino'
240
240
 
241
241
  (The MIT License)
242
242
 
243
- Copyright (c) 2009-2013 Charles Lowell
243
+ Copyright (c) 2009-2015 Charles Lowell
244
244
 
245
245
  Permission is hereby granted, free of charge, to any person obtaining
246
246
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -27,7 +27,14 @@ require 'bundler/gem_helper'
27
27
  task('install') { gem_helper.install_gem }
28
28
 
29
29
  desc "Create tag #{version_tag} and build and push #{name}-#{version}.gem to Rubygems"
30
- task('release') { gem_helper.release_gem }
30
+ task('release') do
31
+ gem_helper.instance_eval do
32
+ guard_clean
33
+ built_gem_path = build_gem
34
+ tag_version unless already_tagged?
35
+ rubygem_push(built_gem_path) if gem_push?
36
+ end
37
+ end
31
38
  end
32
39
  end
33
40
 
@@ -277,9 +277,6 @@ module Rhino
277
277
  # at org.mozilla.javascript.optimizer.Codegen.reportClassFileFormatException
278
278
 
279
279
  def code_generation_error?(exception) # :nodoc
280
- if ( exception.is_a?(NativeException) rescue nil ) # JRuby 1.6 wrapping
281
- exception = exception.cause
282
- end
283
280
  if exception.class == Rhino::JS::EvaluatorException
284
281
  if exception.message.index(CODE_GENERATION_ERROR_MESSAGE)
285
282
  return true
@@ -108,13 +108,9 @@ class Java::OrgMozillaJavascript::ScriptableObject
108
108
  else
109
109
  if property = self[name_str]
110
110
  if property.is_a?(Rhino::JS::Function)
111
- begin
112
- context = Rhino::JS::Context.enter
113
- scope = current_scope(context)
111
+ with_context do |context|
114
112
  js_args = Rhino.args_to_javascript(args, self) # scope == self
115
- Rhino.to_ruby property.__call__(context, scope, self, js_args)
116
- ensure
117
- Rhino::JS::Context.exit
113
+ Rhino.to_ruby property.__call__(context, current_scope(context), self, js_args)
118
114
  end
119
115
  else
120
116
  if args.size > 0
@@ -129,9 +125,23 @@ class Java::OrgMozillaJavascript::ScriptableObject
129
125
  end
130
126
 
131
127
  protected
132
-
128
+
129
+ def with_context
130
+ context = Rhino::JS::Context.getCurrentContext
131
+ unless context
132
+ context = Rhino::JS::Context.enter
133
+ context.initStandardObjects
134
+ context_exit = true
135
+ end
136
+ begin
137
+ yield(context)
138
+ ensure
139
+ Rhino::JS::Context.exit if context_exit
140
+ end
141
+ end
142
+
133
143
  def current_scope(context)
134
- getParentScope || context.initStandardObjects
144
+ getParentScope || Rhino::JS::ScriptRuntime.getGlobal(context)
135
145
  end
136
146
 
137
147
  end
@@ -173,47 +183,67 @@ class Java::OrgMozillaJavascript::NativeObject
173
183
 
174
184
  end
175
185
 
186
+ module Rhino
187
+ module Ruby
188
+ # @private
189
+ module FunctionCall
190
+ # make JavaScript functions callable Ruby style e.g. `fn.call('42')`
191
+ #
192
+ # NOTE: That invoking #call does not have the same semantics as
193
+ # JavaScript's Function#call but rather as Ruby's Method#call !
194
+ # Use #apply or #bind before calling to achieve the same effect.
195
+ def call(*args)
196
+ with_context do |context|
197
+ begin
198
+ # calling as a (var) stored function - no this === undefined "use strict"
199
+ # TODO can't pass Undefined.instance as this - it's not a Scriptable !?
200
+ this = Rhino::JS::ScriptRuntime.getGlobal(context)
201
+ js_args = Rhino.args_to_javascript(args, scope = current_scope(context))
202
+ Rhino.to_ruby __call__(context, scope, this, js_args)
203
+ rescue Rhino::JS::JavaScriptException => e
204
+ raise Rhino::JSError.new(e)
205
+ end
206
+ end
207
+ end
208
+ end
209
+ end
210
+ end
211
+
176
212
  # The base class for all JavaScript function objects.
177
213
  class Java::OrgMozillaJavascript::BaseFunction
178
214
 
179
215
  # Object call(Context context, Scriptable scope, Scriptable this, Object[] args)
180
216
  alias_method :__call__, :call
181
-
182
- # make JavaScript functions callable Ruby style e.g. `fn.call('42')`
183
- #
184
- # NOTE: That invoking #call does not have the same semantics as
185
- # JavaScript's Function#call but rather as Ruby's Method#call !
186
- # Use #apply or #bind before calling to achieve the same effect.
187
- def call(*args)
188
- context = Rhino::JS::Context.enter; scope = current_scope(context)
189
- # calling as a (var) stored function - no this === undefined "use strict"
190
- # TODO can't pass Undefined.instance as this - it's not a Scriptable !?
191
- this = Rhino::JS::ScriptRuntime.getGlobal(context)
192
- js_args = Rhino.args_to_javascript(args, scope)
193
- Rhino.to_ruby __call__(context, scope, this, js_args)
194
- rescue Rhino::JS::JavaScriptException => e
195
- raise Rhino::JSError.new(e)
196
- ensure
197
- Rhino::JS::Context.exit
217
+
218
+ include Rhino::Ruby::FunctionCall if RUBY_VERSION < '2.1'
219
+ # @deprecated (but needed to support JRuby <= 9.2)
220
+ define_method :call, Rhino::Ruby::FunctionCall.instance_method(:call)
221
+
222
+ def self.inherited(klass)
223
+ # NOTE: in JRuby < 9.3 inherited won't be called for a Java class
224
+ # ... so this happens pretty much only for `Rhino::Ruby::Function`
225
+ klass.send(:include, Rhino::Ruby::FunctionCall)
226
+ super(klass)
198
227
  end
199
-
228
+
200
229
  # bind a JavaScript function into the given (this) context
201
230
  def bind(this, *args)
202
- context = Rhino::JS::Context.enter; scope = current_scope(context)
203
- args = Rhino.args_to_javascript(args, scope)
204
- Rhino::JS::BoundFunction.new(context, scope, self, Rhino.to_javascript(this), args)
205
- ensure
206
- Rhino::JS::Context.exit
231
+ with_context do |context|
232
+ args = Rhino.args_to_javascript(args, scope = current_scope(context))
233
+ Rhino::JS::BoundFunction.new(context, scope, self, Rhino.to_javascript(this), args)
234
+ end
207
235
  end
208
236
 
209
237
  # use JavaScript functions constructors from Ruby as `fn.new`
210
238
  def new(*args)
211
- context = Rhino::JS::Context.enter; scope = current_scope(context)
212
- construct(context, scope, Rhino.args_to_javascript(args, scope))
213
- rescue Rhino::JS::JavaScriptException => e
214
- raise Rhino::JSError.new(e)
215
- ensure
216
- Rhino::JS::Context.exit
239
+ with_context do |context|
240
+ begin
241
+ scope = current_scope(context)
242
+ construct(context, scope, Rhino.args_to_javascript(args, scope))
243
+ rescue Rhino::JS::JavaScriptException => e
244
+ raise Rhino::JSError.new(e)
245
+ end
246
+ end
217
247
  end
218
248
 
219
249
  # apply a function with the given context and (optional) arguments
@@ -222,13 +252,14 @@ class Java::OrgMozillaJavascript::BaseFunction
222
252
  # NOTE: That #call from Ruby does not have the same semantics as
223
253
  # JavaScript's Function#call but rather as Ruby's Method#call !
224
254
  def apply(this, *args)
225
- context = Rhino::JS::Context.enter; scope = current_scope(context)
226
- args = Rhino.args_to_javascript(args, scope)
227
- __call__(context, scope, Rhino.to_javascript(this), args)
228
- rescue Rhino::JS::JavaScriptException => e
229
- raise Rhino::JSError.new(e)
230
- ensure
231
- Rhino::JS::Context.exit
255
+ with_context do |context|
256
+ begin
257
+ args = Rhino.args_to_javascript(args, scope = current_scope(context))
258
+ __call__(context, scope, Rhino.to_javascript(this), args)
259
+ rescue Rhino::JS::JavaScriptException => e
260
+ raise Rhino::JSError.new(e)
261
+ end
262
+ end
232
263
  end
233
264
  alias_method :methodcall, :apply # V8::Function compatibility
234
265
 
@@ -1,3 +1,3 @@
1
1
  module Rhino
2
- VERSION = "2.0.4"
2
+ VERSION = "2.1.2"
3
3
  end
@@ -81,11 +81,11 @@ describe Rhino::JSError do
81
81
  # [ "at <eval>:1", "at org/mozilla/javascript/gen/<eval>:1" ]
82
82
  e.javascript_backtrace.should be_a Enumerable
83
83
  e.javascript_backtrace.size.should >= 1
84
- e.javascript_backtrace[0].should == "at <eval>:1"
84
+ e.javascript_backtrace[0].should =~ /at .*?<eval>:1/
85
85
  e.javascript_backtrace(true).should be_a Enumerable
86
86
  e.javascript_backtrace(true).size.should >= 1
87
87
  element = e.javascript_backtrace(true)[0]
88
- element.file_name.should == '<eval>'
88
+ element.file_name.should match '<eval>'
89
89
  element.function_name.should be nil
90
90
  element.line_number.should == 1
91
91
  else
@@ -98,8 +98,8 @@ describe Rhino::JSError do
98
98
  Rhino::Context.eval "function fortyTwo() { throw 42 }\n fortyTwo()"
99
99
  rescue => e
100
100
  e.javascript_backtrace.size.should >= 2
101
- e.javascript_backtrace[0].should == "at <eval>:1 (fortyTwo)"
102
- expect( e.javascript_backtrace.find { |trace| trace == "at <eval>:2" } ).to_not be nil
101
+ e.javascript_backtrace[0].should =~ /at .*?<eval>:1 \(fortyTwo\)/
102
+ expect( e.javascript_backtrace.find { |trace| trace.end_with? "<eval>:2" } ).to_not be nil
103
103
  else
104
104
  fail "expected to rescue"
105
105
  end
@@ -110,7 +110,7 @@ describe Rhino::JSError do
110
110
  Rhino::Context.eval "throw 42"
111
111
  rescue => e
112
112
  e.backtrace.should be_a Array
113
- e.backtrace[0].should == "at <eval>:1"
113
+ e.backtrace[0].should =~ /at .*?<eval>:1/
114
114
  e.backtrace[1].should_not be nil
115
115
  else
116
116
  fail "expected to rescue"
@@ -174,15 +174,13 @@ describe Rhino::JSError do
174
174
  hi = context.eval "( function hi(arg) { Hello.hello(arg); } )"
175
175
  begin
176
176
  hi.call(24)
177
- rescue => e
178
- e.should be_a Rhino::JSError
177
+ fail "expected to raise"
178
+ rescue Rhino::JSError => e
179
179
  e.value.should_not be nil
180
180
  e.value.should be_a Rhino::Ruby::Object
181
181
  e.value(true).should be_a RuntimeError # unwraps ruby object
182
182
  # prints the original message (beyond [ruby RuntimeError]) :
183
183
  e.message.should == "RuntimeError: hello"
184
- else
185
- fail "expected to rescue"
186
184
  end
187
185
  # V8::JSError: hello
188
186
  # from (irb):4:in `hello'
@@ -24,8 +24,9 @@ shared_examples_for 'ScriptableObject', :shared => true do
24
24
  it "might be converted to a hash with string keys" do
25
25
  @object[42] = '42'
26
26
  @object[:foo] = 'bar'
27
- expect = @object.respond_to?(:to_h_properties) ? @object.to_h_properties : {}
28
- @object.to_h.should == expect.merge('42' => '42', 'foo' => 'bar')
27
+ prop_h = @object.to_h
28
+ expect( prop_h['42'] ).to eql '42'
29
+ expect( prop_h['foo'] ).to eql 'bar'
29
30
  end
30
31
 
31
32
  it "yields properties with each" do
@@ -66,13 +67,6 @@ describe "FunctionObject" do
66
67
 
67
68
  to_string = java.lang.Object.new.getClass.getMethod(:toString)
68
69
  @object = Rhino::JS::FunctionObject.new('to_string', to_string, scope)
69
- @object.instance_eval do
70
- def to_h_properties
71
- h = { "arguments"=> nil, "name"=> "to_string", "arity"=> 0, "length"=> 0 }
72
- RhinoHelpers.add_prototype_key(h) if Rhino.implementation_version < '1.7R4'
73
- h
74
- end
75
- end
76
70
  end
77
71
 
78
72
  after do
@@ -80,6 +74,11 @@ describe "FunctionObject" do
80
74
  end
81
75
 
82
76
  it_should_behave_like 'ScriptableObject'
77
+
78
+ it 'has a length' do
79
+ prop_h = @object.to_h
80
+ expect( prop_h['length'] ).to_not be nil
81
+ end
83
82
 
84
83
  end
85
84
 
@@ -97,10 +96,6 @@ describe "NativeObject (scoped)" do
97
96
  @object = @context.newObject(@scope)
98
97
  end
99
98
 
100
- after do
101
- Rhino::JS::Context.exit
102
- end
103
-
104
99
  it_should_behave_like 'ScriptableObject'
105
100
 
106
101
  it 'routes rhino methods' do
@@ -172,17 +167,6 @@ describe "NativeFunction" do
172
167
 
173
168
  object = @context.newObject(@scope)
174
169
  @object = Rhino::JS::ScriptableObject.getProperty(object, 'toString')
175
- @object.instance_eval do
176
- def to_h_properties
177
- h = { "arguments"=> nil, "name"=> "toString", "arity"=> 0, "length"=> 0 }
178
- RhinoHelpers.add_prototype_key(h) if Rhino.implementation_version < '1.7R4'
179
- h
180
- end
181
- end
182
- end
183
-
184
- after do
185
- Rhino::JS::Context.exit
186
170
  end
187
171
 
188
172
  it_should_behave_like 'ScriptableObject'
@@ -257,37 +241,20 @@ describe "NativeFunction (constructor)" do
257
241
  factory.enterContext(@context)
258
242
 
259
243
  @object = Rhino::JS::ScriptableObject.getProperty(@context.newObject(@scope), 'constructor')
260
- @object.instance_eval do
261
- def to_h_properties
262
- h = {
263
- "arguments"=>nil, "prototype"=>{}, "name"=>"Object", "arity"=>1, "length"=>1,
264
-
265
- "getPrototypeOf"=> { "arguments"=>nil, "name"=>"getPrototypeOf", "arity"=>1, "length"=>1},
266
- "keys"=>{"arguments"=>nil, "name"=>"keys", "arity"=>1, "length"=>1},
267
- "getOwnPropertyNames"=>{"arguments"=>nil, "name"=>"getOwnPropertyNames", "arity"=>1, "length"=>1},
268
- "getOwnPropertyDescriptor"=>{"arguments"=>nil, "name"=>"getOwnPropertyDescriptor", "arity"=>2, "length"=>2},
269
- "defineProperty"=>{"arguments"=>nil, "name"=>"defineProperty", "arity"=>3, "length"=>3},
270
- "isExtensible"=>{"arguments"=>nil, "name"=>"isExtensible", "arity"=>1, "length"=>1},
271
- "preventExtensions"=>{"arguments"=>nil, "name"=>"preventExtensions", "arity"=>1, "length"=>1},
272
- "defineProperties"=>{"arguments"=>nil, "name"=>"defineProperties", "arity"=>2, "length"=>2},
273
- "create"=>{"arguments"=>nil, "name"=>"create", "arity"=>2, "length"=>2},
274
- "isSealed"=>{"arguments"=>nil, "name"=>"isSealed", "arity"=>1, "length"=>1},
275
- "isFrozen"=>{"arguments"=>nil, "name"=>"isFrozen", "arity"=>1, "length"=>1},
276
- "seal"=>{"arguments"=>nil, "name"=>"seal", "arity"=>1, "length"=>1},
277
- "freeze"=>{"arguments"=>nil, "name"=>"freeze", "arity"=>1, "length"=>1}
278
- }
279
- RhinoHelpers.add_prototype_key(h, :recurse) if Rhino.implementation_version < '1.7R4'
280
- h
281
- end
282
- end
283
- end
284
-
285
- after do
286
- Rhino::JS::Context.exit
287
244
  end
288
245
 
289
246
  it_should_behave_like 'ScriptableObject'
290
-
247
+
248
+ it 'has a length' do
249
+ prop_h = @object.to_h
250
+ expect( prop_h['length'] ).to_not be nil
251
+ end
252
+
253
+ it 'has keys property' do
254
+ prop_h = @object.to_h
255
+ expect( prop_h['keys'] ).to be_a Hash
256
+ end
257
+
291
258
  it 'is constructable' do
292
259
  @object.new.should be_a Rhino::JS::NativeObject
293
260
  end
@@ -5,12 +5,13 @@ shared_examples_for Rhino::Ruby::Scriptable, :shared => true do
5
5
  it "puts, gets and has a read/write attr" do
6
6
  start = mock('start')
7
7
  start.expects(:put).never
8
-
8
+
9
+ @wrapper = wrapper
9
10
  @wrapper.unwrap.instance_eval do
10
11
  def foo; @foo; end
11
12
  def foo=(foo); @foo = foo; end
12
13
  end
13
-
14
+
14
15
  @wrapper.put('foo', start, 42)
15
16
  @wrapper.has('foo', nil).should == true
16
17
  @wrapper.get('foo', nil).should == 42
@@ -20,21 +21,23 @@ shared_examples_for Rhino::Ruby::Scriptable, :shared => true do
20
21
  it "puts, gets and has a write only attr" do
21
22
  start = mock('start')
22
23
  start.expects(:put).never
23
-
24
+
25
+ @wrapper = wrapper
24
26
  @wrapper.unwrap.instance_eval do
25
27
  def foo=(foo); @foo = foo; end
26
28
  end
27
-
29
+
28
30
  @wrapper.put('foo', start, 42)
31
+ @wrapper.unwrap.instance_variable_get(:'@foo').should == 42
29
32
  @wrapper.has('foo', nil).should == true
30
33
  @wrapper.get('foo', nil).should be(nil)
31
- @wrapper.unwrap.instance_variable_get(:'@foo').should == 42
32
34
  end
33
35
 
34
36
  it "puts, gets and has gets delegated if it acts like a Hash" do
35
37
  start = mock('start')
36
38
  start.expects(:put).never
37
-
39
+
40
+ @wrapper = wrapper
38
41
  @wrapper.unwrap.instance_eval do
39
42
  def [](name); (@hash ||= {})[name]; end
40
43
  def []=(name, value); (@hash ||= {})[name] = value; end
@@ -49,7 +52,8 @@ shared_examples_for Rhino::Ruby::Scriptable, :shared => true do
49
52
  it "puts, gets and has non-existing property" do
50
53
  start = mock('start')
51
54
  start.expects(:put).once
52
-
55
+
56
+ @wrapper = wrapper
53
57
  @wrapper.put('foo', start, 42)
54
58
  @wrapper.has('foo', nil).should == false
55
59
  @wrapper.get('foo', nil).should be(Rhino::JS::Scriptable::NOT_FOUND)
@@ -58,15 +62,14 @@ shared_examples_for Rhino::Ruby::Scriptable, :shared => true do
58
62
  end
59
63
 
60
64
  describe Rhino::Ruby::Object do
61
-
62
- before do
63
- @wrapper = Rhino::Ruby::Object.wrap @object = Object.new
64
- end
65
-
65
+
66
+ let(:object) { Object.new }
67
+ let(:wrapper) { Rhino::Ruby::Object.wrap object }
68
+
66
69
  it "unwraps a ruby object" do
67
- @wrapper.unwrap.should be(@object)
70
+ wrapper.unwrap.should be(object)
68
71
  end
69
-
72
+
70
73
  it_should_behave_like Rhino::Ruby::Scriptable
71
74
 
72
75
  class UII < Object
@@ -162,13 +165,18 @@ describe Rhino::Ruby::Object do
162
165
  end
163
166
 
164
167
  describe Rhino::Ruby::Function do
165
-
166
- before do
167
- @wrapper = Rhino::Ruby::Function.wrap @method = Object.new.method(:to_s)
168
+
169
+ let(:a_class) do
170
+ Class.new do
171
+ def self.sample; end
172
+ def inspect; 'SAMPLE' end
173
+ end
168
174
  end
169
-
175
+ let(:method) { a_class.method(:sample) }
176
+ let(:wrapper) { Rhino::Ruby::Function.wrap method }
177
+
170
178
  it "unwraps a ruby method" do
171
- @wrapper.unwrap.should be(@method)
179
+ wrapper.unwrap.should be(method)
172
180
  end
173
181
 
174
182
  it_should_behave_like Rhino::Ruby::Scriptable
@@ -222,8 +230,8 @@ describe Rhino::Ruby::Function do
222
230
  rb_function = Rhino::Ruby::Function.wrap klass.new.method(:foo)
223
231
  this = nil
224
232
 
225
- args = [ 1.to_java, 2.to_java, 3.to_java ].to_java; js_return = nil
226
- lambda { js_return = rb_function.call(context, scope, this, args) }.should_not raise_error
233
+ args = [ 1.to_java, 2.to_java, 3.to_java ].to_java
234
+ js_return = rb_function.call(context, scope, this, args)
227
235
  js_return.should == 1
228
236
  end
229
237
 
@@ -321,13 +329,12 @@ describe Rhino::Ruby::Function do
321
329
  end
322
330
 
323
331
  describe Rhino::Ruby::Constructor do
324
-
325
- before do
326
- @wrapper = Rhino::Ruby::Constructor.wrap @class = Class.new(Object)
327
- end
328
-
332
+
333
+ let(:klass) { Class.new(Object) }
334
+ let(:wrapper) { Rhino::Ruby::Constructor.wrap(klass) }
335
+
329
336
  it "unwraps a ruby method" do
330
- @wrapper.unwrap.should be(@class)
337
+ wrapper.unwrap.should be(klass)
331
338
  end
332
339
 
333
340
  it_should_behave_like Rhino::Ruby::Scriptable
@@ -20,15 +20,23 @@ module Rhino
20
20
  @context_factory ||= Rhino::JS::ContextFactory.new
21
21
  end
22
22
 
23
- def context
23
+ def context(enter: true)
24
24
  @context || context_factory.call { |ctx| @context = ctx }
25
- @context
25
+ @context.tap { Rhino::JS::Context.enter(@context, context_factory) }
26
26
  end
27
27
 
28
28
  def scope
29
- context.initStandardObjects(nil, false)
29
+ context.initStandardObjects
30
30
  end
31
-
31
+
32
+ def exit_context
33
+ Rhino::JS::Context.exit if @context
34
+ end
35
+
36
+ def self.included(base)
37
+ base.after { exit_context }
38
+ end
39
+
32
40
  end
33
41
  end
34
42
 
@@ -36,4 +44,9 @@ RSpec.configure do |config|
36
44
  config.filter_run_excluding :compat => /(0.5.0)|(0.6.0)/ # RedJS
37
45
  config.include Rhino::SpecHelpers
38
46
  config.deprecation_stream = 'spec/deprecations.log'
47
+
48
+ config.backtrace_clean_patterns = [
49
+ /gems\//,
50
+ /lib\/rspec\/(core|expectations|matchers|mocks)/,
51
+ ]
39
52
  end
@@ -19,7 +19,9 @@ Gem::Specification.new do |s|
19
19
  s.files = `git ls-files`.split("\n").sort.
20
20
  reject { |file| file == 'therubyrhino_jar.gemspec' || file =~ /^jar\// }
21
21
 
22
- s.add_dependency "therubyrhino_jar", '>= 1.7.3'
22
+ s.required_ruby_version = '>= 1.9.3'
23
+
24
+ s.add_dependency "therubyrhino_jar", '>= 1.7.4', '< 1.7.9'
23
25
 
24
26
  s.add_development_dependency "rspec", "~> 2.14.1"
25
27
  s.add_development_dependency "mocha", "~> 0.13.3"
metadata CHANGED
@@ -1,67 +1,74 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: therubyrhino
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Lowell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-26 00:00:00.000000000 Z
11
+ date: 2019-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: therubyrhino_jar
15
- version_requirements: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '>='
18
- - !ruby/object:Gem::Version
19
- version: 1.7.3
20
14
  requirement: !ruby/object:Gem::Requirement
21
15
  requirements:
22
- - - '>='
16
+ - - ">="
23
17
  - !ruby/object:Gem::Version
24
- version: 1.7.3
25
- prerelease: false
18
+ version: 1.7.4
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: 1.7.9
22
+ name: therubyrhino_jar
26
23
  type: :runtime
27
- - !ruby/object:Gem::Dependency
28
- name: rspec
24
+ prerelease: false
29
25
  version_requirements: !ruby/object:Gem::Requirement
30
26
  requirements:
31
- - - ~>
27
+ - - ">="
32
28
  - !ruby/object:Gem::Version
33
- version: 2.14.1
29
+ version: 1.7.4
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 1.7.9
33
+ - !ruby/object:Gem::Dependency
34
34
  requirement: !ruby/object:Gem::Requirement
35
35
  requirements:
36
- - - ~>
36
+ - - "~>"
37
37
  - !ruby/object:Gem::Version
38
38
  version: 2.14.1
39
- prerelease: false
39
+ name: rspec
40
40
  type: :development
41
- - !ruby/object:Gem::Dependency
42
- name: mocha
41
+ prerelease: false
43
42
  version_requirements: !ruby/object:Gem::Requirement
44
43
  requirements:
45
- - - ~>
44
+ - - "~>"
46
45
  - !ruby/object:Gem::Version
47
- version: 0.13.3
46
+ version: 2.14.1
47
+ - !ruby/object:Gem::Dependency
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  requirements:
50
- - - ~>
50
+ - - "~>"
51
51
  - !ruby/object:Gem::Version
52
52
  version: 0.13.3
53
- prerelease: false
53
+ name: mocha
54
54
  type: :development
55
- description: Call javascript code and manipulate javascript objects from ruby. Call ruby code and manipulate ruby objects from javascript.
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 0.13.3
61
+ description: Call javascript code and manipulate javascript objects from ruby. Call
62
+ ruby code and manipulate ruby objects from javascript.
56
63
  email: cowboyd@thefrontside.net
57
64
  executables: []
58
65
  extensions: []
59
66
  extra_rdoc_files:
60
67
  - README.md
61
68
  files:
62
- - .gitignore
63
- - .rspec
64
- - .travis.yml
69
+ - ".gitignore"
70
+ - ".rspec"
71
+ - ".travis.yml"
65
72
  - Gemfile
66
73
  - History.md
67
74
  - README.md
@@ -105,17 +112,17 @@ require_paths:
105
112
  - lib
106
113
  required_ruby_version: !ruby/object:Gem::Requirement
107
114
  requirements:
108
- - - '>='
115
+ - - ">="
109
116
  - !ruby/object:Gem::Version
110
- version: '0'
117
+ version: 1.9.3
111
118
  required_rubygems_version: !ruby/object:Gem::Requirement
112
119
  requirements:
113
- - - '>='
120
+ - - ">="
114
121
  - !ruby/object:Gem::Version
115
122
  version: '0'
116
123
  requirements: []
117
124
  rubyforge_project: therubyrhino
118
- rubygems_version: 2.2.2
125
+ rubygems_version: 2.7.6
119
126
  signing_key:
120
127
  specification_version: 4
121
128
  summary: Embed the Rhino JavaScript interpreter into JRuby