Class: Library
- Inherits:
-
Object
- Object
- Library
- Defined in:
- lib/jruby_art/library.rb
Overview
This class knows where to find propane 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
- #bundled? ⇒ Boolean
- #exist? ⇒ Boolean
-
#initialize(name) ⇒ Library
constructor
A new instance of Library.
- #load_jars ⇒ Object
- #locate ⇒ Object
- #locate_installed_java ⇒ Object
- #locate_java ⇒ Object
- #native_binaries? ⇒ Boolean
- #root ⇒ Object
- #ruby? ⇒ Boolean
- #sketchbook ⇒ Object
Constructor Details
#initialize(name) ⇒ Library
Returns a new instance of Library.
13 14 15 16 |
# File 'lib/jruby_art/library.rb', line 13 def initialize(name) @name = name @ruby = true end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
11 12 13 |
# File 'lib/jruby_art/library.rb', line 11 def dir @dir end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/jruby_art/library.rb', line 11 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/jruby_art/library.rb', line 11 def path @path end |
#ppath ⇒ Object (readonly)
Returns the value of attribute ppath.
11 12 13 |
# File 'lib/jruby_art/library.rb', line 11 def ppath @ppath end |
Instance Method Details
#add_binaries_to_classpath ⇒ Object
80 81 82 83 |
# File 'lib/jruby_art/library.rb', line 80 def add_binaries_to_classpath native_loader = NativeLoader.new native_loader.add_native_path(ppath) end |
#bundled? ⇒ Boolean
56 57 58 |
# File 'lib/jruby_art/library.rb', line 56 def bundled? BUNDLED =~ name end |
#exist? ⇒ Boolean
60 61 62 |
# File 'lib/jruby_art/library.rb', line 60 def exist? path.exist? end |
#load_jars ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/jruby_art/library.rb', line 64 def load_jars Dir.glob("#{dir}/*.jar").each do |jar| require jar end return unless native_binaries? add_binaries_to_classpath end |
#locate ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/jruby_art/library.rb', line 18 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
36 37 38 39 40 41 42 |
# File 'lib/jruby_art/library.rb', line 36 def locate_installed_java prefix = bundled? ? File.join(root, 'modes/java') : sketchbook @dir = Pathname.new( File.join(prefix, "libraries/#{name}/library") ) @path = dir.join(Pathname.new("#{name}.jar")) end |
#locate_java ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/jruby_art/library.rb', line 28 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
72 73 74 75 76 77 78 |
# File 'lib/jruby_art/library.rb', line 72 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 |
#root ⇒ Object
48 49 50 |
# File 'lib/jruby_art/library.rb', line 48 def root Processing::RP_CONFIG.fetch('PROCESSING_ROOT', "#{ENV['HOME']}/processing") end |
#ruby? ⇒ Boolean
52 53 54 |
# File 'lib/jruby_art/library.rb', line 52 def ruby? path.extname == '.rb' end |
#sketchbook ⇒ Object
44 45 46 |
# File 'lib/jruby_art/library.rb', line 44 def sketchbook Processing::RP_CONFIG.fetch('sketchbook_path', "#{ENV['HOME']}/sketchbook") end |