-
Notifications
You must be signed in to change notification settings - Fork 0
/
experimenter.rb
executable file
·42 lines (33 loc) · 992 Bytes
/
experimenter.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/ruby
require 'config.rb'
if ARGV[0] == "data"
full_data = true
else
full_data = false
end
if full_data
runner = "experimenter_data.js"
else
runner = "experimenter.js"
end
experiment = `#{JS_SHELL} #{runner} #{JS_SHELL_OPTIONS}`
experiment = experiment.gsub("\n","")
if !full_data
list = Dir.glob("runs/*")
list.reject! {|f| f =~ /experiments/}
list.each {|f| f.gsub!(/runs\//, "")}
list.sort!
new_experiment_file = "experiment." + Time.now.to_i.to_s + ".nr-" + (list.size + 1).to_s + ".js"
open("runs/" + new_experiment_file, "w") { |file|
file.write("experiment = eval('(" + experiment + ")');")
}
list.push(new_experiment_file)
open("runs/experiments.js", "w") { |file|
file.write("experiments = eval('([\"" + list.join('", "') + "\"])');")
}
else
new_experiment_file = "experiment." + Time.now.to_i.to_s + ".json"
open("data/json/" + new_experiment_file, "w") { |file|
file.write(experiment);
}
end