Almirah 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/bin/almirah +2 -2
  3. data/lib/almirah/doc_fabric.rb +7 -0
  4. data/lib/almirah/doc_items/blockquote.rb +15 -16
  5. data/lib/almirah/doc_items/code_block.rb +19 -21
  6. data/lib/almirah/doc_items/controlled_paragraph.rb +2 -2
  7. data/lib/almirah/doc_items/controlled_table.rb +11 -11
  8. data/lib/almirah/doc_items/controlled_table_row.rb +15 -18
  9. data/lib/almirah/doc_items/doc_footer.rb +10 -13
  10. data/lib/almirah/doc_items/doc_item.rb +2 -2
  11. data/lib/almirah/doc_items/heading.rb +1 -1
  12. data/lib/almirah/doc_items/image.rb +25 -27
  13. data/lib/almirah/doc_items/markdown_list.rb +2 -2
  14. data/lib/almirah/doc_items/markdown_table.rb +9 -2
  15. data/lib/almirah/doc_items/scope_table.rb +188 -0
  16. data/lib/almirah/doc_items/text_line.rb +26 -22
  17. data/lib/almirah/doc_items/todo_block.rb +15 -16
  18. data/lib/almirah/doc_items/work_item.rb +129 -0
  19. data/lib/almirah/doc_parser.rb +14 -8
  20. data/lib/almirah/doc_types/base_document.rb +21 -5
  21. data/lib/almirah/doc_types/coverage.rb +3 -3
  22. data/lib/almirah/doc_types/critical_chain_page.rb +218 -0
  23. data/lib/almirah/doc_types/decision.rb +152 -7
  24. data/lib/almirah/doc_types/decision_grouping.rb +17 -0
  25. data/lib/almirah/doc_types/decisions_overview.rb +591 -31
  26. data/lib/almirah/doc_types/implementation.rb +98 -98
  27. data/lib/almirah/doc_types/index.rb +11 -12
  28. data/lib/almirah/doc_types/persistent_document.rb +1 -1
  29. data/lib/almirah/doc_types/planning_dates.rb +17 -0
  30. data/lib/almirah/doc_types/protocol.rb +16 -20
  31. data/lib/almirah/doc_types/source_file.rb +1 -1
  32. data/lib/almirah/doc_types/traceability.rb +124 -133
  33. data/lib/almirah/dom/doc_section.rb +1 -1
  34. data/lib/almirah/navigation_pane.rb +9 -13
  35. data/lib/almirah/project/critical_chain.rb +117 -0
  36. data/lib/almirah/project/doc_linker.rb +4 -4
  37. data/lib/almirah/project/fever_chart.rb +94 -0
  38. data/lib/almirah/project/project_data.rb +8 -2
  39. data/lib/almirah/project/work_item_scheduler.rb +166 -0
  40. data/lib/almirah/project/working_calendar.rb +112 -0
  41. data/lib/almirah/project.rb +146 -9
  42. data/lib/almirah/project_configuration.rb +126 -29
  43. data/lib/almirah/project_template.rb +6 -6
  44. data/lib/almirah/project_utility.rb +3 -5
  45. data/lib/almirah/search/specifications_db.rb +2 -2
  46. data/lib/almirah/source_file_parser.rb +2 -3
  47. data/lib/almirah/templates/css/main.css +160 -0
  48. data/lib/almirah/templates/scripts/main.js +3 -1
  49. data/lib/almirah.rb +1 -2
  50. metadata +11 -2
@@ -1,104 +1,104 @@
1
1
  require_relative 'base_document'
2
2
 
3
3
  class Implementation < BaseDocument
