Class: Library
- Inherits:
-
Object
- Object
- Library
- Defined in:
- lib/jruby_art/library.rb
Overview
This class knows where to find JRubyArt libraries
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#ppath ⇒ Object
readonly
Returns the value of attribute ppath.
Instance Method Summary collapse
- #add_binaries_to_classpath ⇒ Object
- #exist? ⇒ Boolean
-
#initialize(name) ⇒ Library
constructor
A new instance of Library.
- #library_path ⇒ Object
- #load_jars ⇒ Object
- #locate ⇒ Object
- #locate_installed_java ⇒ Object
- #locate_java ⇒ Object
- #native_binaries? ⇒ Boolean
- #ruby? ⇒ Boolean
Constructor Details
#initialize(name) ⇒ Library
Returns a new instance of Library.
14 15 16 17 |
# File 'lib/jruby_art/library.rb', line 14 def initialize(name) @name = name @ruby = true end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
12 13 14 |
# File 'lib/jruby_art/library.rb', line 12 def dir @dir end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/jruby_art/library.rb', line 12 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
12 13 14 |
# File 'lib/jruby_art/library.rb', line 12 def path @path end |
#ppath ⇒ Object (readonly)
Returns the value of attribute ppath.
12 13 14 |
# File 'lib/jruby_art/library.rb', line 12 def ppath @ppath end |
Instance Method Details
#add_binaries_to_classpath ⇒ Object
83 84 85 86 |
# File 'lib/jruby_art/library.rb', line 83 def add_binaries_to_classpath native_loader = NativeLoader.new native_loader.add_native_path(ppath) end |
#exist? ⇒ Boolean
62 63 64 |
# File 'lib/jruby_art/library.rb', line 62 def exist? path.exist? end |
#library_path ⇒ Object
54 55 56 |
# File 'lib/jruby_art/library.rb', line 54 def library_path Processing::RP_CONFIG.fetch('library_path', "#{ENV['HOME']}/.jruby_art") end |
#load_jars ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/jruby_art/library.rb', line 66 def load_jars Dir.glob("#{dir}/*.jar").sort.each do |jar| require jar end return unless native_binaries? add_binaries_to_classpath end |
#locate ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/jruby_art/library.rb', line 19 def locate return if (@path = Pathname.new( File.join(SKETCH_ROOT, 'library', name, "#{name}.rb") )).exist? return if (@path = Pathname.new( File.join(K9_ROOT, 'library', name, "#{name}.rb") )).exist? locate_java end |
#locate_installed_java ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/jruby_art/library.rb', line 39 def locate_installed_java return if dir.directory? if Processing::RP_CONFIG.fetch('processing_ide', false) prefix = library_path @dir = Pathname.new(File.join(prefix, 'libraries', name, 'library')) @path = dir.join(Pathname.new("#{name}.jar")) else @dir = Pathname.new( File.join(ENV['HOME'], '.jruby_art', 'libraries', name, 'library') ) end @path = dir.join(Pathname.new("#{name}.jar")) end |
#locate_java ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/jruby_art/library.rb', line 30 def locate_java @dir = Pathname.new( File.join(SKETCH_ROOT, 'library', name) ) return @path = dir.join(Pathname.new("#{name}.jar")) if dir.directory? locate_installed_java end |
#native_binaries? ⇒ Boolean
75 76 77 78 79 80 81 |
# File 'lib/jruby_art/library.rb', line 75 def native_binaries? native_folder = NativeFolder.new native = native_folder.name @ppath = File.join(dir, native) File.directory?(ppath) && !Dir.glob(File.join(ppath, native_folder.extension)).empty? end |
#ruby? ⇒ Boolean
58 59 60 |
# File 'lib/jruby_art/library.rb', line 58 def ruby? path.extname == '.rb' end |