Skip to content

Commit 1030098

Browse files
committed
autorun samples from top directory
1 parent 98ea525 commit 1030098

File tree

6 files changed

+182
-0
lines changed

6 files changed

+182
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ WIP to complete translation from JRubyArt to propane using [this conversion tool
55

66
See how to install [java libraries here][contributed]
77

8+
To autorun many samples `cd` this directory and `rake` for others like pbox2d
9+
`rake pbox2d` you get the idea (read the Rakefile). NB: not all samples ge autorun and where appropriate you need to install library or gem.
810

911
[conversion]:https://gist.github.com/monkstone/6f61ecf6c0f222d9b80250bd60a8c84f
1012
[examples]:https://github.com/ruby-processing/JRubyArt-examples

Rakefile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# -*- encoding: utf-8 -*-
2+
3+
PRWD = File.expand_path(__dir__)
4+
5+
desc 'run contributed samples'
6+
task :default => [:all]
7+
8+
desc 'run all autorun samples except hype'
9+
task :all do
10+
Rake::Task[:contributed].execute
11+
Rake::Task[:vecmath].execute
12+
Rake::Task[:shaders].execute
13+
Rake::Task[:slider].execute
14+
end
15+
16+
desc 'run contributed samples'
17+
task :contributed do
18+
sh "cd #{PRWD}/contributed && rake"
19+
end
20+
21+
desc 'shaders'
22+
task :shaders do
23+
sh "cd #{PRWD}/processing_app/topics/shaders && rake"
24+
end
25+
26+
desc 'vecmath'
27+
task :vecmath do
28+
sh "cd #{PRWD}/processing_app/library/vecmath/vec2d && rake"
29+
sh "cd #{PRWD}/processing_app/library/vecmath/vec3d && rake"
30+
sh "cd #{PRWD}/processing_app/library/vecmath/arcball && rake"
31+
end
32+
33+
desc 'hype'
34+
task :hype do
35+
sh "cd #{PRWD}/external_library/java/hype && rake"
36+
end
37+
38+
desc 'slider'
39+
task :slider do
40+
sh "cd #{PRWD}/processing_app/library/slider && rake"
41+
end
42+
43+
desc 'hemesh'
44+
task :hemesh do
45+
sh "cd #{PRWD}/external_library/java/hemesh && rake"
46+
end
47+
48+
desc 'pbox2d'
49+
task :pbox2d do
50+
sh "cd #{PRWD}/external_library/gem/pbox2d && rake"
51+
sh "cd #{PRWD}/external_library/gem/pbox2d/revolute_joint && jruby revolute_joint.rb"
52+
sh "cd #{PRWD}/external_library/gem/pbox2d/test_contact && jruby test_contact.rb"
53+
sh "cd #{PRWD}/external_library/gem/pbox2d/mouse_joint && jruby mouse_joint.rb"
54+
sh "cd #{PRWD}/external_library/gem/pbox2d/distance_joint && jruby distance_joint.rb"
55+
end
56+
57+
desc 'wordcram'
58+
task :wordcram do
59+
sh "cd #{PRWD}/external_library/gem/ruby_wordcram && rake"
60+
end

external_library/gem/pbox2d/Rakefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Simple demo Rakefile to autorun samples in current directory
2+
# adjust path to rp5 executable, and or opts as required
3+
4+
SAMPLES_DIR = './'
5+
6+
desc 'run demo'
7+
task default: [:demo]
8+
9+
desc 'demo'
10+
task :demo do
11+
samples_list.shuffle.each { |sample| run_sample sample }
12+
end
13+
14+
def samples_list
15+
files = []
16+
Dir.chdir(SAMPLES_DIR)
17+
Dir.glob('*.rb').each do |file|
18+
files << File.join(SAMPLES_DIR, file)
19+
end
20+
return files
21+
end
22+
23+
def run_sample(sample_name)
24+
puts "Running #{sample_name}...quit to run next sample"
25+
open("|jruby #{sample_name}", 'r') do |io|
26+
while l = io.gets
27+
puts(l.chop)
28+
end
29+
end
30+
end
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Simple demo Rakefile to autorun samples in current directory
2+
# adjust path to rp5 executable, and or opts as required
3+
4+
SAMPLES_DIR = './'
5+
6+
desc 'run demo'
7+
task default: [:demo]
8+
9+
desc 'demo'
10+
task :demo do
11+
samples_list.shuffle.each { |sample| run_sample sample }
12+
end
13+
14+
def samples_list
15+
files = []
16+
Dir.chdir(SAMPLES_DIR)
17+
Dir.glob('*.rb').each do |file|
18+
files << File.join(SAMPLES_DIR, file)
19+
end
20+
return files
21+
end
22+
23+
def run_sample(sample_name)
24+
puts "Running #{sample_name}...quit to run next sample"
25+
open("|jruby #{sample_name}", 'r') do |io|
26+
while l = io.gets
27+
puts(l.chop)
28+
end
29+
end
30+
end

external_library/java/hemesh/Rakefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Simple demo Rakefile to autorun samples in current directory
2+
# adjust path to rp5 executable, and or opts as required
3+
4+
SAMPLES_DIR = './'
5+
6+
desc 'run demo'
7+
task default: [:demo]
8+
9+
desc 'demo'
10+
task :demo do
11+
samples_list.shuffle.each { |sample| run_sample sample }
12+
end
13+
14+
def samples_list
15+
files = []
16+
Dir.chdir(SAMPLES_DIR)
17+
Dir.glob('*.rb').each do |file|
18+
files << File.join(SAMPLES_DIR, file)
19+
end
20+
return files
21+
end
22+
23+
def run_sample(sample_name)
24+
puts "Running #{sample_name}...quit to run next sample"
25+
open("|jruby #{sample_name}", 'r') do |io|
26+
while l = io.gets
27+
puts(l.chop)
28+
end
29+
end
30+
end

external_library/java/hype/Rakefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Simple demo Rakefile to autorun samples in current directory
2+
# adjust path to rp5 executable, and or opts as required
3+
4+
SAMPLES_DIR = './'
5+
6+
desc 'run demo'
7+
task default: [:demo]
8+
9+
desc 'demo'
10+
task :demo do
11+
samples_list.shuffle.each { |sample| run_sample sample }
12+
end
13+
14+
def samples_list
15+
files = []
16+
Dir.chdir(SAMPLES_DIR)
17+
Dir.glob('*.rb').each do |file|
18+
files << File.join(SAMPLES_DIR, file)
19+
end
20+
return files
21+
end
22+
23+
def run_sample(sample_name)
24+
puts "Running #{sample_name}...quit to run next sample"
25+
open("|jruby #{sample_name}", 'r') do |io|
26+
while l = io.gets
27+
puts(l.chop)
28+
end
29+
end
30+
end

0 commit comments

Comments
 (0)