Class: GCOV::HTMLFormatter
- Inherits:
-
Object
- Object
- GCOV::HTMLFormatter
- Defined in:
- lib/html_formatter.rb
Instance Method Summary collapse
-
#class_of(line) ⇒ Object
initialize.
- #class_of_file(file, error_level, warning_level = nil) ⇒ Object
- #class_of_stat(value, error_comp, warning_comp = nil) ⇒ Object
- #count_of(line) ⇒ Object
- #encode(text) ⇒ Object
-
#get_binding ⇒ Object
this is only a helper method to access the objects binding method.
-
#initialize(project, va = {}) ⇒ HTMLFormatter
constructor
A new instance of HTMLFormatter.
- #print ⇒ Object
Constructor Details
#initialize(project, va = {}) ⇒ HTMLFormatter
Returns a new instance of HTMLFormatter.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/html_formatter.rb', line 17 def initialize project, va={} @project = project @css = va[:css] if !@css @csslink = <<EOF <style> </style> EOF else @csslink = "<link rel=\"stylesheet\" href=\"#{@css}\" />" end @template = ::File.read(::File.join(::File.dirname(__FILE__),"html_view.html.erb")) end |
Instance Method Details
#class_of(line) ⇒ Object
initialize
34 35 36 37 38 39 40 |
# File 'lib/html_formatter.rb', line 34 def class_of line case line.count when :none then "irrelevant" when :missed then "missed" else "ok" end end |
#class_of_file(file, error_level, warning_level = nil) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/html_formatter.rb', line 52 def class_of_file file, error_level, warning_level=nil if file.stats[:coverage] <= error_level return "header error" elsif !warning_level.nil? and file.stats[:coverage] < warning_level return "header warning" else return "header ok" end end |
#class_of_stat(value, error_comp, warning_comp = nil) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/html_formatter.rb', line 42 def class_of_stat value, error_comp, warning_comp=nil if eval("#{value}#{error_comp}") return "value_error" elsif !warning_comp.nil? and eval("#{value}#{warning_comp}") return "value_warning" else return "value_ok" end end |
#count_of(line) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/html_formatter.rb', line 62 def count_of line case line.count when :none then "" when :missed then "<strong>miss</strong>" else line.count end end |
#encode(text) ⇒ Object
70 71 72 |
# File 'lib/html_formatter.rb', line 70 def encode text CGI.escapeHTML( text ) end |
#get_binding ⇒ Object
this is only a helper method to access the objects binding method
13 14 15 |
# File 'lib/html_formatter.rb', line 13 def get_binding # this is only a helper method to access the objects binding method binding end |
#print ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/html_formatter.rb', line 74 def print renderer = ERB.new( @template ) puts renderer.result(self.get_binding) end |