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

Thursday, 26 December 2013

Rakefile to run JRubyArt sketches in a directory from netbeans (tested with samples/contributed)

NB need to adjust path to "k9" executable...., since we are running with development version in netbeans (not an externally installed version)
# Simple demo Rakefile to autorun samples in current directory
# from netbeans, adjust path to k9 executable as required

SAMPLES_DIR="./"

desc 'run demo'
task :default => [:demo]

desc 'demo'
task :demo do
  samples_list.shuffle.each{|sample| run_sample sample}
end

def samples_list
  files = []
  Dir.chdir(SAMPLES_DIR)
  Dir.glob("*.rb").each do |file|
    files << File.join(SAMPLES_DIR, file)
  end
  return files
end

def run_sample(sample_name)
  puts "Running #{sample_name}...quit to run next sample"
  open("|../../bin/k9 run #{sample_name}", "r") do |io|
    while l = io.gets
      puts(l.chop)
    end
  end
end

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