Skip to content

Commit 372da39

Browse files
committed
remove bashism
1 parent 18d15d6 commit 372da39

File tree

17 files changed

+136
-268
lines changed

17 files changed

+136
-268
lines changed

Rakefile

+91-35
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,126 @@
1-
# -*- encoding: utf-8 -*-
1+
require 'fileutils'
22

33
PRWD = File.expand_path(__dir__)
44

55
desc 'run contributed samples'
6-
task :default => [:all]
6+
task default: [:all]
77

88
desc 'run all autorun samples except hype'
99
task :all do
1010
Rake::Task[:contributed].execute
1111
Rake::Task[:vecmath].execute
1212
Rake::Task[:shaders].execute
1313
Rake::Task[:slider].execute
14+
Rake::Task[:demo].execute
1415
end
1516

1617
desc 'run contributed samples'
1718
task :contributed do
18-
sh "cd #{PRWD}/contributed && rake"
19+
FileUtils.cd(File.join(PRWD, 'contributed'))
20+
system 'rake'
1921
end
2022

21-
desc 'shaders'
22-
task :shaders do
23-
sh "cd #{PRWD}/processing_app/topics/shaders && rake"
24-
end
25-
26-
desc 'PixelFlow'
27-
task :pixel_flow do
28-
sh "cd #{PRWD}/external_library/java/pixel_flow && rake"
23+
desc 'run graphics demo'
24+
task :demos do
25+
FileUtils.cd(
26+
File.join(PRWD,
27+
'processing_app',
28+
'demos',
29+
'graphics'
30+
)
31+
)
32+
system 'rake'
2933
end
3034

31-
desc 'vecmath'
35+
desc 'run vecmath samples'
3236
task :vecmath do
33-
sh "cd #{PRWD}/processing_app/library/vecmath/vec2d && rake"
34-
sh "cd #{PRWD}/processing_app/library/vecmath/vec3d && rake"
35-
sh "cd #{PRWD}/processing_app/library/vecmath/arcball && rake"
37+
%w[vec2d vec3d arcball].each do |folder|
38+
FileUtils.cd(
39+
File.join(
40+
PRWD,
41+
'processing_app',
42+
'library',
43+
'vecmath',
44+
folder
45+
)
46+
)
47+
system 'rake'
48+
end
3649
end
3750

38-
desc 'hype'
39-
task :hype do
40-
sh "cd #{PRWD}/external_library/java/hype && rake"
51+
desc 'run shader samples'
52+
task :shaders do
53+
FileUtils.cd(
54+
File.join(
55+
PRWD,
56+
'processing_app',
57+
'topics',
58+
'shaders'
59+
)
60+
)
61+
system 'rake'
4162
end
4263

43-
desc 'slider'
44-
task :slider do
45-
sh "cd #{PRWD}/processing_app/library/slider && rake"
64+
desc 'run Hype Processing samples'
65+
task :hype do
66+
FileUtils.cd(
67+
File.join(
68+
PRWD,
69+
'external_library',
70+
'java',
71+
'hype'
72+
)
73+
)
74+
system 'rake'
4675
end
4776

48-
desc 'geomerative'
49-
task :geomerative do
50-
sh "cd #{PRWD}/external_library/gem/geomerative && rake"
77+
desc 'run WordCram samples'
78+
task :wordcram do
79+
FileUtils.cd(
80+
File.join(
81+
PRWD,
82+
'external_library',
83+
'gem',
84+
'ruby_wordcram'
85+
)
86+
)
87+
system 'rake'
5188
end
5289

5390
desc 'hemesh'
5491
task :hemesh do
55-
sh "cd #{PRWD}/external_library/java/hemesh && rake"
92+
FileUtils.cd(
93+
File.join(
94+
PRWD,
95+
'external_library',
96+
'java',
97+
'hemesh'
98+
)
99+
)
100+
system 'rake'
56101
end
57102

58103
desc 'pbox2d'
59104
task :pbox2d do
60-
sh "cd #{PRWD}/external_library/gem/pbox2d && rake"
61-
sh "cd #{PRWD}/external_library/gem/pbox2d/revolute_joint && jruby revolute_joint.rb"
62-
sh "cd #{PRWD}/external_library/gem/pbox2d/test_contact && jruby test_contact.rb"
63-
sh "cd #{PRWD}/external_library/gem/pbox2d/mouse_joint && jruby mouse_joint.rb"
64-
sh "cd #{PRWD}/external_library/gem/pbox2d/distance_joint && jruby distance_joint.rb"
65-
end
66-
67-
desc 'wordcram'
68-
task :wordcram do
69-
sh "cd #{PRWD}/external_library/gem/ruby_wordcram && rake"
105+
FileUtils.cd(
106+
File.join(
107+
PRWD,
108+
'external_library',
109+
'gem',
110+
'pbox2d'
111+
)
112+
)
113+
system 'rake'
114+
%w[revolute_joint test_contact mouse_joint distance_joint].each do |folder|
115+
FileUtils.cd(
116+
File.join(
117+
PRWD,
118+
'external_library',
119+
'gem',
120+
'pbox2d',
121+
folder
122+
)
123+
)
124+
system "k9 -r #{folder}.rb"
125+
end
70126
end

