Sha256: 81086903218a6da0e8638afc5f7572a5c6929ce836f61e991b29e20ba00a49bd
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
# -*- encoding : utf-8 -*- SKETCH_PATH ||= ARGV.shift SKETCH_ROOT ||= File.dirname(SKETCH_PATH) # we can safely require app.rb as we are using a jruby runtime require_relative '../app' # More processing module module Processing # For use with "bare" sketches that don't want to define a class or methods BARE_WRAP = <<-EOS class Sketch < Processing::App %s end EOS NAKED_WRAP = <<-EOS class Sketch < Processing::App def setup size(DEFAULT_WIDTH, DEFAULT_HEIGHT) %s no_loop end end 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 run_app return end code = no_methods ? format(NAKED_WRAP, source) : format(BARE_WRAP, source) Object.class_eval(code, SKETCH_PATH, -1) Processing::App.sketch_class.new end # Read in the sketch source code. Needs to work both online and offline. def self.read_sketch_source File.read(SKETCH_PATH) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruby-processing-2.7.1 | lib/ruby-processing/runners/base.rb |
ruby-processing-2.7.0 | lib/ruby-processing/runners/base.rb |