Method: Experiment::Runner#generate

Defined in:
lib/experiment/runner.rb

#generateObject

Generates a new experiment condition Usage of the -m flag for writing a hypothesis is recommended



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/experiment/runner.rb', line 25

def generate
dir = "./experiments/" + @arguments.first
      Dir.mkdir(dir)
      File.open(dir + "/" + @arguments.first + ".rb", "w") do |req_file|
 req_file.puts "# ## #{as_human_name @arguments.first} ##"
 req_file.puts "# "+@options.description.split("\n").join("\n# ")
 req_file.puts
 req_file.puts
 req_file.puts "# The first contious block of comment will be included in your report."
 req_file.puts "# This includes the reference implementation."
 req_file.puts "# Override any desired files in this directory."
 Dir["./app/**/*.{rb,o,dll,so,bundle}"].each do |f|
   next if File.basename(f) == 'extconfig.rb'
   p = File.expand_path(f).split("/") - File.expand_path(".").split("/")
   req_file.puts "require \"#{p.join("/").gsub(/\.(rb|o|dll|so|bundle)$/, "")}\""
 end
 req_file.puts "\nclass #{as_class_name @arguments.first} < MyExperiment\n\t\nend"
      end
      File.open(dir + "/config.yaml", "w") do |f|
 f << "---\nexperiment:\n  development:\n  compute:\n"
  end
end