class Tryouts::Drill
def initialize(name, dtype, *args, &drill)
* dream FORMAT, OUTPUT, REPS (benchmark only)
* dream FORMAT, OUTPUT
* dream OUTPUT
The DSL syntax:
is compared to the exepected output of the dreams.
* +&drill+ The body of the drill. The return value of this block
* +args+ These are dependent on the drill type. See the Sergeant classes
* +dtype+ A Symbol representing the drill type. One of: :api, :benchmark
* +name+ The display name of this drill
def initialize(name, dtype, *args, &drill) @name, @dtype, @drill, @skip = name, dtype, drill, false @dreams = [] case @dtype when :cli @sergeant = Tryouts::Drill::Sergeant::CLI.new *args when :api default_output = drill.nil? ? args.shift : nil dream_output, format = *(args.size == 1 ? args.first : args.reverse) @sergeant = Tryouts::Drill::Sergeant::API.new default_output unless args.empty? @dreams << Tryouts::Drill::Dream.new(dream_output, format) end when :benchmark if args.size == 1 reps = args.first else dream_output, format, reps = args[1], args[0], args[2] end @sergeant = Tryouts::Drill::Sergeant::Benchmark.new reps @dreams << Tryouts::Drill::Dream.new(Tryouts::Stats, :class) unless dream_output.nil? @dreams << Tryouts::Drill::Dream.new(dream_output, format) end when :skip @skip = true else raise NoSergeant, "Weird drill sergeant: #{@dtype}" end @clr = :red # For CLI drills, a block takes precedence over inline args. # A block will contain multiple shell commands (see Rye::Box#batch) drill_args = [] if dtype == :cli && drill.is_a?(Proc) @reality = Tryouts::Drill::Reality.new end