therubyrhino 2.0.5 → 2.1.1

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: bfbbbe6278ac40b243346d4eb66423015b12097e
4
- data.tar.gz: 44d5e546ce36f119d27a2fa9d76865834eabb92a
2
+ SHA256:
3
+ metadata.gz: 23aafaf63c5af04a6c05a35bf9fa2b390be1f802f2871be65460ae2deae16f8e
4
+ data.tar.gz: 121d8fe9f0b66fb725adb95e528e78ab08abde6e849ea839e607a85af004aa68
5
5
  SHA512:
6
- metadata.gz: 018a23433c6958f5e36ff9cdfd2c403bebc18d431c595cdba6b90d78affdd299268689163d48b552ad21471985f9ba0f91a45581b53256a333826ee658d601ae
7
- data.tar.gz: 960f6e3be8c7692306609d11293b9307c8a2c038fce381dcd25c7ddd0f03636c01d61068f94cf97266a504b7e86a185c2ec751b38876dbb138ecbd32799e708e
6
+ metadata.gz: a2ed193aa1265042172ba68b3ddea823949d7ff2ea8dc3fdbffb353d7d99640e33ee8ad12e7e5cdff4bd7abbccce0ae50d0f293c7b9c1f2c15b5c9175d23377d
7
+ data.tar.gz: 3f2fc23e13149d53e1aa008b2161d1580ac75357ce94316ae734056614f9b9c653113558c65154138fc1d816a9a3791d5436dd4a0cfa657067c3ac63bef947e3
@@ -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
@@ -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
@@ -173,30 +173,47 @@ class Java::OrgMozillaJavascript::NativeObject
173
173
 
174
174
  end
175
175
 
176
+ module Rhino
177
+ module Ruby
178
+ # @private
179
+ module FunctionCall
180
+ # make JavaScript functions callable Ruby style e.g. `fn.call('42')`
181
+ #
182
+ # NOTE: That invoking #call does not have the same semantics as
183
+ # JavaScript's Function#call but rather as Ruby's Method#call !
184
+ # Use #apply or #bind before calling to achieve the same effect.
185
+ def call(*args)
186
+ context = Rhino::JS::Context.enter; scope = current_scope(context)
187
+ # calling as a (var) stored function - no this === undefined "use strict"
188
+ # TODO can't pass Undefined.instance as this - it's not a Scriptable !?
189
+ this = Rhino::JS::ScriptRuntime.getGlobal(context)
190
+ js_args = Rhino.args_to_javascript(args, scope)
191
+ Rhino.to_ruby __call__(context, scope, this, js_args)
192
+ rescue Rhino::JS::JavaScriptException => e
193
+ raise Rhino::JSError.new(e)
194
+ ensure
195
+ Rhino::JS::Context.exit
196
+ end
197
+ end
198
+ end
199
+ end
200
+
176
201
  # The base class for all JavaScript function objects.
177
202
  class Java::OrgMozillaJavascript::BaseFunction
178
203
 
179
204
  # Object call(Context context, Scriptable scope, Scriptable this, Object[] args)
180
205
  alias_method :__call__, :call
181
206
 
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
207
+ # @deprecated (but needed to support JRuby <= 9.2)
208
+ module_exec { define_method :call, Rhino::Ruby::FunctionCall.instance_method(:call) }
209
+
210
+ def self.inherited(klass)
211
+ # NOTE: in JRuby < 9.3 inherited won't be called for a Java class
212
+ # ... so this happens pretty much only for `Rhino::Ruby::Function`
213
+ klass.send(:include, Rhino::Ruby::FunctionCall)
214
+ super(klass)
198
215
  end
199
-
216
+
200
217
  # bind a JavaScript function into the given (this) context
201
218
  def bind(this, *args)
202
219
  context = Rhino::JS::Context.enter; scope = current_scope(context)
@@ -1,3 +1,3 @@
1
1
  module Rhino
2
- VERSION = "2.0.5"
2
+ VERSION = "2.1.1"
3
3
  end
@@ -85,7 +85,7 @@ describe Rhino::JSError do
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
@@ -99,7 +99,7 @@ describe Rhino::JSError do
99
99
  rescue => e