4
- attr_accessor :top_doc, :bottom_doc, :items, :is_agregated, :traced_items
5
-
6
- def initialize(top_doc)
7
- super()
8
- @top_doc = top_doc
9
-
10
- @is_agregated = true
11
- @traced_items = {}
12
-
13
- @id = if @is_agregated
14
- top_doc.id + '-sources'
15
- else
16
- top_doc.id + '-' + bottom_doc.id
17
- end
18
-
19
- @title = 'Implementation Matrix: ' + @id
4
+ attr_accessor :top_doc, :bottom_doc, :items, :is_agregated, :traced_items
5
+
6
+ def initialize(top_doc)
7
+ super()
8
+ @top_doc = top_doc
9
+
10
+ @is_agregated = true
11
+ @traced_items = {}
12
+
13
+ @id = if @is_agregated
14
+ top_doc.id + '-sources'
15
+ else
16
+ top_doc.id + '-' + bottom_doc.id
17
+ end
18
+
19
+ @title = 'Implementation Matrix: ' + @id
20
+ end
21
+
22
+ def to_console
23
+ puts "\e[35m" + 'Implementation: ' + @id + "\e[0m"
24
+ end
25
+
26
+ def to_html(nav_pane, output_file_path)
27
+ html_rows = []
28
+
29
+ html_rows.append('')
30
+ s = "<h1>#{@title}</h1>\n"
31
+ s += "<table class=\"controlled\">\n"
32
+ s += "\t<thead>"
33
+ s += "\t\t<th>#</th>"
34
+ s += "\t\t<th style='font-weight: bold;'>#{@top_doc.title}</th>"
35
+ s += "\t\t<th>#</th>"
36
+ s += "\t\t<th style='font-weight: bold;'>Repository</th>"
37
+ s += "\t\t<th style='font-weight: bold;'>File Name</th>"
38
+ s += "\t\t<th style='font-weight: bold;'>Comment</th>"
39
+ s += "\t</thead>\n"
40
+ html_rows.append s
41
+
42
+ sorted_items = @top_doc.controlled_items.sort_by { |w| w.id }
43
+
44
+ sorted_items.each do |top_item|
45
+ row = render_table_row top_item
46
+ html_rows.append row
20
47
  end
