Experiments with ruby-processing (processing-2.2.1) and JRubyArt for processing-3.0

Sunday 2 February 2014

More experiments with pry and ruby processing

I have found that is is indeed possible to use pry in place of irb with JRubyArt (on the pry branch of development branch of ruby processing). The most secure way is to create and install a 'java' platform version of the JRubyArt gem, requiring pry (unless you are using bundler (or rvm?) install pry using `jruby -S gem install pry`). Below is a snapshot of a ruby-processing sketch started with:-
jruby -S k9 live drawolver # update 4 Feb 2014 (default to using installed jruby)
In this case I need to use `jruby -S` because for my pry-branch I specify use of java engine (on reflection I don't think this is important), however the --gem flag is important. Now using anBy using the --gem flag we require the sketch to be actually run with an installed jruby (this seems to be required to use gems, and in this case we want to use pry-java version). In the pry branch of JRubyArt I have substituted pry for irb. As with the irb live mode you can access the sketch with `$app`, see below where no_loop command has been sent (stops the draw loop).
screenshot
Running JRubyArt in live mode (note use $app to access sketch)



What good it is, is best tested by pry afficianados, however it also occured to me that there is an alternative way of introducing/using pry. If you start a sketch in the "watch" mode you can edit the live sketch to:-
require 'pry'
# and where you want the break
binding.pry
This also works but again I'm no pry afficianado, so I will leave it to them to decide how best to proceed, but in this scenario you could edit the sketch either from pry, or with an independent editor (tested with vim for both in my case). See below, here I found I was able to set the @back variable directly (no need to call $app). In this I started the sketch in the watch mode, and edited in vim (right-hand terminal, with and unusual white background for me!!)
Now this is slightly interesting, instead of continuing to type $app in the pry repl, you can assign to app `binding = $app`. Then just carry on as though you are editing a regular ruby sketch...

No comments:

Post a Comment

Followers

About Me

My photo
I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2