therubyrhino 1.72.7 → 1.72.8

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,3 +3,4 @@ doc
3
3
  *.gem
4
4
  .rvmrc
5
5
  .bundle
6
+ Gemfile.lock
data/History.txt CHANGED
@@ -1,6 +1,5 @@
1
- === 1.72.7
2
- * N major enhancements:
3
- * N minor enhancements:
1
+ === 1.72.8 2011-06-26
2
+ * fix passing of options hash to ruby.
4
3
 
5
4
  === 1.72.6 2009-11-30
6
5
  * 2 major enhancements:
@@ -17,7 +16,7 @@
17
16
  * automatically wrap/unwrap ruby and javascript arrays
18
17
  * automatically convert ruby method objects and Proc objects into javascript functions
19
18
  * Make functions defined in javascript callable from ruby
20
-
19
+
21
20
  === 1.72.3 2009-11-11
22
21
  * 4 major enhancements:
23
22
  * greatly simplified interface to context by unifying context and scope
data/lib/rhino/context.rb CHANGED
@@ -31,7 +31,7 @@ module Rhino
31
31
  # end
32
32
  #
33
33
  # == Notes
34
- # While there are many similarities between Rhino::Context and Java::OrgMozillaJavascript::Context, they are not
34
+ # While there are many similarities between Rhino::Context and Java::org.mozilla.javascript.Context, they are not
35
35
  # the same thing and should not be confused.
36
36
 
37
37
  class Context
@@ -150,7 +150,7 @@ module Rhino
150
150
 
151
151
  end
152
152
 
153
- class IOReader < Java::JavaIo::Reader #:nodoc:
153
+ class IOReader < java.io.Reader #:nodoc:
154
154
 
155
155
  def initialize(io)
156
156
  @io = io
@@ -162,14 +162,14 @@ module Rhino
162
162
  if str.nil?
163
163
  return -1
164
164
  else
165
- jstring = Java::JavaLang::String.new(str)
165
+ jstring = java.lang.String.new(str)
166
166
  for i in 0 .. jstring.length - 1
167
167
  charbuffer[i + offset] = jstring.charAt(i)
168
168
  end
169
169
  return jstring.length
170
170
  end
171
171
  rescue StandardError => e
172
- raise Java::JavaIo::IOException.new, "Failed reading from ruby IO object"
172
+ raise java.io.IOException.new, "Failed reading from ruby IO object"
173
173
  end
174
174
  end
175
175
  end
@@ -21,9 +21,7 @@ module Rhino
21
21
  end
22
22
 
23
23
  def getIds()
24
- puts "getIds()"
25
- require 'java'
26
- @ruby.public_methods(false).map {|m| m.gsub(/(.)_(.)/) {::JavaLang::String.new("#{$1}#{$2.upcase}")}}.tap {|ids| puts "ids: #{ids.inspect}"}.to_java
24
+ @ruby.public_methods(false).map {|m| m.gsub(/(.)_(.)/) {java.lang.String.new("#{$1}#{$2.upcase}")}}.to_java
27
25
  end
28
26
 
29
27
  def to_s
@@ -62,4 +60,4 @@ module Rhino
62
60
 
63
61
  end
64
62
  end
65
- end
63
+ end
data/lib/rhino/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Rhino
3
- VERSION = "1.72.7"
3
+ VERSION = "1.72.8"
4
4
  end
@@ -20,6 +20,7 @@ module Rhino
20
20
  when String,Numeric then object
21
21
  when TrueClass,FalseClass then object
22
22
  when Array then J::NativeArray.new(object.to_java)
23
+ when Hash then ruby_hash_to_native(object)
23
24
  when Proc,Method then RubyFunction.new(object)
24
25
  when NativeObject then object.j
25
26
  when J::Scriptable then object
@@ -30,7 +31,17 @@ module Rhino
30
31
  def array(native)
31
32
  native.length.times.map {|i| ruby(native.get(i,native))}
32
33
  end
34
+
35
+ def ruby_hash_to_native(ruby_object)
36
+ native_object = NativeObject.new
37
+
38
+ ruby_object.each_pair do |k, v|
39
+ native_object[k] = v
40
+ end
41
+
42
+ native_object.j
43
+ end
33
44
 
34
- module_function :ruby, :javascript, :array
45
+ module_function :ruby, :javascript, :array, :ruby_hash_to_native
35
46
  end
36
47
  end
