We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpProcessing Implementations › ruby-processing and custom require
Page Index Toggle Pages: 1
ruby-processing and custom require (Read 4370 times)
ruby-processing and custom require
May 26th, 2009, 5:03am
 
Hi.
I recently started using ruby-processing and I have two questions:

1. How can I require and use another of my gems in a ruby-processing context? When I use 'rp5  run <file>' none of my installed gems are found although I require 'rubygems first.

2. Is it possible to run a ruby-processing class (that inhertis from app) with the vanilla ruby binary?

Grateful for any help /Mart
Re: ruby-processing and custom require
Reply #1 - May 26th, 2009, 6:11am
 
Hi Mart.

Ruby-Processing is using the JRuby interpreter to run, and not your standard Ruby interpreter. This means that you can't run it through vanilla MRI, as it needs to run in Java to have access to Processing. This also means that you can't access your gems as usual. If you want to use a gem, the easiest thing to do is unpack it into your sketch, much like you would when you vendor a gem into a Rails project. Then you can require or load it.

Note that this will only work with pure-ruby gems. Gems that depend on native C extensions can't be run directly by JRuby. The JRuby guys are working on FFI for gems to help make Ruby gems more compatible across different Ruby implementations.
Re: ruby-processing and custom require
Reply #2 - May 30th, 2009, 2:31pm
 
Gotcha, many thank's!
Also thank you for a wonderful work. Ruby-processing is great!

Re: ruby-processing and custom require
Reply #3 - Aug 5th, 2009, 2:00pm
 
Hello guys,
I'm using YAML in my sketch and I get following error when exporting as an applet or app:
/var/lib/gems/1.8/gems/ruby-processing-1.0.8/lib/ruby-processing/exporters/base_
exporter.rb:97:in `extract_real_requires': (eval):1:in `extract_real_requires': uninitialized constant Processing::BaseExporter::YAML (NameError)

Then I tried to requre in base_exporter.rb, but that didn't work either..
Can you help?
Re: ruby-processing and custom require
Reply #4 - Aug 14th, 2009, 8:16pm
 
You've stumbled across one of the wartier parts -- Ruby-Processing trying to figure out which require and load statements are references to actual files that need to be included in the exported sketch. YAML, being part of the standard library, is clearly not one of those, but perhaps you're doing something fancy on that line that's breaking the detection. If you don't mind, please paste the line(s) in question. Otherwise, doing a plain old "require 'yaml'" on a line all by itself should pose no problem.
Re: ruby-processing and custom require
Reply #5 - May 30th, 2010, 5:19am
 
jashkenas wrote on May 26th, 2009, 6:11am:
Note that this will only work with pure-ruby gems. Gems that depend on native C extensions can't be run directly by JRuby. The JRuby guys are working on FFI for gems to help make Ruby gems more compatible across different Ruby implementations.


Do you know when this will change/where I can watch for updates
Page Index Toggle Pages: 1