Skip to content

Commit 2e0021f

Browse files
committed
Remove bashisms
1 parent 8e025db commit 2e0021f

File tree

36 files changed

+392
-209
lines changed

36 files changed

+392
-209
lines changed

Rakefile

Lines changed: 80 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# -*- encoding: utf-8 -*-
1+
require 'fileutils'
22

33
K9WD = 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
@@ -15,56 +15,99 @@ end
1515

1616
desc 'run contributed samples'
1717
task :contributed do
18-
sh "cd #{K9WD}/contributed && rake"
18+
FileUtils.cd(File.join(K9WD, 'contributed'))
19+
system 'rake'
1920
end
2021

21-
desc 'PixelFlow'
22-
task :pixel_flow do
23-
sh "cd #{K9WD}/external_library/java/PixelFlow && rake"
24-
end
25-
26-
desc 'shaders'
27-
task :shaders do
28-
sh "cd #{K9WD}/processing_app/topics/shaders && rake"
29-
end
30-
31-
desc 'vecmath'
22+
desc 'run vecmath samples'
3223
task :vecmath do
33-
sh "cd #{K9WD}/processing_app/library/vecmath/vec2d && rake"
34-
sh "cd #{K9WD}/processing_app/library/vecmath/vec3d && rake"
35-
sh "cd #{K9WD}/processing_app/library/vecmath/arcball && rake"
24+
%w[vec2d vec3d arcball].each do |folder|
25+
FileUtils.cd(
26+
File.join(
27+
K9WD,
28+
'processing_app',
29+
'library',
30+
'vecmath',
31+
folder
32+
)
33+
)
34+
system 'rake'
35+
end
3636
end
3737

38-
desc 'hype'
39-
task :hype do
40-
sh "cd #{K9WD}/external_library/java/hype && rake"
38+
desc 'run shader samples'
39+
task :shader do
40+
FileUtils.cd(
41+
File.join(
42+
K9WD,
43+
'processing_app',
44+
'topics',
45+
'shader'
46+
)
47+
)
48+
system 'rake'
4149
end
4250

43-
desc 'skatolo'
44-
task :skatolo do
45-
sh "cd #{K9WD}/external_library/gem/skatolo && rake"
51+
desc 'run Hype Processing samples'
52+
task :hype do
53+
FileUtils.cd(
54+
File.join(
55+
K9WD,
56+
'external_library',
57+
'java',
58+
'hype'
59+
)
60+
)
61+
system 'rake'
4662
end
4763

48-
desc 'slider'
49-
task :slider do
50-
sh "cd #{K9WD}/processing_app/library/slider && rake"
64+
desc 'run WordCram samples'
65+
task :wordcram do
66+
FileUtils.cd(
67+
File.join(
68+
K9WD,
69+
'external_library',
70+
'gem',
71+
'ruby_wordcram'
72+
)
73+
)
74+
system 'rake'
5175
end
5276

5377
desc 'hemesh'
5478
task :hemesh do
55-
sh "cd #{K9WD}/external_library/java/hemesh && rake"
79+
FileUtils.cd(
80+
File.join(
81+
K9WD,
82+
'external_library',
83+
'java',
84+
'hemesh'
85+
)
86+
)
87+
system 'rake'
5688
end
5789

5890
desc 'pbox2d'
5991
task :pbox2d do
60-
sh "cd #{K9WD}/external_library/gem/pbox2d && rake"
61-
sh "cd #{K9WD}/external_library/gem/pbox2d/revolute_joint && k9 -r revolute_joint.rb"
62-
sh "cd #{K9WD}/external_library/gem/pbox2d/test_contact && k9 -r test_contact.rb"
63-
sh "cd #{K9WD}/external_library/gem/pbox2d/mouse_joint && k9 -r mouse_joint.rb"
64-
sh "cd #{K9WD}/external_library/gem/pbox2d/distance_joint && k9 -r distance_joint.rb"
65-
end
66-
67-
desc 'wordcram'
68-
task :wordcram do
69-
sh "cd #{K9WD}/external_library/gem/ruby_wordcram && rake"
92+
FileUtils.cd(
93+
File.join(
94+
K9WD,
95+
'external_library',
96+
'gem',
97+
'pbox2d'
98+
)
99+
)
100+
system 'rake'
101+
%w[revolute_joint test_contact mouse_joint distance_joint].each do |folder|
102+
FileUtils.cd(
103+
File.join(
104+
K9WD,
105+
'external_library',
106+
'gem',
107+
'pbox2d',
108+
folder
109+
)
110+
)
111+
system "k9 -r #{folder}.rb"
112+
end
70113
end