@@ -53,7 +53,7 @@ describe Rhino::To do
53
53
  it "it unwraps wrapped java objects" do
54
54
  Context.open do |cx|
55
55
  scope = cx.scope
56
- Java::JavaLang::String.new("Hello World").tap do |str|
56
+ java.lang.String.new("Hello World").tap do |str|
57
57
  J::NativeJavaObject.new(scope.j, str, str.getClass()).tap do |o|
58
58
  To.ruby(o).should == "Hello World"
59
59
  end
@@ -97,6 +97,13 @@ describe Rhino::To do
97
97
  a.get(3,a).should be(4)
98
98
  end
99
99
  end
100
+
101
+ it "converts ruby hashes into native objects" do
102
+ To.javascript({ :bare => true }).tap do |h|
103
+ h.should be_kind_of(J::NativeObject)
104
+ h.get("bare", h).should be(true)
105
+ end
106
+ end
100
107
 
101
108
  it "converts procs and methods into native functions" do
102
109
  to(lambda {|lhs,rhs| lhs * rhs}).tap do |f|
@@ -132,4 +139,4 @@ describe Rhino::To do
132
139
  def to(object)
133
140
  To.javascript(object)
134
141
  end
135
- end
142
+ end
data/therubyrhino.gemspec CHANGED
@@ -16,4 +16,5 @@ Gem::Specification.new do |s|
16
16
  s.summary = %q{Embed the Rhino JavaScript interpreter into JRuby}
17
17
 
18
18
  s.add_development_dependency "rspec"
19
+ s.add_development_dependency "jruby-openssl"
19
20
  end
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: therubyrhino
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 72
8
- - 7
9
- version: 1.72.7
4
+ prerelease:
5
+ version: 1.72.8
10
6
  platform: ruby
11
7
  authors:
12
8
  - Charles Lowell
@@ -14,21 +10,31 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-01-10 00:00:00 -06:00
13
+ date: 2011-06-28 00:00:00 -05:00
18
14
  default_executable:
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
21
17
  name: rspec
22
18
  version_requirements: &id001 !ruby/object:Gem::Requirement
19
+ none: false
23
20
  requirements:
24
21
  - - ">="
25
22
  - !ruby/object:Gem::Version
26
- segments:
27
- - 0
28
23
  version: "0"
29
24
  requirement: *id001
30
25
  prerelease: false
31
26
  type: :development
27
+ - !ruby/object:Gem::Dependency
28
+ name: jruby-openssl
29
+ version_requirements: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ requirement: *id002
36
+ prerelease: false
37
+ type: :development
32
38
  description: Call javascript code and manipulate javascript objects from ruby. Call ruby code and manipulate ruby objects from javascript.
33
39
  email: cowboyd@thefrontside.net
34
40
  executables: []
@@ -41,7 +47,6 @@ files:
41
47
  - .gitignore
42
48
  - .gitmodules
43
49
  - Gemfile
44
- - Gemfile.lock
45
50
  - History.txt
46
51
  - README.rdoc
47
52
  - Rakefile
@@ -74,23 +79,27 @@ rdoc_options: []
74
79
  require_paths:
75
80
  - lib
76
81
  required_ruby_version: !ruby/object:Gem::Requirement
82
+ none: false
77
83
  requirements:
78
84
  - - ">="
79
85
  - !ruby/object:Gem::Version
86
+ hash: 2
80
87
  segments:
81
88
  - 0
82
89
  version: "0"
83
90
  required_rubygems_version: !ruby/object:Gem::Requirement
91
+ none: false
84
92
  requirements:
85
93
  - - ">="
86
94
  - !ruby/object:Gem::Version
95
+ hash: 2
87
96
  segments:
88
97
  - 0
89
98
  version: "0"
90
99
  requirements: []
91
100
 
92
101
  rubyforge_project: therubyrhino
93
- rubygems_version: 1.3.6
102
+ rubygems_version: 1.5.1
94
103
  signing_key:
95
104
  specification_version: 3
96
105
  summary: Embed the Rhino JavaScript interpreter into JRuby
data/Gemfile.lock DELETED
@@ -1,16 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- therubyrhino (1.72.7)
5
-
6
- GEM
7
- remote: http://rubygems.org/
8
- specs:
9
- rspec (1.3.0)
10
-
11
- PLATFORMS
12
- java
13
-
14
- DEPENDENCIES
15
- rspec
16
- therubyrhino!