Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ruby-processing/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def mix_proxy_into_inner_classes
klass.constants.each do |name|
const = klass.const_get name
next if const.class != Class || const.to_s.match(/^Java::/)
const.class_eval 'include Processing::Proxy'
const.class_eval('include Processing::Proxy')
end
end

Expand Down
23 changes: 15 additions & 8 deletions lib/ruby-processing/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Runner
Examples:
rp5 setup unpack_samples
rp5 run rp_samples/samples/contributed/jwishy.rb
rp5 run-app rp_samples/samples/contributed/jwishy.rb
rp5 create some_new_sketch 640 480 p3d (P3D mode example)
rp5 create some_new_sketch 640 480 --wrap (a class wrapped default sketch)
rp5 watch some_new_sketch.rb
Expand Down Expand Up @@ -63,14 +64,15 @@ def self.execute
# Dispatch central.
def execute!
case @options.action
when 'run' then run(@options.path, @options.args)
when 'watch' then watch(@options.path, @options.args)
when 'live' then live(@options.path, @options.args)
when 'create' then create(@options.path, @options.args)
when 'app' then app(@options.path)
when 'setup' then setup(@options.path)
when /-v/ then show_version
when /-h/ then show_help
when 'run' then run(@options.path, @options.args)
when 'run-app' then run_app(@options.path, @options.args)
when 'watch' then watch(@options.path, @options.args)
when 'live' then live(@options.path, @options.args)
when 'create' then create(@options.path, @options.args)
when 'app' then app(@options.path)
when 'setup' then setup(@options.path)
when /-v/ then show_version
when /-h/ then show_help
else
show_help
end
Expand Down Expand Up @@ -103,6 +105,11 @@ def run(sketch, args)
spin_up('run.rb', sketch, args)
end

def run_app(sketch, args)
ensure_exists(sketch)
spin_up('run_app.rb', sketch, args)
end

# Run a sketch, keeping an eye on it's file, and reloading
# whenever it changes.
def watch(sketch, args)
Expand Down
13 changes: 9 additions & 4 deletions lib/ruby-processing/runners/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,23 @@ def setup
EOS

# This method is the common entry point to run a sketch, bare or complete.

def self.run_app
load SKETCH_PATH
Processing::App.sketch_class.new unless $app
end

def self.load_and_run_sketch
source = read_sketch_source
wrapped = !source.match(/^[^#]*< Processing::App/).nil?
no_methods = source.match(/^[^#]*(def\s+setup|def\s+draw)/).nil?
if wrapped
load SKETCH_PATH
Processing::App.sketch_class.new unless $app
run_app
return
end
code = no_methods ? format(NAKED_WRAP, source) : format(BARE_WRAP, source)
Object.class_eval code, SKETCH_PATH, -1
Object.class_eval(code, SKETCH_PATH, -1)
Processing::App.sketch_class.new
code = no_methods ? format(NAKED_WRAP, source) : format(BARE_WRAP, source)
end

# Read in the sketch source code. Needs to work both online and offline.
Expand Down
3 changes: 3 additions & 0 deletions lib/ruby-processing/runners/run_app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require_relative 'base'

Processing.run_app