Class: Implementation
- Inherits:
-
BaseDocument
- Object
- BaseDocument
- Implementation
- Defined in:
- lib/almirah/doc_types/implementation.rb
Instance Attribute Summary collapse
-
#bottom_doc ⇒ Object
Returns the value of attribute bottom_doc.
-
#is_agregated ⇒ Object
Returns the value of attribute is_agregated.
-
#items ⇒ Object
Returns the value of attribute items.
-
#top_doc ⇒ Object
Returns the value of attribute top_doc.
-
#traced_items ⇒ Object
Returns the value of attribute traced_items.
Attributes inherited from BaseDocument
Instance Method Summary collapse
-
#initialize(top_doc) ⇒ Implementation
constructor
A new instance of Implementation.
- #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) ⇒ Implementation
Returns a new instance of Implementation.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/almirah/doc_types/implementation.rb', line 6 def initialize(top_doc) super() @top_doc = top_doc @is_agregated = true @traced_items = {} @id = if @is_agregated top_doc.id + '-sources' else top_doc.id + '-' + bottom_doc.id end @title = 'Implementation Matrix: ' + @id end |
Instance Attribute Details
#bottom_doc ⇒ Object
Returns the value of attribute bottom_doc.
4 5 6 |
# File 'lib/almirah/doc_types/implementation.rb', line 4 def bottom_doc @bottom_doc end |
#is_agregated ⇒ Object
Returns the value of attribute is_agregated.
4 5 6 |
# File 'lib/almirah/doc_types/implementation.rb', line 4 def is_agregated @is_agregated end |
#items ⇒ Object
Returns the value of attribute items.
4 5 6 |
# File 'lib/almirah/doc_types/implementation.rb', line 4 def items @items end |
#top_doc ⇒ Object
Returns the value of attribute top_doc.
4 5 6 |
# File 'lib/almirah/doc_types/implementation.rb', line 4 def top_doc @top_doc end |
#traced_items ⇒ Object
Returns the value of attribute traced_items.
4 5 6 |
# File 'lib/almirah/doc_types/implementation.rb', line 4 def traced_items @traced_items end |
Instance Method Details
#render_table_row(top_item) ⇒ Object
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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/almirah/doc_types/implementation.rb', line 53 def render_table_row(top_item) s = '' top_f_text = top_item.format_string(top_item.text) id_color = '' if top_item.source_code_links && top_item.source_code_links.length.positive? top_item_rendered = false top_item.source_code_links.each do |bottom_item| id_color = "style='background-color: #cff4d2;'" bottom_f_text = bottom_item.format_string(bottom_item.text) file_name = bottom_item.parent_doc.id repository = bottom_item.parent_doc.repository p = bottom_item.parent_doc.html_file_path.split('/build/source_files/').last html_source_file_relative_path = "./../../source_files/#{p}" 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: 28%;'>#{top_f_text}</td>\n" s += "\t\t<td class=\"item_id\"><a href=\"#{html_source_file_relative_path}##{bottom_item.id}\" class=\"external\">#{bottom_item.id}</a></td>\n" s += "\t\t<td class=\"item_text\" style='width: 16%;'>#{repository}</td>\n" s += "\t\t<td class=\"item_text\" style='width: 16%;'>#{file_name}</td>\n" s += "\t\t<td class=\"item_text\" style='width: 28%;'>#{bottom_f_text}</td>\n" s += "\t</tr>\n" top_item_rendered = true @traced_items[top_item.id.to_s.downcase] = top_item end unless top_item_rendered 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: 28%;'>#{top_f_text}</td>\n" s += "\t\t<td class=\"item_id\"></td>\n" s += "\t\t<td class=\"item_text\" style='width: 16%;'></td>\n" s += "\t\t<td class=\"item_text\" style='width: 16%;'></td>\n" s += "\t\t<td class=\"item_text\" style='width: 28%;'></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: 28%;'>#{top_f_text}</td>\n" s += "\t\t<td class=\"item_id\"></td>\n" s += "\t\t<td class=\"item_text\" style='width: 16%;'></td>\n" s += "\t\t<td class=\"item_text\" style='width: 16%;'></td>\n" s += "\t\t<td class=\"item_text\" style='width: 28%;'></td>\n" s += "\t</tr>\n" end s end |
#to_console ⇒ Object
22 23 24 |
# File 'lib/almirah/doc_types/implementation.rb', line 22 def to_console puts "\e[35m" + 'Implementation: ' + @id + "\e[0m" end |
#to_html(nav_pane, output_file_path) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/almirah/doc_types/implementation.rb', line 26 def to_html(nav_pane, output_file_path) html_rows = [] html_rows.append('') s = "<h1>#{@title}</h1>\n" s += "<table class=\"controlled\">\n" s += "\t<thead>" s += "\t\t<th>#</th>" s += "\t\t<th style='font-weight: bold;'>#{@top_doc.title}</th>" s += "\t\t<th>#</th>" s += "\t\t<th style='font-weight: bold;'>Repository</th>" s += "\t\t<th style='font-weight: bold;'>File Name</th>" s += "\t\t<th style='font-weight: bold;'>Comment</th>" s += "\t</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" save_html_to_file(html_rows, nav_pane, output_file_path) end |