Class: Dcov::Generator
Overview
Instance Attribute Summary collapse
Instance Method Summary
collapse
#class_coverage, #method_coverage, #module_coverage
Constructor Details
#initialize(data) ⇒ Generator
10
11
12
|
# File 'lib/dcov/generators/html/generator.rb', line 10
def initialize(data)
@data = data
end
|
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
9
10
11
|
# File 'lib/dcov/generators/html/generator.rb', line 9
def data
@data
end
|
Instance Method Details
#build_stats_body ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/dcov/generators/html/generator.rb', line 31
def build_stats_body
output = ""
output << "<p>\n"
output << "Class coverage: <b>#{class_coverage}%</b><br>\n"
output << "Module coverage: <b>#{module_coverage}%</b><br>\n"
output << "Method coverage: <b>#{method_coverage}%</b><br>\n"
output << "</p>\n\n"
output << "<ol>\n"
data[:structured].each do |key,value|
output << ((value[0]..nil? || value[0]. == '') ?
"\t<li><font color='#f00;'><tt>#{key.is_a?(String) ? key : key.full_name }</tt></font>\n\t\t<ol>\n" :
"\t<li><tt>#{key}</tt>\n\t\t<ol>") unless value[0].is_a?(Dcov::TopLevel)
value[1].each do |itm|
output << ((itm..nil? || itm. == '') ?
"\t\t\t<li><font color='#f00;'><tt>#{itm.name}</tt></font>\n" :
"\t\t\t<li><tt>#{itm.name}</tt>\n")
output << "#{"<br /><span class='quality_problem'>parameters without documentation: <tt>" + itm.reporting_data[:parameters_without_coverage].join(", ") + "</tt></span>" if itm.reporting_data[:parameters_without_coverage].length > 0}"
output << "#{"<br /><span class='quality_problem'>default values without documentation: <tt>" + itm.reporting_data[:default_values_without_coverage].join(", ") + "</tt></span>" if itm.reporting_data[:default_values_without_coverage].length > 0}"
output << "#{"<br /><span class='quality_problem'>options are not documented</span>" if itm.reporting_data[:no_options_documentation]}"
output << "#{"<br /><span class='quality_problem'>there are no examples</span>" if itm.reporting_data[:no_examples]}"
output << "</li>\n"
end
output << "\t\t</ol>\n\t</li>\n\n" unless value[0].is_a?(Dcov::TopLevel)
end
output
end
|
64
65
66
67
|
# File 'lib/dcov/generators/html/generator.rb', line 64
def
output = ""
output << "</ol>\n\n</body></html>"
end
|
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/dcov/generators/html/generator.rb', line 18
def
output = ""
output << """<html><head><title>dcov results</title>
<style>
BODY { font-family: Helvetica, Arial, sans-serif; font-size: 10pt; background: #333; color: white; margin: 16px; }
H1 { text-shadow: 3pt 3pt 5pt black;}
.quality_problem { font-size: 8pt; color: #999; }
LI { margin: 8px; }
</style>
</head><body>\n<h1>dcov results</h1>\n\n"""
end
|
#to_s ⇒ Object
14
15
16
|
# File 'lib/dcov/generators/html/generator.rb', line 14
def to_s
+ build_stats_body +
end
|