21
-
22
- def to_console
23
- puts "\e[35m" + 'Implementation: ' + @id + "\e[0m"
24
- end
25
-
26
- def to_html(nav_pane, output_file_path)
27
- html_rows = []
28
-
29
- html_rows.append('')
30
- s = "<h1>#{@title}</h1>\n"
31
- s += "<table class=\"controlled\">\n"
32
- s += "\t<thead>"
33
- s += "\t\t<th>#</th>"
34
- s += "\t\t<th style='font-weight: bold;'>#{@top_doc.title}</th>"
35
- s += "\t\t<th>#</th>"
36
- s += "\t\t<th style='font-weight: bold;'>Repository</th>"
37
- s += "\t\t<th style='font-weight: bold;'>File Name</th>"
38
- s += "\t\t<th style='font-weight: bold;'>Comment</th>"
39
- s += "\t</thead>\n"
40
- html_rows.append s
41
-
42
- sorted_items = @top_doc.controlled_items.sort_by { |w| w.id }
43
-
44
- sorted_items.each do |top_item|
45
- row = render_table_row top_item
46
- html_rows.append row
47
- end
48
- html_rows.append "</table>\n"
49
-
50
- save_html_to_file(html_rows, nav_pane, output_file_path)
51
- end
52
-
53
- def render_table_row(top_item)
54
- s = ''
55
- top_f_text = top_item.format_string(top_item.text)
56
- id_color = ''
57
-
58
- if top_item.source_code_links && top_item.source_code_links.length.positive?
59
-
60
- top_item_rendered = false
61
-
62
- top_item.source_code_links.each do |bottom_item|
63
- id_color = "style='background-color: #cff4d2;'"
64
- bottom_f_text = bottom_item.format_string(bottom_item.text)
65
- file_name = bottom_item.parent_doc.id
66
- repository = bottom_item.parent_doc.repository
67
-
68
- p = bottom_item.parent_doc.html_file_path.split('/build/source_files/').last
69
- html_source_file_relative_path = "./../../source_files/#{p}"
70
-
71
- s += "\t<tr>\n"
72
- 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"
73
- s += "\t\t<td class=\"item_text\" style='width: 28%;'>#{top_f_text}</td>\n"
74
- 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"
75
- s += "\t\t<td class=\"item_text\" style='width: 16%;'>#{repository}</td>\n"
76
- s += "\t\t<td class=\"item_text\" style='width: 16%;'>#{file_name}</td>\n"
77
- s += "\t\t<td class=\"item_text\" style='width: 28%;'>#{bottom_f_text}</td>\n"
78
- s += "\t</tr>\n"
79
- top_item_rendered = true
80
- @traced_items[top_item.id.to_s.downcase] = top_item
81
- end
82
- unless top_item_rendered
83
- s += "\t<tr>\n"
84
- 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"
85
- s += "\t\t<td class=\"item_text\" style='width: 28%;'>#{top_f_text}</td>\n"
86
- s += "\t\t<td class=\"item_id\"></td>\n"
87
- s += "\t\t<td class=\"item_text\" style='width: 16%;'></td>\n"
88
- s += "\t\t<td class=\"item_text\" style='width: 16%;'></td>\n"
89
- s += "\t\t<td class=\"item_text\" style='width: 28%;'></td>\n"
90
- s += "\t</tr>\n"
91
- end
92
- else
93
- s += "\t<tr>\n"
94
- 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"
95
- s += "\t\t<td class=\"item_text\" style='width: 28%;'>#{top_f_text}</td>\n"
96
- s += "\t\t<td class=\"item_id\"></td>\n"
97
- s += "\t\t<td class=\"item_text\" style='width: 16%;'></td>\n"
98
- s += "\t\t<td class=\"item_text\" style='width: 16%;'></td>\n"
99
- s += "\t\t<td class=\"item_text\" style='width: 28%;'></td>\n"
100
- s += "\t</tr>\n"
101
- end
102
- s
48
+ html_rows.append "</table>\n"
49
+
50
+ save_html_to_file(html_rows, nav_pane, output_file_path)
51
+ end
52
+
53
+ def render_table_row(top_item)
54
+ s = ''
55
+ top_f_text = top_item.format_string(top_item.text)
56
+ id_color = ''
57
+
58
+ if top_item.source_code_links && top_item.source_code_links.length.positive?
59
+
60
+ top_item_rendered = false
61
+
62
+ top_item.source_code_links.each do |bottom_item|
63
+ id_color = "style='background-color: #cff4d2;'"
64
+ bottom_f_text = bottom_item.format_string(bottom_item.text)
65
+ file_name = bottom_item.parent_doc.id
66
+ repository = bottom_item.parent_doc.repository
67
+
68
+ p = bottom_item.parent_doc.html_file_path.split('/build/source_files/').last
69
+ html_source_file_relative_path = "./../../source_files/#{p}"
70
+
71
+ s += "\t<tr>\n"
72
+ 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"
73
+ s += "\t\t<td class=\"item_text\" style='width: 28%;'>#{top_f_text}</td>\n"
74
+ 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"
75
+ s += "\t\t<td class=\"item_text\" style='width: 16%;'>#{repository}</td>\n"
76
+ s += "\t\t<td class=\"item_text\" style='width: 16%;'>#{file_name}</td>\n"
77
+ s += "\t\t<td class=\"item_text\" style='width: 28%;'>#{bottom_f_text}</td>\n"
78
+ s += "\t</tr>\n"
79
+ top_item_rendered = true
80
+ @traced_items[top_item.id.to_s.downcase] = top_item
81
+ end
82
+ unless top_item_rendered
83
+ s += "\t<tr>\n"
84
+ 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"
85
+ s += "\t\t<td class=\"item_text\" style='width: 28%;'>#{top_f_text}</td>\n"
86
+ s += "\t\t<td class=\"item_id\"></td>\n"
87
+ s += "\t\t<td class=\"item_text\" style='width: 16%;'></td>\n"
88
+ s += "\t\t<td class=\"item_text\" style='width: 16%;'></td>\n"
89
+ s += "\t\t<td class=\"item_text\" style='width: 28%;'></td>\n"
90
+ s += "\t</tr>\n"
91
+ end
92
+ else
93
+ s += "\t<tr>\n"
94
+ 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"
95
+ s += "\t\t<td class=\"item_text\" style='width: 28%;'>#{top_f_text}</td>\n"
96
+ s += "\t\t<td class=\"item_id\"></td>\n"
97
+ s += "\t\t<td class=\"item_text\" style='width: 16%;'></td>\n"
98
+ s += "\t\t<td class=\"item_text\" style='width: 16%;'></td>\n"
99
+ s += "\t\t<td class=\"item_text\" style='width: 28%;'></td>\n"
100
+ s += "\t</tr>\n"
103
101
  end
102
+ s
103
+ end
104
104
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require_relative 'base_document'
4
4
 
5
- class Index < BaseDocument # rubocop:disable Metrics/ClassLength,Style/Documentation
5
+ class Index < BaseDocument
6
6
  attr_accessor :project
