Class: Coverage
- Inherits:
-
BaseDocument
- Object
- BaseDocument
- Coverage
- Defined in:
- lib/almirah/doc_types/coverage.rb
Instance Attribute Summary collapse
-
#bottom_doc ⇒ Object
Returns the value of attribute bottom_doc.
-
#items ⇒ Object
Returns the value of attribute items.
-
#top_doc ⇒ Object
Returns the value of attribute top_doc.
Attributes inherited from BaseDocument
Instance Method Summary collapse
-
#initialize(top_doc) ⇒ Coverage
constructor
A new instance of Coverage.
- #render_table_row(top_item) ⇒ Object
- #to_console ⇒ Object
- #to_html(nav_pane, output_file_path) ⇒ Object
Methods inherited from BaseDocument
Constructor Details
#initialize(top_doc) ⇒ Coverage
Returns a new instance of Coverage.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/almirah/doc_types/coverage.rb', line 9 def initialize(top_doc) @top_doc = top_doc @bottom_doc = bottom_doc @items = Array.new @headings = Array.new @id = top_doc.id + "-" + "tests" @title = "Coverage Matrix: " + @id end |
Instance Attribute Details
#bottom_doc ⇒ Object
Returns the value of attribute bottom_doc.
6 7 8 |
# File 'lib/almirah/doc_types/coverage.rb', line 6 def bottom_doc @bottom_doc end |
#items ⇒ Object
Returns the value of attribute items.
7 8 9 |
# File 'lib/almirah/doc_types/coverage.rb', line 7 def items @items end |
#top_doc ⇒ Object
Returns the value of attribute top_doc.
5 6 7 |
# File 'lib/almirah/doc_types/coverage.rb', line 5 def top_doc @top_doc end |
Instance Method Details
#render_table_row(top_item) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/almirah/doc_types/coverage.rb', line 47 def render_table_row(top_item) s = "" if top_item.coverage_links if top_item.coverage_links.length > 1 id_color = "" # "style='background-color: #fff8c5;'" # disabled for now else id_color = "" end top_item.coverage_links.each do |bottom_item| s += "\t<tr>\n" s += "\t\t<td class=\"item_id\" #{id_color}><a href=\"./../#{top_item.parent_doc.id}/#{top_item.parent_doc.id}.html##{top_item.id}\" class=\"external\">#{top_item.id}</a></td>\n" s += "\t\t<td class=\"item_text\" style='width: 42%;'>#{top_item.text}</td>\n" if bottom_item.columns[-2].text.downcase == "pass" test_step_color = "style='background-color: #cfc;'" elsif bottom_item.columns[-2].text.downcase == "fail" test_step_color = "style='background-color: #fcc;'" else test_step_color = "" end s += "\t\t<td class=\"item_id\" #{test_step_color}><a href=\"./../../tests/protocols/#{bottom_item.parent_doc.id}/#{bottom_item.parent_doc.id}.html##{bottom_item.id}\" class=\"external\">#{bottom_item.id}</a></td>\n" s += "\t\t<td class=\"item_text\" style='width: 42%;'>#{bottom_item.columns[1].text}</td>\n" s += "\t</tr>\n" end else s += "\t<tr>\n" s += "\t\t<td class=\"item_id\"><a href=\"./../#{top_item.parent_doc.id}/#{top_item.parent_doc.id}.html##{top_item.id}\" class=\"external\">#{top_item.id}</a></td>\n" s += "\t\t<td class=\"item_text\" style='width: 42%;'>#{top_item.text}</td>\n" s += "\t\t<td class=\"item_id\"></td>\n" s += "\t\t<td class=\"item_text\" style='width: 42%;'></td>\n" s += "\t</tr>\n" end return s end |
#to_console ⇒ Object
21 22 23 |
# File 'lib/almirah/doc_types/coverage.rb', line 21 def to_console puts "\e[35m" + "Traceability: " + @id + "\e[0m" end |
#to_html(nav_pane, output_file_path) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/almirah/doc_types/coverage.rb', line 25 def to_html(nav_pane, output_file_path) html_rows = Array.new html_rows.append('') s = "<h1>#{@title}</h1>\n" s += "<table class=\"controlled\">\n" s += "\t<thead> <th>#</th> <th style='font-weight: bold;'>#{@top_doc.title}</th> <th>#</th> <th style='font-weight: bold;'>Test CaseId.StepId</th> </thead>\n" html_rows.append s sorted_items = @top_doc.controlled_items.sort_by { |w| w.id } sorted_items.each do |top_item| row = render_table_row top_item html_rows.append row end html_rows.append "</table>\n" self.save_html_to_file(html_rows, nav_pane, output_file_path) end |