Class: QED::Reporter::Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/qed/reporter/abstract.rb

Overview

Reporter Absract Base Class

Serves as the base class for all other output formats.

Direct Known Subclasses

BulletPoint, DotProgress, Html, Verbatim

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Abstract

Returns a new instance of Abstract.



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/qed/reporter/abstract.rb', line 17

def initialize(options={})
  @io    = options[:io] || STDOUT
  @trace = options[:trace]

  @demos = 0
  @steps = 0
  @omit  = []
  @pass  = []
  @fail  = []
  @error = []
end

Instance Attribute Details

#ioObject (readonly)

Returns the value of attribute io.



13
14
15
# File 'lib/qed/reporter/abstract.rb', line 13

def io
  @io
end

#omitObject (readonly)

Returns the value of attribute omit.



15
16
17
# File 'lib/qed/reporter/abstract.rb', line 15

def omit
  @omit
end

#stepsObject (readonly)

Returns the value of attribute steps.



14
15
16
# File 'lib/qed/reporter/abstract.rb', line 14

def steps
  @steps
end

Class Method Details

.After(type, &block) ⇒ Object



56
57
58
59
60
# File 'lib/qed/reporter/abstract.rb', line 56

def self.After(type, &block)
#  raise ArgumentError unless %w{session demo demonstration step pass fail error}.include?(type.to_s)
#  type = :demonstration if type.to_s == 'demo'
  define_method("after_#{type}", &block)
end

.Before(type, &block) ⇒ Object



50
51
52
53
54
# File 'lib/qed/reporter/abstract.rb', line 50

def self.Before(type, &block)
#  raise ArgumentError unless %w{session demo demonstration step}.include?(type.to_s)
#  type = :demonstration if type.to_s == 'demo'
  define_method("before_#{type}", &block)
end

.When(type, &block) ⇒ Object



44
45
46
47
48
# File 'lib/qed/reporter/abstract.rb', line 44

def self.When(type, &block)
  #raise ArgumentError unless %w{session demo demonstration step}.include?(type.to_s)
  #type = :demonstration if type.to_s == 'demo'
  define_method(type, &block)
end

Instance Method Details

#after_code(step, file) ⇒ Object



129
130
# File 'lib/qed/reporter/abstract.rb', line 129

def after_code(step, file)
end

#after_document(demo) ⇒ Object

End of a demonstration.



137
138
# File 'lib/qed/reporter/abstract.rb', line 137

def after_document(demo)  #demo(demo)
end

#after_session(session) ⇒ Object

After running all demonstrations. This is the place to output a summary of the session, if applicable.



142
143
# File 'lib/qed/reporter/abstract.rb', line 142

def after_session(session)
end

#before_code(step, file) ⇒ Object



100
101
102
# File 'lib/qed/reporter/abstract.rb', line 100

def before_code(step, file)
  @steps += 1
end

#before_document(demo) ⇒ Object

Beginning of a demonstration.



79
80
81
# File 'lib/qed/reporter/abstract.rb', line 79

def before_document(demo) #demo(demo)
  @demos += 1
end

#before_session(session) ⇒ Object

At the start of a session, before running any demonstrations.



75
76
# File 'lib/qed/reporter/abstract.rb', line 75

def before_session(session)
end

#code(section) ⇒ Object

Right before running code.



105
106
# File 'lib/qed/reporter/abstract.rb', line 105

def code(section)
end

#error(step, exception) ⇒ Object

After running a step that raised an error.



123
124
125
126
# File 'lib/qed/reporter/abstract.rb', line 123

def error(step, exception)
  raise exception if $DEBUG
  @error << [step, exception]
end

#errorsObject



30
# File 'lib/qed/reporter/abstract.rb', line 30

def errors   ; @error ; end

#fail(step, assertion) ⇒ Object

After running a step that failed.



118
119
120
# File 'lib/qed/reporter/abstract.rb', line 118

def fail(step, assertion)
  @fail << [step, assertion]
end

#failuresObject



31
# File 'lib/qed/reporter/abstract.rb', line 31

def failures ; @fail  ; end

#import(file) ⇒ Object



88
89
# File 'lib/qed/reporter/abstract.rb', line 88

def import(file)
end

#load(demo) ⇒ Object



84
85
# File 'lib/qed/reporter/abstract.rb', line 84

def load(demo)
end

#pass(step) ⇒ Object

After running a step that passed.



113
114
115
# File 'lib/qed/reporter/abstract.rb', line 113

def pass(step)
  @pass << step
end

#passesObject



29
# File 'lib/qed/reporter/abstract.rb', line 29

def passes   ; @pass  ; end

#text(section) ⇒ Object

Right before text section.



109
110
# File 'lib/qed/reporter/abstract.rb', line 109

def text(section)
end

#trace?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/qed/reporter/abstract.rb', line 34

def trace?
  @trace
end

#unloadObject



133
134
# File 'lib/qed/reporter/abstract.rb', line 133

def unload
end

#update(type, *args) ⇒ Object



39
40
41
# File 'lib/qed/reporter/abstract.rb', line 39

def update(type, *args)
  __send__("#{type}", *args)
end

#when(*args) ⇒ Object



146
147
# File 'lib/qed/reporter/abstract.rb', line 146

def when(*args)
end