7
7
 
8
8
  def initialize(project)
@@ -16,11 +16,10 @@ class Index < BaseDocument # rubocop:disable Metrics/ClassLength,Style/Documenta
16
16
  puts "\e[36mIndex: #{@id}\e[0m"
17
17
  end
18
18
 
19
- def to_html(output_file_path) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
19
+ def to_html(output_file_path)
20
20
  html_rows = []
21
21
 
22
22
  html_rows.append('')
23
- s = "<h1>#{@title}</h1>\n"
24
23
 
25
24
  # Specifications
26
25
  s = "<h2>Specifications</h2>\n"
@@ -41,7 +40,7 @@ class Index < BaseDocument # rubocop:disable Metrics/ClassLength,Style/Documenta
41
40
 
42
41
  sorted_items = @project.project_data.specifications.sort_by(&:id)
43
42
 
44
- sorted_items.each do |doc| # rubocop:disable Metrics/BlockLength
43
+ sorted_items.each do |doc|
45
44
  s = "\t<tr>\n"
46
45
  s += "\t\t<td class=\"item_text\" style='padding: 5px;'><a href=\"./specifications/#{doc.id}/#{doc.id}.html\" class=\"external\"><i class=\"fa fa-file-text-o\" style='background-color: ##{doc.color};'> </i>&nbsp#{doc.title}</a></td>\n"
47
46
  s += "\t\t<td class=\"item_id\" style='width: 7%;'>#{doc.controlled_items.length}</td>\n"
@@ -121,11 +120,11 @@ class Index < BaseDocument # rubocop:disable Metrics/ClassLength,Style/Documenta
121
120
  s += "\t\t<td class=\"item_text\" style='padding: 5px;'><a href=\"./specifications/#{doc.id}/#{doc.id}.html\" class=\"external\">#{doc.title}</a></td>\n"
122
121
  s += "\t\t<td class=\"item_id\" style='width: 7%;'>#{'%.2f' % coverage}%</td>\n"
123
122
  s += "\t\t<td class=\"item_text\" style='width: 25%; padding: 5px;'><i class=\"fa fa-file-text-o\" style='background-color: ##{doc.top_doc.color};'> </i>&nbsp#{doc.top_doc.title}</td>\n"
124
- if doc.bottom_doc
125
- s += "\t\t<td class=\"item_text\" style='width: 25%; padding: 5px;'><i class=\"fa fa-file-text-o\" style='background-color: ##{doc.bottom_doc.color};'> </i>&nbsp#{doc.bottom_doc.title}</td>\n"
126
- else
127
- s += "\t\t<td class=\"item_text\" style='width: 25%; padding: 5px;'><i class=\"fa fa-circle-o\"'> </i>&nbspAll References</td>\n"
128
- end
123
+ s += if doc.bottom_doc
124
+ "\t\t<td class=\"item_text\" style='width: 25%; padding: 5px;'><i class=\"fa fa-file-text-o\" style='background-color: ##{doc.bottom_doc.color};'> </i>&nbsp#{doc.bottom_doc.title}</td>\n"
125
+ else
126
+ "\t\t<td class=\"item_text\" style='width: 25%; padding: 5px;'><i class=\"fa fa-circle-o\"'> </i>&nbspAll References</td>\n"
127
+ end
129
128
  s += "</tr>\n"
130
129
  html_rows.append s
131
130
  end
@@ -158,7 +157,7 @@ class Index < BaseDocument # rubocop:disable Metrics/ClassLength,Style/Documenta
158
157
  end
159
158
 
160
159
  s += "\t\t<td class=\"item_text\" style='padding: 5px;'><a href=\"./specifications/#{doc.id}/#{doc.id}.html\" class=\"external\">#{doc.title}</a></td>\n"
161
- s += "\t\t<td class=\"item_id\" style='width: 7%;'>#{'%.2f' % coverage}%</td>\n" # rubocop:disable Style/FormatString
160
+ s += "\t\t<td class=\"item_id\" style='width: 7%;'>#{'%.2f' % coverage}%</td>\n"
162
161
  s += "\t\t<td class=\"item_id\" style='width: 7%; #{test_step_color}' title='pass/fail'> #{doc.passed_steps_number}/#{doc.failed_steps_number} </td>\n"