contributed/Rakefile

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Simple demo Rakefile to autorun samples in current directory
22
# adjust path to k9 executable, and or opts as required
33

4-
SAMPLES_DIR = './'
5-
64
desc 'run demo'
75
task default: [:demo]
86

@@ -12,19 +10,10 @@ task :demo do
1210
end
1311

1412
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
13+
Dir.glob('*.rb').map { |file| File.join(__dir__, file) }
2114
end
2215

2316
def run_sample(sample_name)
2417
puts "Running #{sample_name}...quit to run next sample"
25-
open("|k9 -r #{sample_name}", 'r') do |io|
26-
while l = io.gets
27-
puts(l.chop)
28-
end
29-
end
18+
system "k9 -r #{sample_name}"
3019
end

external_library/gem/cf3/Rakefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Simple demo Rakefile to autorun samples in current directory
2+
# adjust path to k9 executable, and or opts as required
3+
4+
desc 'run demo'
5+
task default: [:demo]
6+
7+
desc 'demo'
8+
task :demo do
9+
samples_list.shuffle.each { |sample| run_sample sample }
10+
end
11+
12+
def samples_list
13+
Dir.glob('*.rb').map { |file| File.join(__dir__, file) }
14+
end
15+
16+
def run_sample(sample_name)
17+
puts "Running #{sample_name}...quit to run next sample"
18+
system "k9 -r #{sample_name}"
19+
end
Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Simple demo Rakefile to autorun samples in current directory
22
# adjust path to k9 executable, and or opts as required
33

4-
SAMPLES_DIR = './'
5-
64
desc 'run demo'
75
task default: [:demo]
86

@@ -12,19 +10,10 @@ task :demo do
1210
end
1311

1412
def samples_list
15-
files = []
16-
Dir.chdir(SAMPLES_DIR)
17-
Dir.glob('*.rb').each do |file|
18-
files << File.join(SAMPLES_DIR, file) unless file.end_with? 'agent.rb'
19-
end
20-
files
13+
Dir.glob('*.rb').map { |file| File.join(__dir__, file) }
2114
end
2215

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

64
desc 'run demo'
75
task default: [:demo]
@@ -12,19 +10,10 @@ task :demo do
1210
end
1311

1412
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
13+
Dir.glob('*.rb').map { |file| File.join(__dir__, file) }
2114
end
2215

2316
def run_sample(sample_name)
2417
puts "Running #{sample_name}...quit to run next sample"
25-
open("|k9 -r #{sample_name}", 'r') do |io|
26-
while l = io.gets
27-
puts(l.chop)
28-
end
29-
end
18+
system "k9 -r #{sample_name}"
3019
end
Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
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 = './'
2+
# adjust path to k9 executable, and or opts as required
53

64
desc 'run demo'
75
task default: [:demo]
@@ -12,19 +10,10 @@ task :demo do
1210
end
1311

1412
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
13+
Dir.glob('*.rb').map { |file| File.join(__dir__, file) }
2114
end
2215

2316
def run_sample(sample_name)
2417
puts "Running #{sample_name}...quit to run next sample"
25-
open("|k9 -r #{sample_name}", 'r') do |io|
26-
while l = io.gets
27-
puts(l.chop)
28-
end
29-
end
18+
system "k9 -r #{sample_name}"
3019
end
Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
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 = './'
2+
# adjust path to k9 executable, and or opts as required
53

64
desc 'run demo'
75
task default: [:demo]
@@ -12,19 +10,10 @@ task :demo do
1210
end
1311

1412
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
13+
Dir.glob('*.rb').map { |file| File.join(__dir__, file) }
2114
end
2215

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

0 commit comments

Comments
 (0)