100
100
  e.javascript_backtrace.size.should >= 2
101
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
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
@@ -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
 
@@ -172,13 +171,6 @@ describe "NativeFunction" do
172
171
 
173
172
  object = @context.newObject(@scope)
174
173
  @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
174
  end
183
175
 
184
176
  after do
@@ -257,29 +249,6 @@ describe "NativeFunction (constructor)" do
257
249
  factory.enterContext(@context)
258
250
 
259
251
  @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
252
  end
284
253
 
285
254
  after do
@@ -287,7 +256,17 @@ describe "NativeFunction (constructor)" do
287
256
  end
288
257
 
289
258
  it_should_behave_like 'ScriptableObject'
290
-
259
+
260
+ it 'has a length' do
261
+ prop_h = @object.to_h
262
+ expect( prop_h['length'] ).to_not be nil
263
+ end
264
+
265
+ it 'has keys property' do
266
+ prop_h = @object.to_h
267
+ expect( prop_h['keys'] ).to be_a Hash
268
+ end
269
+
291
270
  it 'is constructable' do
292
271
  @object.new.should be_a Rhino::JS::NativeObject
293
272
  end
@@ -36,4 +36,9 @@ RSpec.configure do |config|
36
36
  config.filter_run_excluding :compat => /(0.5.0)|(0.6.0)/ # RedJS
37
37
  config.include Rhino::SpecHelpers
38
38
  config.deprecation_stream = 'spec/deprecations.log'
39
+
40
+ config.backtrace_clean_patterns = [
41
+ /gems\//,
42
+ /lib\/rspec\/(core|expectations|matchers|mocks)/,
43
+ ]
39
44
  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', '< 1.7.7'
22
+ s.required_ruby_version = '>= 1.9.3'
23
+
24
+ s.add_dependency "therubyrhino_jar", '>= 1.7.4', '< 1.7.8'
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: therubyrhino
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Lowell
@@ -15,21 +15,21 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 1.7.3
18
+ version: 1.7.4
19
19
  - - "<"
20
20
  - !ruby/object:Gem::Version
21
- version: 1.7.7
21
+ version: 1.7.8
22
22
  name: therubyrhino_jar
23
- prerelease: false
24
23
  type: :runtime
24
+ prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 1.7.3
29
+ version: 1.7.4
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 1.7.7
32
+ version: 1.7.8
33
33
  - !ruby/object:Gem::Dependency
34
34
  requirement: !ruby/object:Gem::Requirement
35
35
  requirements:
@@ -37,8 +37,8 @@ dependencies:
37
37
  - !ruby/object:Gem::Version
38
38
  version: 2.14.1
39
39
  name: rspec
40
- prerelease: false
41
40
  type: :development
41
+ prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
@@ -51,14 +51,15 @@ dependencies:
51
51
  - !ruby/object:Gem::Version
52
52
  version: 0.13.3
53
53
  name: mocha
54
- prerelease: false
55
54
  type: :development
55
+ prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: 0.13.3
61
- description: Call javascript code and manipulate javascript objects from ruby. Call ruby code and manipulate ruby objects from javascript.
61
+ description: Call javascript code and manipulate javascript objects from ruby. Call
62
+ ruby code and manipulate ruby objects from javascript.
62
63
  email: cowboyd@thefrontside.net
63
64
  executables: []
64
65
  extensions: []
@@ -113,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
114
  requirements:
114
115
  - - ">="
115
116
  - !ruby/object:Gem::Version
116
- version: '0'
117
+ version: 1.9.3
117
118
  required_rubygems_version: !ruby/object:Gem::Requirement
118
119
  requirements:
119
120
  - - ">="
@@ -121,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
122
  version: '0'
122
123
  requirements: []
123
124
  rubyforge_project: therubyrhino
124
- rubygems_version: 2.4.8
125
+ rubygems_version: 2.7.6
125
126
  signing_key:
126
127
  specification_version: 4
127
128
  summary: Embed the Rhino JavaScript interpreter into JRuby