163
162
  s += "\t\t<td class=\"item_text\" style='width: 25%; padding: 5px;'>\
164
163
  <i class=\"fa fa-file-text-o\" style='background-color: ##{doc.top_doc.color};'> </i>\
@@ -187,13 +186,13 @@ class Index < BaseDocument # rubocop:disable Metrics/ClassLength,Style/Documenta
187
186
 
188
187
  implemented_items = 0
189
188
  doc.top_doc.controlled_items.each do |i|
190
- implemented_items += 1 if i.source_code_links && i.source_code_links.length.positive? # rubocop:disable Style/SafeNavigation
189
+ implemented_items += 1 if i.source_code_links && i.source_code_links.length.positive?
191
190
  end
192
191
 
193
192
  coverage = implemented_items.to_f / doc.top_doc.controlled_items.length * 100.0
194
193
 
195
194
  s += "\t\t<td class=\"item_text\" style='padding: 5px;'><a href=\"./specifications/#{doc.id}/#{doc.id}.html\" class=\"external\">#{doc.title}</a></td>\n"
196
- s += "\t\t<td class=\"item_id\" style='width: 7%;'>#{'%.2f' % coverage}%</td>\n" # rubocop:disable Style/FormatString
195
+ s += "\t\t<td class=\"item_id\" style='width: 7%;'>#{'%.2f' % coverage}%</td>\n"
197
196
  s += "\t\t<td class=\"item_text\" style='width: 25%; padding: 5px;'>\
198
197
  <i class=\"fa fa-file-text-o\" style='background-color: ##{doc.top_doc.color};'> </i>\
199
198
  #{doc.top_doc.title}</td>\n"
@@ -2,7 +2,7 @@
2
2
 
3
3
  require_relative 'base_document'
4
4
 
5
- class PersistentDocument < BaseDocument # rubocop:disable Style/Documentation
5
+ class PersistentDocument < BaseDocument
6
6
  attr_accessor :path, :items, :controlled_items, :headings, :up_link_docs, :frontmatter
7
7
 
8
8
  def initialize(fele_path)
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'date'
4
+
5
+ # Shared date bucketing for the planning views (ADR-182): the recent Fridays a
6
+ # time-series trail is sampled on. Used by the overview's velocity chart and the
7
+ # Critical Chain page's fever-chart trail (ADR-196).
8
+ module PlanningDates
9
+ # `count` Fridays ending at the Friday on or before `reference_date`, oldest
10
+ # first.
11
+ def recent_fridays(reference_date, count)
12
+ friday_wday = 5
13
+ days_back = (reference_date.wday - friday_wday) % 7
14
+ most_recent = reference_date - days_back
15
+ (0...count).to_a.reverse.map { |i| most_recent - (7 * i) }
16
+ end
17
+ end
@@ -1,28 +1,24 @@
1
- require_relative "persistent_document"
1
+ require_relative 'persistent_document'
2
2
 
3
3
  class Protocol < PersistentDocument
4
+ attr_accessor :specifications_path
4
5
 
5
- attr_accessor :specifications_path
6
+ def initialize(fele_path)
7
+ super
8
+ @id = File.basename(fele_path, File.extname(fele_path)).downcase
9
+ @specifications_path = './../../../specifications/'
10
+ end
6
11
 
7
- def initialize(fele_path)
8
- super
9
- @id = File.basename(fele_path, File.extname(fele_path)).downcase
10
- @specifications_path = './../../../specifications/'
11
- end
12
-
13
- def to_html(nav_pane, output_file_path)
14
-
15
- html_rows = Array.new
16
-
17
- html_rows.append('')
12
+ def to_html(nav_pane, output_file_path)
13
+ html_rows = []
18
14
 
19
- @items.each do |item|
20
- a = item.to_html
21
- html_rows.append a
22
- end
15
+ html_rows.append('')
23
16
 
24
- self.save_html_to_file(html_rows, nav_pane, output_file_path)
25
-
17
+ @items.each do |item|
18
+ a = item.to_html
19
+ html_rows.append a
26
20
  end
27
21
 
28
- end
22
+ save_html_to_file(html_rows, nav_pane, output_file_path)
23
+ end
24
+ end
@@ -63,7 +63,7 @@ class SourceFile < PersistentDocument
63
63
  save_to_file(html_rows, nil, output_file_path)
64
64
  end
65
65
 
