Class: Dcov::Generator
- Inherits:
-
Object
- Object
- Dcov::Generator
- Includes:
- StatsRenderer::Helpers
- Defined in:
- lib/dcov/generators/html/generator.rb
Overview
Generates HTML output
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #build_stats_body ⇒ Object
- #build_stats_footer ⇒ Object
- #build_stats_header ⇒ Object
-
#initialize(data) ⇒ Generator
constructor
A new instance of Generator.
- #to_s ⇒ Object
Methods included from StatsRenderer::Helpers
#class_coverage, #method_coverage, #module_coverage
Constructor Details
#initialize(data) ⇒ Generator
Returns a new instance of Generator.
10 11 12 |
# File 'lib/dcov/generators/html/generator.rb', line 10 def initialize(data) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
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].comment.nil? || value[0].comment == '') ? "\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.comment.nil? || itm.comment == '') ? "\t\t\t<li><font color='#f00;'><tt>#{itm.name}</tt></font>\n" : "\t\t\t<li><tt>#{itm.name}</tt>\n") # Quality information 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 |
#build_stats_footer ⇒ Object
64 65 66 67 |
# File 'lib/dcov/generators/html/generator.rb', line 64 def output = "" output << "</ol>\n\n</body></html>" end |
#build_stats_header ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dcov/generators/html/generator.rb', line 18 def build_stats_header # Little CSS, a little HTML... 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_header + build_stats_body + end |