-
Notifications
You must be signed in to change notification settings - Fork 0
Using Rubygems
Because Ruby-Processing uses a JARed copy of JRuby it will only look for Gems that came installed in that JAR.
It would be nice to use the power of Rubygems, so let’s tell our Sketch where to find them.
First, I would recommend installing JRuby itself, then installing all gems that you need with JRuby:
> sudo jruby -S gem install gem_name
Assuming that you have put JRuby in /usr/local/jruby all gems will install to /usr/local/jruby/lib/ruby/gems/1.8/gems
Now, in your sketch add the following lines before you want to require a Rubygem library:
require 'rubygems'
Gem.clear_paths
ENV['GEM_HOME'] = File.join(Dir.pwd, 'vendor')
ENV['GEM_PATH'] = File.join(Dir.pwd, 'vendor')
This tells Rubygems to ignore all assigned paths and assume that the new path is under ‘vendor’.
Create the vendor directory:
> mkdir vendor
Now, copy all JRuby gems into vendor/gems
> cp -rf /usr/local/jruby/lib/ruby/gems/1.8/gems vendor/gems
And you must also copy the gemspecs
> cp -rf /usr/local/jruby/lib/ruby/gems/1.8/specifications vendor/specifications
Now just require your Rubygems as you normally would