66
- def save_to_file(html_rows, nav_pane, output_file_path) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
66
+ def save_to_file(html_rows, nav_pane, output_file_path)
67
67
  gem_root = File.expand_path './../../..', File.dirname(__FILE__)
68
68
  template_file = "#{gem_root}/lib/almirah/templates/page.html"
69
69
 
@@ -1,142 +1,133 @@
1
- require_relative "base_document"
1
+ require_relative 'base_document'
2
2
 
3
3
  class Traceability < BaseDocument
4
-
5
- attr_accessor :top_doc
6
- attr_accessor :bottom_doc
7
- attr_accessor :items
8
- attr_accessor :is_agregated
9
- attr_accessor :traced_items
10
-
11
- def initialize(top_doc, bottom_doc)
12
- super()
13
- @top_doc = top_doc
14
- @bottom_doc = bottom_doc
15
- @is_agregated = if bottom_doc
16
- false
17
- else
18
- true
19
- end
20
- @traced_items = {}
21
-
22
- if @is_agregated
23
- @id = top_doc.id + "-all"
24
- else
25
- @id = top_doc.id + "-" + bottom_doc.id
26
- end
27
-
28
- @title = "Traceability Matrix: " + @id
29
- end
30
-
31
- def to_console
32
- puts "\e[35m" + "Traceability: " + @id + "\e[0m"
4
+ attr_accessor :top_doc, :bottom_doc, :items, :is_agregated, :traced_items
5
+
6
+ def initialize(top_doc, bottom_doc)
7
+ super()
8
+ @top_doc = top_doc
9
+ @bottom_doc = bottom_doc
10
+ @is_agregated = if bottom_doc
11
+ false
12
+ else
13
+ true
14
+ end
15
+ @traced_items = {}
16
+
17
+ @id = if @is_agregated
18
+ top_doc.id + '-all'
19
+ else
20
+ top_doc.id + '-' + bottom_doc.id
21
+ end
22
+
23
+ @title = 'Traceability Matrix: ' + @id
24
+ end
25
+
26
+ def to_console
27
+ puts "\e[35m" + 'Traceability: ' + @id + "\e[0m"
28
+ end
29
+
30
+ def to_html(nav_pane, output_file_path)
31
+ html_rows = []
32
+
33
+ html_rows.append('')
34
+ s = "<h1>#{@title}</h1>\n"
35
+ s += "<table class=\"controlled\">\n"
36
+ s += "\t<thead> <th>#</th> <th style='font-weight: bold;'>#{@top_doc.title}</th> "
37
+ s += if @bottom_doc
38
+ "<th>#</th> <th style='font-weight: bold;'>#{@bottom_doc.title}</th> "
39
+ else
40
+ "<th>#</th> <th style='font-weight: bold;'>All References</th> "
41
+ end
42
+ s += "<th style='font-weight: bold;'>Document Section</th>"
43
+ s += "</thead>\n"
44
+ html_rows.append s
45
+
46
+ sorted_items = @top_doc.controlled_items.sort_by { |w| w.id }
47
+
48
+ sorted_items.each do |top_item|
49
+ row = render_table_row top_item
50
+ html_rows.append row
33
51
  end
34
-
35
- def to_html(nav_pane, output_file_path)
36
-
37
- html_rows = Array.new
38
-
39
- html_rows.append('')
40
- s = "<h1>#{@title}</h1>\n"
41
- s += "<table class=\"controlled\">\n"
42
- s += "\t<thead> <th>#</th> <th style='font-weight: bold;'>#{@top_doc.title}</th> "
43
- if @bottom_doc
44
- s += "<th>#</th> <th style='font-weight: bold;'>#{@bottom_doc.title}</th> "
45
- else
46
- s += "<th>#</th> <th style='font-weight: bold;'>All References</th> "
52
+ html_rows.append "</table>\n"
53
+
54
+ save_html_to_file(html_rows, nav_pane, output_file_path)
55
+ end
56
+
57
+ def render_table_row(top_item)
58
+ s = ''
59
+ top_f_text = top_item.format_string(top_item.text)
60
+ id_color = ''
61
+
62
+ if top_item.down_links
63
+
64
+ if @is_agregated
65
+
66
+ top_item_rendered = false
67
+
68
+ top_item.down_links.each do |bottom_item|
69
+ id_color = "style='background-color: ##{bottom_item.parent_doc.color};'"
70
+ bottom_f_text = bottom_item.format_string(bottom_item.text)
71
+ document_section = bottom_item.parent_heading.get_section_info_html
72
+ s += "\t<tr>\n"
73
+ 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"
74
+ s += "\t\t<td class=\"item_text\" style='width: 34%;'>#{top_f_text}</td>\n"
75
+ s += "\t\t<td class=\"item_id\" #{id_color}><a href=\"./../#{bottom_item.parent_doc.id}/#{bottom_item.parent_doc.id}.html##{bottom_item.id}\" class=\"external\">#{bottom_item.id}</a></td>\n"
76
+ s += "\t\t<td class=\"item_text\" style='width: 34%;'>#{bottom_f_text}</td>\n"
77
+ s += "\t\t<td class=\"item_text\" style='width: 16%;'>#{document_section}</td>\n"
78
+ s += "\t</tr>\n"
79
+ top_item_rendered = true
80
+ @traced_items[top_item.id.to_s.downcase] = top_item
47
81
  end
