Class: Auger::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/auger/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(outcome = nil, status = outcome) ⇒ Result

Returns a new instance of Result.



6
7
8
9
# File 'lib/auger/result.rb', line 6

def initialize(outcome = nil, status = outcome)
  @outcome = outcome
  @status  = status
end

Instance Attribute Details

#outcomeObject

Returns the value of attribute outcome.



4
5
6
# File 'lib/auger/result.rb', line 4

def outcome
  @outcome
end

#statusObject

Returns the value of attribute status.



4
5
6
# File 'lib/auger/result.rb', line 4

def status
  @status
end

#testObject

Returns the value of attribute test.



4
5
6
# File 'lib/auger/result.rb', line 4

def test
  @test
end

#timeObject

Returns the value of attribute time.



4
5
6
# File 'lib/auger/result.rb', line 4

def time
  @time
end

Instance Method Details

#formatObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/auger/result.rb', line 11

def format
  output =
    case self.outcome
    when TrueClass  then "\u2713"
    when MatchData  then outcome.captures.empty? ? "\u2713" : outcome.captures.join(' ')
    when FalseClass then puts "false"; "\u2717"
    when NilClass   then puts "nillly"; "nil"
    when Exception
      "#{outcome.class}: #{outcome.to_s}" +
      "\n\tBacktrace:\n\t#{outcome.backtrace.join("\n\t")}"
    else                 outcome.to_s
    end

  color =
    case self.status
    when FalseClass, NilClass then :red
    when Exception            then :magenta
    when Status               then
      case self.status.value
        when :ok        then :green
        when :warn      then :yellow
        when :exception then :magenta
      else                   :red
      end
    else                           :green
    end

  return output.color(color)
end

#verbose?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/auger/result.rb', line 41

def verbose?
  !!AUGER_OPS[:verbose]
end