nested_inherited_jruby_include_package 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +16 -2
- data/lib/core/src/main/ruby/jruby/java/core_ext/module.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3920b3a4d05fffb3446866663dcb68bb37e3758cafefea3e0f6d9f526f4dd46
|
4
|
+
data.tar.gz: 128acb0e72ae6b858523b38d0def2213ee2f8b4e98fcdd8ee7601349f84c90a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f14d9126cbd3719684d687cdc0f6c871872a767f0e5d4a53ffd650a7fa38a51b6ad207fdbdf4bd66eb7dedcd054c7b5e7e0e64a82317398631cd6d0c9201a61
|
7
|
+
data.tar.gz: c5c7f0e8e27a79a1bdccd150fcc9ecbcc08f67bba03b9ceb0da04f8bd9efc4c3d0678468a6b4a8bcf2fa7bb3bcede7ee1966822ddb8fb474ba802f758fb22552
|
data/README.md
CHANGED
@@ -41,6 +41,20 @@ SubClass.new
|
|
41
41
|
# prints #<Java::JavaUtil::Arrays::ArrayList:0x7ce3cb8e>
|
42
42
|
```
|
43
43
|
|
44
|
+
Example (java inheritance):
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
module GUI
|
48
|
+
include_package 'javax.swing'
|
49
|
+
include_package 'java.awt.image' # BufferedImage
|
50
|
+
# bellow won't work without accessing BufferedImage before :
|
51
|
+
class ShowImage < JFrame
|
52
|
+
p BufferedImage.new(10, 20, BufferedImage::TYPE_BYTE_BINARY)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
# prints #<Java::JavaAwtImage::BufferedImage:0x2f112965>
|
56
|
+
```
|
57
|
+
|
44
58
|
More examples can be found in:
|
45
59
|
|
46
60
|
[spec/lib/core/src/main/ruby/jruby/java/core_ext/module_spec.rb](spec/lib/core/src/main/ruby/jruby/java/core_ext/module_spec.rb)
|
@@ -49,7 +63,7 @@ More examples can be found in:
|
|
49
63
|
|
50
64
|
Add the following to `Gemfile`:
|
51
65
|
```
|
52
|
-
gem 'nested_inherited_jruby_include_package', '~> 0.
|
66
|
+
gem 'nested_inherited_jruby_include_package', '~> 0.3.0'
|
53
67
|
```
|
54
68
|
|
55
69
|
And, then run:
|
@@ -59,7 +73,7 @@ jruby -S bundle install
|
|
59
73
|
|
60
74
|
If you are not using Bundler, run:
|
61
75
|
```
|
62
|
-
jruby -S gem install nested_inherited_jruby_include_package -v 0.
|
76
|
+
jruby -S gem install nested_inherited_jruby_include_package -v 0.3.0
|
63
77
|
```
|
64
78
|
|
65
79
|
Then add this line to your code:
|
@@ -14,7 +14,7 @@ class Module
|
|
14
14
|
end,
|
15
15
|
|
16
16
|
collect_ancestors_namespaces: lambda do |collection, m|
|
17
|
-
return if collection.include?(m)
|
17
|
+
return if m.is_a?(Java::JavaPackage) || collection.include?(m)
|
18
18
|
collection << m
|
19
19
|
result = (m.ancestors + hidden_methods[:namespaces].call(m)[1..-1]).uniq
|
20
20
|
if result.size == 1
|
@@ -39,6 +39,7 @@ class Module
|
|
39
39
|
end,
|
40
40
|
|
41
41
|
java_aliases_from_ancestors_namespaces: lambda do |m|
|
42
|
+
return [] if m.is_a?(Java::JavaPackage)
|
42
43
|
m.ancestors.map do |klass|
|
43
44
|
hidden_methods[:java_aliases_from_namespaces].call(klass)
|
44
45
|
end.reverse.reduce({}, :merge)
|