Module: Rubeus::Extensions
- Extended by:
- Verboseable
- Defined in:
- lib/rubeus/extensions.rb,
lib/rubeus/extensions/java.rb,
lib/rubeus/extensions/javax.rb
Defined Under Namespace
Modules: Java, Javax
Constant Summary
collapse
"jp.rubybizcommons.rubeus.extensions".freeze
RUBEUS_EXTRA_PACKAGE.split('.').freeze
Class Method Summary
collapse
log_if_verbose, out, out=
Class Method Details
.apply_for(java_fqn) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/rubeus/extensions.rb', line 56
def apply_for(java_fqn)
log_if_verbose("apply_for(#{java_fqn.inspect})") do
extension = self.find_for(java_fqn)
return nil unless extension
@extension_applied ||= []
unless @extension_applied.include?(java_fqn)
log_if_verbose("JavaUtilities.extend_proxy(#{java_fqn})") do
JavaUtilities.extend_proxy(java_fqn) do
include extension
end
end
@extension_applied << java_fqn
end
end
end
|
.class_name_for(java_fqn_or_parts) ⇒ Object
29
30
31
32
|
# File 'lib/rubeus/extensions.rb', line 29
def class_name_for(java_fqn_or_parts)
parts = package_parts(java_fqn_or_parts)
"Rubeus::Extensions::%s" % parts.map{|part|part.camelize}.join('::')
end
|
.find_for(java_fqn) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/rubeus/extensions.rb', line 34
def find_for(java_fqn)
parts = java_fqn.split('.')
extension_path = path_for(parts)
begin
log_if_verbose("require(#{extension_path.inspect})") do
require(extension_path)
end
rescue LoadError => e
return nil
end
begin
klass_name = class_name_for(parts)
log_if_verbose("instance_eval(#{klass_name.inspect})") do
instance_eval(klass_name)
end
rescue NameError => e
return nil
end
end
|
.path_for(java_fqn_or_parts) ⇒ Object
24
25
26
27
|
# File 'lib/rubeus/extensions.rb', line 24
def path_for(java_fqn_or_parts)
parts = package_parts(java_fqn_or_parts)
"rubeus/extensions/%s" % parts.map{|part|part.underscore}.join('/')
end
|
.verbose ⇒ Object
11
|
# File 'lib/rubeus/extensions.rb', line 11
def verbose; ::Rubeus.verbose; end
|