Class: Corundum::QA::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/corundum/qa-report.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Report



72
73
74
75
76
77
78
# File 'lib/corundum/qa-report.rb', line 72

def initialize(name)
  @name = name
  @rejects = []
  @passed = true
  @summary = ""
  @summary_counts = true
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



79
80
81
# File 'lib/corundum/qa-report.rb', line 79

def name
  @name
end

#passedObject

Returns the value of attribute passed.



80
81
82
# File 'lib/corundum/qa-report.rb', line 80

def passed
  @passed
end

#rejectsObject (readonly)

Returns the value of attribute rejects.



79
80
81
# File 'lib/corundum/qa-report.rb', line 79

def rejects
  @rejects
end

#summaryObject

Returns the value of attribute summary.



80
81
82
# File 'lib/corundum/qa-report.rb', line 80

def summary
  @summary
end

#summary_countsObject

Returns the value of attribute summary_counts.



80
81
82
# File 'lib/corundum/qa-report.rb', line 80

def summary_counts
  @summary_counts
end

Instance Method Details

#<<(reject) ⇒ Object



82
83
84
# File 'lib/corundum/qa-report.rb', line 82

def <<(reject)
  @rejects << reject
end

#add(*args) ⇒ Object



86
87
88
# File 'lib/corundum/qa-report.rb', line 86

def add(*args)
  self << Rejection.new(*args)
end

#empty?Boolean



100
101
102
# File 'lib/corundum/qa-report.rb', line 100

def empty?
  @rejects.empty?
end

#fail(summary) ⇒ Object



90
91
92
93
# File 'lib/corundum/qa-report.rb', line 90

def fail(summary)
  @passed = false
  @summary = summary
end

#lengthObject Also known as: count



95
96
97
# File 'lib/corundum/qa-report.rb', line 95

def length
  @rejects.length
end

#to_s(widths = nil) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/corundum/qa-report.rb', line 104

def to_s(widths=nil)
  Paint[
    (passed ? "Ok" : "FAIL") +
    ": #{name} " +
    (summary_counts ? "(#{length})" : ""),
      passed ? :green : :red
  ] + "\n" +
    (summary.empty? ? "" : (summary + "\n")) +
    rejects.map do |reject|
    "  " + reject.to_s(widths) + "\n"
    end.join("")
end