48
- s += "<th style='font-weight: bold;'>Document Section</th>"
49
- s += "</thead>\n"
50
- html_rows.append s
51
-
52
- sorted_items = @top_doc.controlled_items.sort_by { |w| w.id }
53
-
54
- sorted_items.each do |top_item|
55
- row = render_table_row top_item
56
- html_rows.append row
82
+ unless top_item_rendered
83
+ s += "\t<tr>\n"
84
+ 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"
85
+ s += "\t\t<td class=\"item_text\" style='width: 34%;'>#{top_f_text}</td>\n"
86
+ s += "\t\t<td class=\"item_id\"></td>\n"
87
+ s += "\t\t<td class=\"item_text\" style='width: 34%;'></td>\n"
88
+ s += "\t\t<td class=\"item_text\" style='width: 16%;'></td>\n"
89
+ s += "\t</tr>\n"
57
90
  end
58
- html_rows.append "</table>\n"
59
91
 
60
- self.save_html_to_file(html_rows, nav_pane, output_file_path)
61
-
62
- end
63
-
64
- def render_table_row(top_item)
65
- s = ""
66
- top_f_text = top_item.format_string( top_item.text )
67
- id_color = ""
68
-
69
- if top_item.down_links
70
-
71
- if @is_agregated
72
-
73
- top_item_rendered = false
74
-
75
- top_item.down_links.each do |bottom_item|
76
- id_color = "style='background-color: ##{bottom_item.parent_doc.color};'"
77
- bottom_f_text = bottom_item.format_string( bottom_item.text )
78
- document_section = bottom_item.parent_heading.get_section_info_html
79
- s += "\t<tr>\n"
80
- 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"
81
- s += "\t\t<td class=\"item_text\" style='width: 34%;'>#{top_f_text}</td>\n"
82
- s += "\t\t<td class=\"item_id\" #{id_color}><a href=\"./../#{bottom_item.parent_doc.id}/#{bottom_item.parent_doc.id}.html##{bottom_item.id}\" class=\"external\">#{bottom_item.id}</a></td>\n"
83
- s += "\t\t<td class=\"item_text\" style='width: 34%;'>#{bottom_f_text}</td>\n"
84
- s += "\t\t<td class=\"item_text\" style='width: 16%;'>#{document_section}</td>\n"
85
- s += "\t</tr>\n"
86
- top_item_rendered = true
87
- @traced_items[top_item.id.to_s.downcase] = top_item
88
- end
89
- unless top_item_rendered
90
- s += "\t<tr>\n"
91
- 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"
92
- s += "\t\t<td class=\"item_text\" style='width: 34%;'>#{top_f_text}</td>\n"
93
- s += "\t\t<td class=\"item_id\"></td>\n"
94
- s += "\t\t<td class=\"item_text\" style='width: 34%;'></td>\n"
95
- s += "\t\t<td class=\"item_text\" style='width: 16%;'></td>\n"
96
- s += "\t</tr>\n"
97
- end
98
-
99
- else
100
- top_item_rendered = false
101
- top_item.down_links.each do |bottom_item|
102
-
103
- id_color = ""
104
-
105
- if bottom_item.parent_doc.id == @bottom_doc.id
106
-
107
- bottom_f_text = bottom_item.format_string( bottom_item.text )
108
- document_section = bottom_item.parent_heading.get_section_info_html
109
-
110
- s += "\t<tr>\n"
111
- 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"
112
- s += "\t\t<td class=\"item_text\" style='width: 34%;'>#{top_f_text}</td>\n"
113
- s += "\t\t<td class=\"item_id\"><a href=\"./../#{bottom_item.parent_doc.id}/#{bottom_item.parent_doc.id}.html##{bottom_item.id}\" class=\"external\">#{bottom_item.id}</a></td>\n"
114
- s += "\t\t<td class=\"item_text\" style='width: 34%;'>#{bottom_f_text}</td>\n"
115
- s += "\t\t<td class=\"item_text\" style='width: 16%;'>#{document_section}</td>\n"
116
- s += "\t</tr>\n"
117
- top_item_rendered = true
118
- @traced_items[top_item.id.to_s.downcase] = top_item
119
- end
120
- end
121
- unless top_item_rendered
122
- s += "\t<tr>\n"
123
- 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"
124
- s += "\t\t<td class=\"item_text\" style='width: 34%;'>#{top_f_text}</td>\n"
125
- s += "\t\t<td class=\"item_id\"></td>\n"
126
- s += "\t\t<td class=\"item_text\" style='width: 34%;'></td>\n"
127
- s += "\t\t<td class=\"item_text\" style='width: 16%;'></td>\n"
128
- s += "\t</tr>\n"
129
- end
130
- end
131
- else
132
- s += "\t<tr>\n"
133
- 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"
134
- s += "\t\t<td class=\"item_text\" style='width: 34%;'>#{top_f_text}</td>\n"
135
- s += "\t\t<td class=\"item_id\"></td>\n"
136
- s += "\t\t<td class=\"item_text\" style='width: 34%;'></td>\n"
137
- s += "\t\t<td class=\"item_text\" style='width: 16%;'></td>\n"
138
- s += "\t</tr>\n"
92
+ else
93
+ top_item_rendered = false
94
+ top_item.down_links.each do |bottom_item|
95
+ id_color = ''
96
+
97
+ next unless bottom_item.parent_doc.id == @bottom_doc.id
98
+
99
+ bottom_f_text = bottom_item.format_string(bottom_item.text)
100
+ document_section = bottom_item.parent_heading.get_section_info_html
101
+
102
+ s += "\t<tr>\n"
103
+ 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"
104
+ s += "\t\t<td class=\"item_text\" style='width: 34%;'>#{top_f_text}</td>\n"
105
+ s += "\t\t<td class=\"item_id\"><a href=\"./../#{bottom_item.parent_doc.id}/#{bottom_item.parent_doc.id}.html##{bottom_item.id}\" class=\"external\">#{bottom_item.id}</a></td>\n"
106
+ s += "\t\t<td class=\"item_text\" style='width: 34%;'>#{bottom_f_text}</td>\n"
107
+ s += "\t\t<td class=\"item_text\" style='width: 16%;'>#{document_section}</td>\n"
108
+ s += "\t</tr>\n"
109
+ top_item_rendered = true
110
+ @traced_items[top_item.id.to_s.downcase] = top_item
111
+ end
112
+ unless top_item_rendered
113
+ s += "\t<tr>\n"
114
+ 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"
115
+ s += "\t\t<td class=\"item_text\" style='width: 34%;'>#{top_f_text}</td>\n"
116
+ s += "\t\t<td class=\"item_id\"></td>\n"
117
+ s += "\t\t<td class=\"item_text\" style='width: 34%;'></td>\n"
118
+ s += "\t\t<td class=\"item_text\" style='width: 16%;'></td>\n"
119
+ s += "\t</tr>\n"
139
120
  end
140
- return s
121
+ end
122
+ else
123
+ s += "\t<tr>\n"
124
+ 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"
125
+ s += "\t\t<td class=\"item_text\" style='width: 34%;'>#{top_f_text}</td>\n"
126
+ s += "\t\t<td class=\"item_id\"></td>\n"
127
+ s += "\t\t<td class=\"item_text\" style='width: 34%;'></td>\n"
128
+ s += "\t\t<td class=\"item_text\" style='width: 16%;'></td>\n"
129
+ s += "\t</tr>\n"
141
130
  end
131
+ s
132
+ end
142
133
  end