Class: Gobstones::Batch

Inherits:
Object
  • Object
show all
Defined in:
lib/gobstones/batch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content, examples, extra, options) ⇒ Batch

Returns a new instance of Batch.



5
6
7
8
9
10
11
# File 'lib/gobstones/batch.rb', line 5

def initialize(content, examples, extra, options)
  @content = content
  @examples = examples
  @extra = extra
  @options = options
  @compilation_mode = @options[:game_framework] ? Gobstones::CompilationMode::GameFramework : Gobstones::CompilationMode::Classic
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



2
3
4
# File 'lib/gobstones/batch.rb', line 2

def content
  @content
end

#examplesObject

Returns the value of attribute examples.



2
3
4
# File 'lib/gobstones/batch.rb', line 2

def examples
  @examples
end

#extraObject

Returns the value of attribute extra.



2
3
4
# File 'lib/gobstones/batch.rb', line 2

def extra
  @extra
end

#optionsObject

Returns the value of attribute options.



2
3
4
# File 'lib/gobstones/batch.rb', line 2

def options
  @options
end

Instance Method Details

#run_tests!(output) ⇒ Object



13
14
15
16
17
# File 'lib/gobstones/batch.rb', line 13

def run_tests!(output)
  Mumukit::Metatest::Framework.new(
    checker: Gobstones::Checker.new(options),
    runner: Gobstones::MultipleExecutionsRunner.new).test output, examples
end

#to_jsonObject



19
20
21
22
23
24
25
# File 'lib/gobstones/batch.rb', line 19

def to_json
  {
    code: compile_content(content),
    extraCode: compile_extra(extra),
    examples: examples.map { |example| example_json(example) }
  }.to_json
end