java_override 0.1.3-java → 0.1.4-java

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,29 +2,33 @@ Java::Override JRuby Module
2
2
  ===========================
3
3
 
4
4
  * [Homepage](https://rubygems.org/gems/java_override)
5
- * [Documentation](http://rubydoc.info/gems/java_override/frames)
5
+ * [Documentation](https://github.com/szw/java_override/blob/master/README.md)
6
6
 
7
7
  Description
8
8
  -----------
9
9
 
10
- Java::Override is a JRuby module enabling overriding native Java methods with
11
- Ruby naming conventions. JRuby allows you to call Java methods (of Java classes/interfaces)
12
- with Ruby conventions. You can use so called *snake_case*, Java Beans accessors are
13
- *translated* to Ruby ones (e.g. <code>getFooBar</code> can be accessed via <code>foo\_bar</code>,
14
- <code>isFooBar</code> via <code>foo\_bar?</code>, or <code>setFooBar</code> via <code>foo\_bar=</code>).
15
- Those methods are added to Java classes as JRuby aliases. However, if you want to override
16
- a Java method you cannot override such alias because Java will not see it. Java will do polymorphic
17
- call of its own, native methods. Therefore you have to override native Java methods and it
18
- doesn't look pretty in JRuby code.
19
-
20
- The Java::Override module abolishes this inconvenience. Once included in the subclass it
21
- creates aliases to native java methods and supports inheritance and polymorphism that way.
10
+ Java::Override is a JRuby module that enables overriding native Java methods with
11
+ Ruby naming conventions. JRuby allows you to call Java methods (members of native
12
+ Java classes/interfaces) with Ruby naming style. Therefore you can use *snake_case* and
13
+ Ruby-like accessors instead of JavaBean ones.
14
+
15
+ In JRuby JavaBean accessors are *translated* to their Ruby counterparts
16
+ (e.g. <code>getFooBar</code> can be accessed via <code>foo\_bar</code>,
17
+ <code>isFooBar</code> via <code>foo\_bar?</code>, or <code>setFooBar</code> via
18
+ <code>foo\_bar=</code>). Those methods are added to Java classes as JRuby aliases.
19
+ However, if we want to override a Java method we cannot define a Ruby-like method
20
+ because JVM won't see it. JVM performs polymorphic calls on its own, native methods.
21
+ And so we have to override native Java methods and it doesn't look much pretty
22
+ in JRuby code.
23
+
24
+ But the Java::Override module abolishes this inconvenience. Once included in the subclass
25
+ it creates aliases to native Java methods and supports inheritance and polymorphism that way.
22
26
  Moreover, it adds proper aliases for Java interfaces included as modules.
23
27
 
24
28
  Examples
25
29
  --------
26
30
 
27
- Look at the following implementation of javax.swing.table.AbstractTableModel class.
31
+ Here is a good looking simple implementation of <code>javax.swing.table.AbstractTableModel</code> class.
28
32
 
29
33
  require 'java/override'
30
34
 
data/Rakefile CHANGED
@@ -26,6 +26,6 @@ Gem::Tasks.new
26
26
  require 'rake/testtask'
27
27
  Rake::TestTask.new do |test|
28
28
  test.libs << 'test'
29
- test.pattern = 'test/**/test_*.rb'
29
+ test.pattern = 'test/**/*_test.rb'
30
30
  test.verbose = true
31
31
  end
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
6
6
  gem.name = "java_override"
7
7
  gem.version = Java::Override::VERSION
8
8
  gem.summary = %q{Support for Java class and interface inheritance in JRuby}
9
- gem.description = %q{Support for Java class and interface inheritance in JRuby. Enable overriding native Java methods with JRuby ones follwing Ruby naming conventions.}
9
+ gem.description = %q{Support for Java class and interface inheritance in JRuby. Enable overriding native Java methods with JRuby ones following Ruby naming conventions.}
10
10
  gem.license = "MIT"
11
11
  gem.authors = ["Szymon Wrozynski"]
12
12
  gem.email = "szymon@wrozynski.com"
@@ -1,6 +1,6 @@
1
1
  module Java
2
2
  module Override
3
3
  # Java::Override version
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
6
6
  end
@@ -12,9 +12,8 @@ java_import "TestSuperclass"
12
12
  FileUtils.rm 'TestInterface.class'
13
13
  FileUtils.rm 'TestSuperclass.class'
14
14
 
15
- class TestJavaOverride < Test::Unit::TestCase
15
+ class JavaOverrideTest < Test::Unit::TestCase
16
16
  def setup
17
- @superclass = TestSuperclass.new
18
17
  @my_class = MyClass.new
19
18
  end
20
19
 
@@ -35,8 +34,10 @@ class TestJavaOverride < Test::Unit::TestCase
35
34
  assert_equal "MyClassGetter: MyClassSetter: FOO", @my_class.foo
36
35
  assert_equal "MyClassGetter: MyClassSetter: FOO", @my_class.getFoo
37
36
 
38
- assert TestSuperclass.new.foo_bar?
39
- assert TestSuperclass.new.isFooBar
37
+ test_superclass = TestSuperclass.new
38
+
39
+ assert test_superclass.foo_bar?
40
+ assert test_superclass.isFooBar
40
41
 
41
42
  refute @my_class.foo_bar?
42
43
  refute @my_class.isFooBar
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: java_override
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.3
5
+ version: 0.1.4
6
6
  platform: java
7
7
  authors:
8
8
  - Szymon Wrozynski
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-17 00:00:00.000000000 Z
12
+ date: 2012-08-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -75,7 +75,7 @@ dependencies:
75
75
  none: false
76
76
  prerelease: false
77
77
  type: :development
78
- description: Support for Java class and interface inheritance in JRuby. Enable overriding native Java methods with JRuby ones follwing Ruby naming conventions.
78
+ description: Support for Java class and interface inheritance in JRuby. Enable overriding native Java methods with JRuby ones following Ruby naming conventions.
79
79
  email: szymon@wrozynski.com
80
80
  executables: []
81
81
  extensions: []
@@ -93,7 +93,7 @@ files:
93
93
  - test/helper.rb
94
94
  - test/java/TestInterface.java
95
95
  - test/java/TestSuperclass.java
96
- - test/test_java_override.rb
96
+ - test/java_override_test.rb
97
97
  homepage: https://rubygems.org/gems/java_override
98
98
  licenses:
99
99
  - MIT
@@ -123,5 +123,5 @@ test_files:
123
123
  - test/helper.rb
124
124
  - test/java/TestInterface.java
125
125
  - test/java/TestSuperclass.java
126
- - test/test_java_override.rb
126
+ - test/java_override_test.rb
127
127
  ...