ruby-processing / propane

A simpler ruby-processing for linux/Windows/MacOS?
https://ruby-processing.github.io/propane
GNU General Public License v3.0
27 stars 1 forks source link

find_method doesnt exist #4

Closed jtoy closed 7 years ago

jtoy commented 7 years ago

According to the docs: Because of this method madness, Propane::App has a convenience method for searching through them. find_method('ellipse') will return a list of the method names that may match what you’re looking for: ‘ellipse’, ‘ellipseMode’, and ‘ellipse_mode’.

https://ruby-processing.github.io/propane/methods/processing_api

Environment

propane (2.3.0 java)

jruby -v jruby 9.1.7.0 (2.3.1) 2017-01-11 68056ae Java HotSpot(TM) 64-Bit Server VM 25.102-b14 on 1.8.0_102-b14 +jit [darwin-x86_64] uname -a Darwin MacBook-Pro-6.local 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64 java -version java version "1.8.0_102" Java(TM) SE Runtime Environment (build 1.8.0_102-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)

Expected Behavior

this method should work from irb Propane::App.find_method 'ellipse'

it fails with: Propane::App.find_method 'ellipse' NoMethodError: undefined method find_method' for Propane::App:Class Did you mean? define_method from org/jruby/RubyBasicObject.java:1653:inmethod_missing'

Actual Behavior

no method found

monkstone commented 7 years ago

This is advanced stuff and perhaps not well explained (especially for propane, perhaps you could help make it better). You actually need to create an instance to use find_method, and then you can use the global variable $app. My advice is to create a sketch using propane -c my_sketch 200 200. Fire up jirb or pry (I use jpry command see below)

# in my .bashrc file
alias jpry="jruby -e \"require 'pry'; binding.pry\""
load 'my_sketch.rb'

# at pry irb prompt
$app.find_method 'ellipse'

ellipse ellipseMode ellipse_mode => true [3] pry(main)> $app.find_method('ellipse') => [:ellipse, :ellipseMode, :ellipse_mode] [4] pry(main)>

PS: to install pry with jruby either

jruby -S gem install pry

or

jgem install pry
monkstone commented 7 years ago

Even for JRubyArt the explanation of live coding is hidden in the wiki. https://github.com/ruby-processing/JRubyArt/wiki/Live-Coding

For propane you could do:-

[1] pry(main)> require 'propane' => true [2] pry(main)> class MySketch < Propane::App [2] pry(main) def settings [2] pry(main) size 200, 200 [2] pry(main) end
[2] pry(main)
def setup [2] pry(main) background 0, 0, 200 [2] pry(main) end
[2] pry(main)* end
=> :setup [3] pry(main)> MySketch.new => #<MySketch:0x7923f5b3 @height=200, @width=200, @arguments=[], @declared_fields={"sketchPath"=>#, "key"=>#, "frameRate"=>#, "mousePressed"=>#, "keyPressed"=>#}, @options={}, @render_mode=nil> [4] pry(main)> $app.find_method 'ellipse' => [:ellipse, :ellipseMode, :ellipse_mode] [5] pry(main)> edit -p MySketch#setup [6] pry(main)> MySketch.new

in [5] relies on setup similar to JRubyArt eg set pry editor to vim you can then edit say background color, but need to create new instance to see the change.

jtoy commented 7 years ago

Great, I think getting the docs cleaned up a bit will be useful. ill look into it.