Module: Mumukit::Templates::WithStructuredResults

Defined in:
lib/mumukit/templates/with_structured_results.rb

Instance Method Summary collapse

Instance Method Details

#extract_result(result) ⇒ Object



17
18
19
20
21
# File 'lib/mumukit/templates/with_structured_results.rb', line 17

def extract_result(result)
  separator = self.class.instance_variable_get :@separator
  result = result.split(separator).last if separator.present?
  result
end

#post_process_file(file, result, status) ⇒ Object



2
3
4
5
6
7
8
9
10
11
# File 'lib/mumukit/templates/with_structured_results.rb', line 2

def post_process_file(file, result, status)
  result = extract_result(result)
  if [:passed, :failed].include? status
    [to_structured_result(result)]
  else
    post_process_unstructured_result(file, result, status)
  end
rescue JSON::ParserError
  [result, :errored]
end

#post_process_unstructured_result(_file, result, status) ⇒ Object



13
14
15
# File 'lib/mumukit/templates/with_structured_results.rb', line 13

def post_process_unstructured_result(_file, result, status)
  [result, status]
end

#to_structured_result(result) ⇒ Object



23
24
25
# File 'lib/mumukit/templates/with_structured_results.rb', line 23

def to_structured_result(result)
  JSON.pretty_parse(result)
end