contributed/Rakefile

+2-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
# Simple demo Rakefile to autorun samples in current directory
2-
# adjust path to rp5 executable, and or opts as required
3-
4-
SAMPLES_DIR = './'
52

63
desc 'run demo'
74
task default: [:demo]
@@ -12,19 +9,10 @@ task :demo do
129
end
1310

1411
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
12+
Dir.glob('*.rb').map { |file| File.join(__dir__, file) }
2113
end
2214

2315
def run_sample(sample_name)
2416
puts "Running #{sample_name}...quit to run next sample"
25-
open("|jruby --dev #{sample_name}", 'r') do |io|
26-
while l = io.gets
27-
puts(l.chop)
28-
end
29-
end
17+
system "jruby --dev #{sample_name}"
3018
end

external_library/gem/arcball/Rakefile

+3-15
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,18 @@
11
# Simple demo Rakefile to autorun samples in current directory
2-
# adjust path to rp5 executable, and or opts as required
3-
4-
SAMPLES_DIR = './'
52

63
desc 'run demo'
74
task default: [:demo]
85

96
desc 'demo'
107
task :demo do
11-
samples_list.shuffle.each{ |sample| run_sample sample }
8+
samples_list.shuffle.each { |sample| run_sample sample }
129
end
1310

1411
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
12+
Dir.glob('*.rb').map { |file| File.join(__dir__, file) }
2113
end
2214

2315
def run_sample(sample_name)
2416
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
17+
system "jruby --dev #{sample_name}"
3018
end
+2-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
# Simple demo Rakefile to autorun samples in current directory
2-
# adjust path to rp5 executable, and or opts as required
3-
4-
SAMPLES_DIR = './'
52

63
desc 'run demo'
74
task default: [:demo]
@@ -12,20 +9,10 @@ task :demo do
129
end
1310

1411
def samples_list
15-
files = []
16-
Dir.chdir(SAMPLES_DIR)
17-
Dir.glob('*.rb').each do |file|
18-
next if file =~ /agent/ # ignore agent files
19-
files << File.join(SAMPLES_DIR, file)
20-
end
21-
return files
12+
Dir.glob('*.rb').map { |file| File.join(__dir__, file) }
2213
end
2314

2415
def run_sample(sample_name)
2516
puts "Running #{sample_name}...quit to run next sample"
26-
open("|jruby #{sample_name}", 'r') do |io|
27-
while l = io.gets
28-
puts(l.chop)
29-
end
30-
end
17+
system "jruby --dev #{sample_name}"
3118
end

external_library/gem/pbox2d/Rakefile

+2-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
# Simple demo Rakefile to autorun samples in current directory
2-
# adjust path to rp5 executable, and or opts as required
3-
4-
SAMPLES_DIR = './'
52

63
desc 'run demo'
74
task default: [:demo]
@@ -12,19 +9,10 @@ task :demo do
129
end
1310

1411
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
12+
Dir.glob('*.rb').map { |file| File.join(__dir__, file) }
2113
end
2214

2315
def run_sample(sample_name)
2416
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
17+
system "jruby --dev #{sample_name}"
3018
end
+2-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
# Simple demo Rakefile to autorun samples in current directory
2-
# adjust path to rp5 executable, and or opts as required
3-
4-
SAMPLES_DIR = './'
52

63
desc 'run demo'
74
task default: [:demo]
@@ -12,19 +9,10 @@ task :demo do
129
end
1310

1411
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
12+
Dir.glob('*.rb').map { |file| File.join(__dir__, file) }
2113
end
2214

2315
def run_sample(sample_name)
2416
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
17+
system "jruby --dev #{sample_name}"
3018
end
+2-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
# Simple demo Rakefile to autorun samples in current directory
2-
# adjust path to rp5 executable, and or opts as required
3-
4-
SAMPLES_DIR = './'
52

63
desc 'run demo'
74
task default: [:demo]
@@ -12,19 +9,10 @@ task :demo do
129
end
1310

1411
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
12+
Dir.glob('*.rb').map { |file| File.join(__dir__, file) }
2113
end
2214

2315
def run_sample(sample_name)
2416
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
17+
system "jruby --dev #{sample_name}"
3018
end

external_library/java/handy/Rakefile

+4-16
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,18 @@
11
# Simple demo Rakefile to autorun samples in current directory
2-
# adjust path to k9 executable, and or opts as required
3-
4-
SAMPLES_DIR="./"
52

63
desc 'run demo'
7-
task :default => [:demo]
4+
task default: [:demo]
85

96
desc 'demo'
107
task :demo do
11-
samples_list.shuffle.each{|sample| run_sample sample}
8+
samples_list.shuffle.each { |sample| run_sample sample }
129
end
1310

1411
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
12+
Dir.glob('*.rb').map { |file| File.join(__dir__, file) }
2113
end
2214

2315
def run_sample(sample_name)
2416
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
17+
system "jruby --dev #{sample_name}"
3018
end

0 commit comments

Comments
 (0)