Class: Naether::Java::Ruby
- Inherits:
-
Object
- Object
- Naether::Java::Ruby
- Includes:
- Singleton
- Defined in:
- lib/naether/java.rb
Overview
Handle loading jars for Ruby via Rjb
Instance Attribute Summary collapse
-
#loaded_jars ⇒ Object
readonly
Returns the value of attribute loaded_jars.
Instance Method Summary collapse
-
#initialize ⇒ Ruby
constructor
A new instance of Ruby.
- #load_jars(jars) ⇒ Object
Constructor Details
#initialize ⇒ Ruby
Returns a new instance of Ruby.
118 119 120 121 122 123 124 125 126 |
# File 'lib/naether/java.rb', line 118 def initialize() require 'rjb' # Call Rjb::load with an empty classpath, incase Rjb::load has already been called java_opts = (ENV['JAVA_OPTS'] || ENV['JAVA_OPTIONS']).to_s.split Rjb::load("", java_opts) @loaded_jars = [] end |
Instance Attribute Details
#loaded_jars ⇒ Object (readonly)
Returns the value of attribute loaded_jars.
116 117 118 |
# File 'lib/naether/java.rb', line 116 def loaded_jars @loaded_jars end |
Instance Method Details
#load_jars(jars) ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/naether/java.rb', line 128 def load_jars(jars) loaded_jars = [] unless jars.is_a?( Array ) jars = [jars] end jars.each do |jar| = File.(jar) if !@loaded_jars.include? loaded_jars << @loaded_jars << end end unless loaded_jars.empty? Rjb::add_jar( loaded_jars ) end loaded_jars end |