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

Wednesday, 20 November 2013

A Rakefile to demo ruby-processing samples

Loosely based on a Shoes4 Rakefile, here is a Rakefile to demo ruby-processing files in a folder:-

# Simple demo Rakefile to autorun samples

SAMPLES_DIR="/home/tux/samples/contributed"

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"
  system "rp5 run #{sample_name}"
end

No comments:

Post a Comment

Followers

Blog Archive

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