Class: Erudite::Executable

Inherits:
Object
  • Object
show all
Defined in:
lib/erudite/executable.rb

Overview

Parses, runs, and outputs examples.

Class Method Summary collapse

Class Method Details

.format_example(example) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/erudite/executable.rb', line 10

def self.format_example(example)
  if example.pass?
    format_passing_example(example)
  else
    format_failing_example(example)
  end
end

.format_failing_example(example) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/erudite/executable.rb', line 22

def self.format_failing_example(example)
  "- FAIL\n  Source: \#{example.source}\n  Expected:\nOutput: \#{example.expected.output.inspect}\nResult: \#{example.expected.result.inspect}\n  Actual:\nOutput: \#{example.actual.output.inspect}\nResult: \#{example.actual.result.inspect}\n  TXT\nend\n"

.format_passing_example(_example) ⇒ Object



18
19
20
# File 'lib/erudite/executable.rb', line 18

def self.format_passing_example(_example)
  '- PASS'
end

.run(io) ⇒ Object



6
7
8
# File 'lib/erudite/executable.rb', line 6

def self.run(io)
  Parser.parse(io).each { |example| puts format_example(example) }
end