Almirah 0.2.2 → 0.2.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1924d26950a0c5c34f254da368edfa0c10a4a8aec9359bbb24239170fd6ded0b
4
- data.tar.gz: 225aec68760b4cb52c0ace5cd5dfe1cda664ab913859beef80f803c94ccfe9a0
3
+ metadata.gz: 2fa95a589e6285719010318ec666da5cf309ef511cd69cb2ffc6629464d64ae0
4
+ data.tar.gz: f2c8fd5747f9c5e53417744eac9caa15e2c313987d94c36b8d446434089f14fd
5
5
  SHA512:
6
- metadata.gz: 805998bbe735fbec09972bd63c3d695a9df352436c75d02f3f32aa6bc971fef9d29b3cb6ef5fd9e5a4f58cde34b41d0ed4482fe8ee5ef575bf0f0651939f16d6
7
- data.tar.gz: cc96b734b74c78a7667e17fb12d2e4f4b72c393bcf5db1044a81963b2ca49d2cf87b4adf3b386dc66cd0bcdfc57ece1aebb7896a90b83443a9dbf0909f32cd7f
6
+ metadata.gz: e0071aa202dac9bd73495fb389db3008f83ff5dff9bd61d8d4f957abb935a1727362e51a3e2c6418a7a388ea28d6baef344500ec9ec46256b803982dbd5275cd
7
+ data.tar.gz: bcfbdf1cbca81f17d3e305723c111a38327ca16f3a8e8c28795e3135041e8a97d64e0baddd1780ae826bec85ddb0cbcf5533908506debde61d1d27e31caf02bf
@@ -1,8 +1,10 @@
1
1
  require_relative 'doc_types/base_document'
2
2
  require_relative 'doc_types/specification'
3
3
  require_relative 'doc_types/protocol'
4
+ require_relative 'doc_types/coverage'
4
5
  require_relative 'doc_parser'
5
6
  require_relative 'dom/document'
7
+ require_relative 'doc_items/heading'
6
8
 
7
9
  class DocFabric
8
10
  @@color_index = 0
@@ -31,6 +33,24 @@ class DocFabric
31
33
  doc
32
34
  end
33
35
 
36
+ def self.create_coverage_matrix(specification)
37
+ doc = Coverage.new specification
38
+ Heading.reset_global_section_number
39
+ doc.headings << Heading.new(doc, doc.title, 0)
40
+ # Build dom
41
+ doc.dom = Document.new(doc.headings)
42
+ doc
43
+ end
44
+
45
+ def self.create_traceability_document(top_document, bottom_document)
46
+ doc = Traceability.new top_document, bottom_document
47
+ Heading.reset_global_section_number
48
+ doc.headings << Heading.new(doc, doc.title, 0)
49
+ # Build dom
50
+ doc.dom = Document.new(doc.headings)
51
+ doc
52
+ end
53
+
34
54
  def self.parse_document(doc)
35
55
 
36
56
  file = File.open(doc.path)
@@ -40,7 +60,6 @@ class DocFabric
40
60
  DocParser.parse(doc, file_lines)
41
61
 
42
62
  # Build dom
43
- doc.dom = Document.new(doc.headings) if doc.is_a?(Specification)
44
-
63
+ doc.dom = Document.new(doc.headings) if doc.is_a?(Specification) || doc.is_a?(Protocol)
45
64
  end
46
65
  end
@@ -11,9 +11,9 @@ class Blockquote < DocItem
11
11
  def to_html
12
12
  s = ''
13
13
  f_text = format_string(@text)
14
- if @@htmlTableRenderInProgress
14
+ if @@html_table_render_in_progress
15
15
  s += "</table>\n"
16
- @@htmlTableRenderInProgress = false
16
+ @@html_table_render_in_progress = false
17
17
  end
18
18
 
19
19
  s += "<div class=\"blockquote\"><p>#{f_text}</div>\n"
@@ -13,9 +13,9 @@ class CodeBlock < DocItem
13
13
  def to_html
14
14
  s = ''
15
15
 
16
- if @@htmlTableRenderInProgress
16
+ if @@html_table_render_in_progress
17
17
  s += "</table>\n"
18
- @@htmlTableRenderInProgress = false
18
+ @@html_table_render_in_progress = false
19
19
  end
20
20
  s += "<code>"
21
21
  @code_lines.each do |l|
@@ -1,91 +1,112 @@
1
- require_relative "paragraph"
1
+ require_relative 'paragraph'
2
2
 
3
3
  class ControlledParagraph < Paragraph
4
+ attr_accessor :id, :up_link_ids, :down_links, :coverage_links
4
5
 
5
- attr_accessor :id
6
- attr_accessor :up_link_ids
7
- attr_accessor :down_links
8
- attr_accessor :coverage_links
6
+ def initialize(doc, text, id)
7
+ super(doc, text)
8
+ @parent_heading = doc.headings[-1]
9
+ @id = id
10
+ @up_link_ids = nil
11
+ @down_links = nil
12
+ @coverage_links = nil
13
+ end
9
14
 
10
- def initialize(doc, text, id)
11
- @parent_doc = doc
12
- @parent_heading = doc.headings[-1]
13
- @text = text.strip
14
- @id = id
15
- @up_link_ids = nil
16
- @down_links = nil
17
- @coverage_links = nil
15
+ def to_html
16
+ s = ''
17
+ unless @@html_table_render_in_progress
18
+ s += "<table class=\"controlled\">\n"
19
+ s += "\t<thead> <th>#</th> <th></th> <th title=\"Up-links\">UL</th> <th title=\"Down-links\">DL</th> \
20
+ <th title=\"Test Coverage\">COV</th> </thead>\n"
21
+ @@html_table_render_in_progress = true # rubocop:disable Style/ClassVars
18
22
  end
23
+ f_text = format_string(@text)
24
+ s += "\t<tr>\n"
25
+ s += "\t\t<td class=\"item_id\"> \
26
+ <a name=\"#{@id}\" id=\"#{@id}\" href=\"##{@id}\" title=\"Paragraph ID\">#{@id}</a></td>\n"
27
+ s += "\t\t<td class=\"item_text\">#{f_text}</td>\n"
19
28
 
20
- def to_html
21
- s = ''
22
- unless @@htmlTableRenderInProgress
23
- s += "<table class=\"controlled\">\n"
24
- s += "\t<thead> <th>#</th> <th></th> <th>UL</th> <th>DL</th> <th>COV</th> </thead>\n"
25
- @@htmlTableRenderInProgress = true
29
+ if @up_link_ids
30
+ if @up_link_ids.length == 1
31
+ if tmp = /^([a-zA-Z]+)-\d+/.match(@up_link_ids[0])
32
+ up_link_doc_name = tmp[1].downcase
26
33
  end
27
- f_text = format_string(@text)
28
- s += "\t<tr>\n"
29
- s += "\t\t<td class=\"item_id\"> <a name=\"#{@id}\" id=\"#{@id}\" href=\"##{@id}\">#{@id}</a></td>\n"
30
- s += "\t\t<td class=\"item_text\">#{f_text}</td>\n"
31
-
32
- if @up_link_ids
33
- if @up_link_ids.length == 1
34
- if tmp = /^([a-zA-Z]+)[-]\d+/.match(@up_link_ids[0])
35
- up_link_doc_name = tmp[1].downcase
36
- end
37
- s += "\t\t<td class=\"item_id\"><a href=\"./../#{up_link_doc_name}/#{up_link_doc_name}.html##{@up_link_ids[0]}\" class=\"external\">#{@up_link_ids[0]}</a></td>\n"
38
- else
39
- s += "\t\t<td class=\"item_id\">"
40
- s += "<div id=\"DL_#{@id}\" style=\"display: block;\">"
41
- s += "<a href=\"#\" onclick=\"downlink_OnClick(this.parentElement); return false;\" class=\"external\">#{@up_link_ids.length}</a>"
42
- s += "</div>"
43
- s += "<div id=\"DLS_#{@id}\" style=\"display: none;\">"
44
- @up_link_ids.each do |lnk|
45
- if tmp = /^([a-zA-Z]+)[-]\d+/.match(lnk)
46
- up_link_doc_name = tmp[1].downcase
47
- end
48
- s += "\t\t\t<a href=\"./../#{up_link_doc_name}/#{up_link_doc_name}.html##{lnk}\" class=\"external\">#{lnk}</a>\n<br>"
49
- end
50
- s += "</div>"
51
- s += "</td>\n"
52
- end
53
- else
54
- s += "\t\t<td class=\"item_id\"></td>\n"
34
+ s += "\t\t<td class=\"item_id\">\
35
+ <a href=\"./../#{up_link_doc_name}/#{up_link_doc_name}.html##{@up_link_ids[0]}\" \
36
+ class=\"external\" title=\"Linked to\">#{@up_link_ids[0]}</a></td>\n"
37
+ else
38
+ s += "\t\t<td class=\"item_id\">"
39
+ s += "<div id=\"UL_#{@id}\" style=\"display: block;\">"
40
+ s += "<a href=\"#\" onclick=\"upLink_OnClick(this.parentElement); return false;\" \
41
+ class=\"external\" title=\"Number of up-links\">#{@up_link_ids.length}</a>"
42
+ s += '</div>'
43
+ s += "<div id=\"ULS_#{@id}\" style=\"display: none;\">"
44
+ @up_link_ids.each do |lnk|
45
+ if tmp = /^([a-zA-Z]+)-\d+/.match(lnk)
46
+ up_link_doc_name = tmp[1].downcase
47
+ end
48
+ s += "\t\t\t<a href=\"./../#{up_link_doc_name}/#{up_link_doc_name}.html##{lnk}\" \
49
+ class=\"external\" title=\"Linked to\">#{lnk}</a>\n<br>"
55
50
  end
51
+ s += '</div>'
52
+ s += "</td>\n"
53
+ end
54
+ else
55
+ s += "\t\t<td class=\"item_id\"></td>\n"
56
+ end
56
57
 
57
- if @down_links
58
- if tmp = /^([a-zA-Z]+)[-]\d+/.match(@down_links[0].id) # guessing that all the links refer to one document
59
- down_link_doc_name = tmp[1].downcase
60
- end
61
- if @down_links.length == 1
62
- s += "\t\t<td class=\"item_id\"><a href=\"./../#{down_link_doc_name}/#{down_link_doc_name}.html##{@down_links[0].id}\" class=\"external\">#{@down_links[0].id}</a></td>\n"
63
- else
64
- s += "\t\t<td class=\"item_id\">"
65
- s += "<div id=\"DL_#{@id}\" style=\"display: block;\">"
66
- s += "<a href=\"#\" onclick=\"downlink_OnClick(this.parentElement); return false;\" class=\"external\">#{@down_links.length}</a>"
67
- s += "</div>"
68
- s += "<div id=\"DLS_#{@id}\" style=\"display: none;\">"
69
- @down_links.each do |lnk|
70
- s += "\t\t\t<a href=\"./../#{lnk.parent_doc.id}/#{lnk.parent_doc.id}.html##{lnk.id}\" class=\"external\">#{lnk.id}</a>\n<br>"
71
- end
72
- s += "</div>"
73
- s += "</td>\n"
74
- end
75
- else
76
- s += "\t\t<td class=\"item_id\"></td>\n"
58
+ if @down_links
59
+ if tmp = /^([a-zA-Z]+)-\d+/.match(@down_links[0].id) # guessing that all the links refer to one document
60
+ down_link_doc_name = tmp[1].downcase
61
+ end
62
+ if @down_links.length == 1
63
+ s += "\t\t<td class=\"item_id\">\
64
+ <a href=\"./../#{down_link_doc_name}/#{down_link_doc_name}.html##{@down_links[0].id}\" \
65
+ class=\"external\" title=\"Referenced in\">#{@down_links[0].id}</a></td>\n"
66
+ else
67
+ s += "\t\t<td class=\"item_id\">"
68
+ s += "<div id=\"DL_#{@id}\" style=\"display: block;\">"
69
+ s += "<a href=\"#\" onclick=\"downlink_OnClick(this.parentElement); return false;\" \
70
+ class=\"external\" title=\"Number of references\">#{@down_links.length}</a>"
71
+ s += '</div>'
72
+ s += "<div id=\"DLS_#{@id}\" style=\"display: none;\">"
73
+ @down_links.each do |lnk|
74
+ s += "\t\t\t<a href=\"./../#{lnk.parent_doc.id}/#{lnk.parent_doc.id}.html##{lnk.id}\" \
75
+ class=\"external\" title=\"Referenced in\">#{lnk.id}</a>\n<br>"
77
76
  end
77
+ s += '</div>'
78
+ s += "</td>\n"
79
+ end
80
+ else
81
+ s += "\t\t<td class=\"item_id\"></td>\n"
82
+ end
78
83
 
79
- if @coverage_links
80
- if tmp = /^(.+)[.]\d+/.match(@coverage_links[0].id) # guessing that all the links refer to one document
81
- cov_link_doc_name = tmp[1].downcase
82
- end
83
- s += "\t\t<td class=\"item_id\"><a href=\"./../../tests/protocols/#{cov_link_doc_name}/#{cov_link_doc_name}.html\" class=\"external\">#{@coverage_links.length}</a></td>\n"
84
- else
85
- s += "\t\t<td class=\"item_id\"></td>\n"
84
+ if @coverage_links
85
+ if tmp = /^(.+)[.]\d+/.match(@coverage_links[0].id) # guessing that all the links refer to one document
86
+ cov_link_doc_name = tmp[1].downcase
87
+ end
88
+ if @coverage_links.length == 1
89
+ s += "\t\t<td class=\"item_id\">\
90
+ <a href=\"./../../tests/protocols/#{cov_link_doc_name}/#{cov_link_doc_name}.html\" \
91
+ class=\"external\" title=\"Number of verification steps\">#{@coverage_links[0].id}</a></td>\n"
92
+ else
93
+ s += "\t\t<td class=\"item_id\">"
94
+ s += "<div id=\"COV_#{@id}\" style=\"display: block;\">"
95
+ s += "<a href=\"#\" onclick=\"coverageLink_OnClick(this.parentElement); return false;\" \
96
+ class=\"external\" title=\"Number of verification steps\">#{@coverage_links.length}</a>"
97
+ s += '</div>'
98
+ s += "<div id=\"COVS_#{@id}\" style=\"display: none;\">"
99
+ @coverage_links.each do |lnk|
100
+ s += "\t\t\t<a href=\"./../../tests/protocols/#{lnk.parent_doc.id}/#{lnk.parent_doc.id}.html##{lnk.id}\" \
101
+ class=\"external\" title=\"Covered in\">#{lnk.id}</a>\n<br>"
86
102
  end
87
- s += "\t</tr>\n"
88
- return s
89
- end
90
-
91
- end
103
+ s += '</div>'
104
+ s += "</td>\n"
105
+ end
106
+ else
107
+ s += "\t\t<td class=\"item_id\"></td>\n"
108
+ end
109
+ s += "\t</tr>\n"
110
+ s
111
+ end
112
+ end
@@ -1,177 +1,224 @@
1
- require_relative "controlled_table_row"
2
- require_relative "text_line"
1
+ require_relative 'controlled_table_row'
2
+ require_relative 'text_line'
3
3
 
4
- class ControlledTableColumn < TextLine
4
+ class ControlledTableColumn < TextLine # rubocop:disable Style/Documentation
5
+ attr_accessor :text
5
6
 
6
- attr_accessor :text
7
-
8
- def initialize(text)
9
- @text = text.strip
10
- end
7
+ def initialize(text) # rubocop:disable Lint/MissingSuper
8
+ @text = text.strip
9
+ end
11
10
 
12
- def to_html
13
- f_text = format_string(@text)
14
- "\t\t<td>#{f_text}</td>\n\r"
15
- end
11
+ def to_html
12
+ f_text = format_string(@text)
13
+ "\t\t<td>#{f_text}</td>\n\r"
14
+ end
16
15
  end
17
16
 
18
-
19
17
  class RegualrColumn < ControlledTableColumn
20
-
21
18
  end
22
19
 
20
+ class TestStepNumberColumn < ControlledTableColumn # rubocop:disable Style/Documentation
21
+ attr_accessor :step_number, :row_id
23
22
 
24
- class TestStepNumberColumn < ControlledTableColumn
23
+ def initialize(text)
24
+ super
25
+ @step_number = text.to_i
26
+ @row_id = ''
27
+ end
25
28
 
26
- attr_accessor :step_number
27
- attr_accessor :row_id
28
-
29
- def initialize(text)
30
- text = text.strip
31
- @step_number = text.to_i
32
- @text = text
33
- @row_id = ""
34
- end
29
+ def to_html
30
+ "\t\t<td style=\"text-align: center;\"><a name=\"#{@row_id}\" id=\"#{@row_id}\" \
31
+ href=\"##{@row_id}\">#{@text}</a></td>\n\r"
32
+ end
33
+ end
35
34
 
36
- def to_html
37
- "\t\t<td style=\"text-align: center;\"><a name=\"#{@row_id}\" id=\"#{@row_id}\" href=\"##{@row_id}\">#{@text}</a></td>\n\r"
35
+ class TestStepResultColumn < ControlledTableColumn # rubocop:disable Style/Documentation
36
+ def to_html
37
+ f_text = format_string(@text)
38
+ case @text.downcase
39
+ when 'pass'
40
+ "\t\t<td style=\"background-color: #cfc;\">#{f_text}</td>\n\r"
41
+ when 'fail'
42
+ "\t\t<td style=\"background-color: #fcc;\">#{f_text}</td>\n\r"
43
+ else
44
+ "\t\t<td>#{f_text}</td>\n\r"
38
45
  end
39
- end
40
-
41
-
42
- class TestStepResultColumn < ControlledTableColumn
46
+ end
47
+ end
43
48
 
44
- def to_html
45
- f_text = format_string(@text)
46
- if @text.downcase == "pass"
47
- "\t\t<td style=\"background-color: #cfc;\">#{f_text}</td>\n\r"
48
- elsif @text.downcase == "fail"
49
- "\t\t<td style=\"background-color: #fcc;\">#{f_text}</td>\n\r"
50
- else
51
- "\t\t<td>#{f_text}</td>\n\r"
52
- end
49
+ class TestStepReferenceColumn < ControlledTableColumn # rubocop:disable Style/Documentation
50
+ attr_accessor :up_link_ids, :up_link_doc_ids, :parent_row
51
+
52
+ def initialize(parent_row, text)
53
+ super(text)
54
+ @up_link_ids = nil
55
+ @up_link_doc_ids = {}
56
+ @parent_row = parent_row
57
+
58
+ up_links = nil
59
+
60
+ # check if it contains the uplink (one or many)
61
+ first_pos = text.length # for trailing commas
62
+ tmp = text.scan(/(>\[(?>[^\[\]]|\g<0>)*\])/) # >[SRS-001], >[SYS-002]
63
+ unless tmp.empty?
64
+ up_links = []
65
+ tmp.each do |ul|
66
+ lnk = ul[0]
67
+ # do not add links for the self document
68
+ doc_id = /([a-zA-Z]+)-\d+/.match(lnk) # SRS
69
+ up_links << lnk.upcase if doc_id # (doc_id) and (doc_id[1].downcase != doc.id.downcase)
70
+ # try to find the real end of text
71
+ pos = text.index(lnk)
72
+ first_pos = pos if pos < first_pos
73
+ # remove uplink from text
74
+ text = text.split(lnk, 1).join('')
75
+ end
76
+ # remove trailing commas and spaces
77
+ if text.length > first_pos
78
+ first_pos -= 1
79
+ text = text[0..first_pos].strip
80
+ end
53
81
  end
54
- end
55
82
 
83
+ if up_links # rubocop:disable Style/GuardClause
84
+ up_links.uniq! # remove duplicates
85
+ # doc.items_with_uplinks_number += 1 # for statistics
86
+ up_links.each do |ul|
87
+ next unless tmp = />\[(\S*)\]$/.match(ul) # >[SRS-001]
56
88
 
57
- class TestStepReferenceColumn < ControlledTableColumn
89
+ up_link_id = tmp[1]
58
90
 
59
- attr_accessor :up_link
60
- attr_accessor :up_link_doc_id
91
+ @up_link_ids ||= []
61
92
 
62
- def initialize(text)
63
-
64
- @up_link = nil
65
- @up_link_doc_id = nil
93
+ @up_link_ids.append(up_link_id)
66
94
 
67
- if tmp = />\[(\S*)\]/.match(text) # >[SRS-001]
68
- @up_link = tmp[1]
69
- if tmp = /^([a-zA-Z]+)[-]\d+/.match(@up_link) # SRS
70
- @up_link_doc_id = tmp[1].downcase
71
- end
95
+ if tmp = /^([a-zA-Z]+)-\d+/.match(up_link_id) # SRS
96
+ @up_link_doc_ids[tmp[1].downcase.to_s] = tmp[1].downcase # multiple documents could be up-linked
72
97
  end
98
+ end
73
99
  end
74
-
75
- def to_html
76
- if @up_link
77
- "\t\t<td class=\"item_id\"><a href=\"./../../../specifications/#{@up_link_doc_id}/#{@up_link_doc_id}.html##{@up_link}\" class=\"external\">#{@up_link}</a></td>\n\r"
78
- else
79
- "\t\t<td style=\"text-align: center;\"></td>\n\r"
100
+ end
101
+
102
+ def to_html # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
103
+ s = ''
104
+ if @up_link_ids
105
+ if @up_link_ids.length == 1
106
+ if tmp = /^([a-zA-Z]+)-\d+/.match(@up_link_ids[0])
107
+ up_link_doc_name = tmp[1].downcase
80
108
  end
109
+ s += "\t\t<td class=\"item_id\" style=\"text-align: center;\">\
110
+ <a href=\"./../../../specifications/#{up_link_doc_name}/#{up_link_doc_name}.html##{@up_link_ids[0]}\" \
111
+ class=\"external\" title=\"Linked to\">#{@up_link_ids[0]}</a></td>\n"
112
+ else
113
+ s += "\t\t<td class=\"item_id\" style=\"text-align: center;\">"
114
+ s += "<div id=\"COV_#{@parent_row.id}\" style=\"display: block;\">"
115
+ s += "<a href=\"#\" onclick=\"coverageLink_OnClick(this.parentElement); return false;\" \
116
+ class=\"external\" title=\"Number of verified items\">#{@up_link_ids.length}</a>"
117
+ s += '</div>'
118
+ s += "<div id=\"COVS_#{@parent_row.id}\" style=\"display: none;\">"
119
+ @up_link_ids.each do |lnk|
120
+ if tmp = /^([a-zA-Z]+)-\d+/.match(lnk)
121
+ up_link_doc_name = tmp[1].downcase
122
+ end
123
+ s += "\t\t\t<a href=\"./../../../specifications/#{up_link_doc_name}/#{up_link_doc_name}.html##{lnk}\" \
124
+ class=\"external\" title=\"Verifies\">#{lnk}</a>\n<br>"
125
+ end
126
+ s += '</div>'
127
+ s += "</td>\n"
128
+ end
129
+ else
130
+ "\t\t<td style=\"text-align: center;\"></td>\n\r"
81
131
  end
82
-
132
+ end
83
133
  end
84
134
 
135
+ class ControlledTable < DocItem # rubocop:disable Style/Documentation
136
+ attr_accessor :column_names, :rows, :is_separator_detected
85
137
 
86
- class ControlledTable < DocItem
87
-
88
- attr_accessor :column_names
89
- attr_accessor :rows
138
+ def initialize(doc, markdown_table) # rubocop:disable Lint/MissingSuper
139
+ @parent_doc = doc
140
+ @parent_heading = doc.headings[-1]
90
141
 
91
- def initialize(markdown_table, parent_doc)
92
- @parent_doc = parent_doc
93
- @column_names = markdown_table.column_names
94
- # copy and re-format existing rows
95
- @rows = Array.new
142
+ @column_names = markdown_table.column_names
143
+ @is_separator_detected = markdown_table.is_separator_detected
144
+ # copy and re-format existing rows
145
+ @rows = []
96
146
 
97
- markdown_table.rows.each do |r|
98
- @rows.append(format_columns(r))
99
- end
147
+ markdown_table.rows.each do |r|
148
+ @rows.append(format_columns(r))
100
149
  end
150
+ end
101
151
 
102
- def addRow(row)
152
+ def add_row(row)
153
+ columns = row.split('|')
103
154
 
104
- columns = row.split('|')
155
+ @rows.append(format_columns(columns))
105
156
 
106
- @rows.append(format_columns(columns))
157
+ true
158
+ end
107
159
 
108
- return true
109
- end
160
+ def format_columns(columns) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
161
+ new_row = ControlledTableRow.new
162
+ new_row.parent_doc = @parent_doc
110
163
 
111
- def format_columns(columns)
112
-
113
- new_row = ControlledTableRow.new
114
- new_row.parent_doc = @parent_doc
115
-
116
- columns.each_with_index do | element, index |
117
-
118
- if index == 0 # it is expected that test step id is placed in the first columl
119
-
120
- col = TestStepNumberColumn.new element
121
- new_row.columns.append col
122
- new_row.id = @parent_doc.id + '.' + col.text
123
- col.row_id = new_row.id
124
-
125
- elsif index + 1 == columns.length # it is expected that a link is placed to the last column only
126
-
127
- col = TestStepReferenceColumn.new element
128
- new_row.columns.append col
129
- # save uplink key but do not rewrite
130
- if col.up_link_doc_id != nil
131
-
132
- @parent_doc.up_link_docs[ col.up_link_doc_id.to_s ] = col.up_link_doc_id
133
-
134
- # save reference to the test step
135
- new_row.up_link = col.up_link
136
- @parent_doc.controlled_items.append new_row
137
- end
138
-
139
- elsif index + 2 == columns.length # it is expected that test step result is placed to the pre-last column only
140
-
141
- col = TestStepResultColumn.new element
142
- new_row.columns.append col
143
-
144
- else
145
- col = RegualrColumn.new element
146
- new_row.columns.append col
147
- end
148
- end
149
- return new_row
150
- end
164
+ columns.each_with_index do |element, index|
165
+ if index.zero? # it is expected that test step id is placed in the first columl
151
166
 
152
- def to_html
153
- s = ''
154
- if @@htmlTableRenderInProgress
155
- s += "</table>\n"
156
- @@htmlTableRenderInProgress = false
157
- end
158
-
159
- s += "<table class=\"markdown_table\">\n"
160
- s += "\t<thead>"
167
+ col = TestStepNumberColumn.new element
168
+ new_row.columns.append col
169
+ new_row.id = "#{@parent_doc.id}.#{col.text}"
170
+ col.row_id = new_row.id
161
171
 
162
- @column_names.each do |h|
163
- s += " <th>#{h}</th>"
164
- end
172
+ elsif index + 1 == columns.length # it is expected that a link is placed to the last column only
165
173
 
166
- s += " </thead>\n"
174
+ col = TestStepReferenceColumn.new(new_row, element)
175
+ new_row.columns << col
176
+ # save uplink key but do not rewrite
177
+ unless col.up_link_doc_ids.empty?
178
+ col.up_link_doc_ids.each do |key, value|
179
+ @parent_doc.up_link_docs[key] = value
167
180
 
168
- @rows.each do |row|
169
- s += row.to_html
181
+ # save reference to the test step
182
+ new_row.up_link_ids = col.up_link_ids
183
+ @parent_doc.controlled_items.append new_row
184
+ end
170
185
  end
171
186
 
172
- s += "</table>\n"
187
+ elsif index + 2 == columns.length # it is expected that test step result is placed to the pre-last column only
188
+
189
+ col = TestStepResultColumn.new element
190
+ new_row.columns.append col
191
+
192
+ else
193
+ col = RegualrColumn.new element
194
+ new_row.columns.append col
195
+ end
196
+ end
197
+ new_row
198
+ end
199
+
200
+ def to_html # rubocop:disable Metrics/MethodLength
201
+ s = ''
202
+ if @@html_table_render_in_progress
203
+ s += "</table>\n"
204
+ @@html_table_render_in_progress = false # rubocop:disable Style/ClassVars
205
+ end
206
+
207
+ s += "<table class=\"markdown_table\">\n"
208
+ s += "\t<thead>"
173
209
 
174
- return s
210
+ @column_names.each do |h|
211
+ s += " <th>#{h}</th>"
175
212
  end
176
213
 
177
- end
214
+ s += " </thead>\n"
215
+
216
+ @rows.each do |row|
217
+ s += row.to_html
218
+ end
219
+
220
+ s += "</table>\n"
221
+
222
+ s
223
+ end
224
+ end
@@ -3,13 +3,13 @@ require_relative "doc_item"
3
3
  class ControlledTableRow < DocItem
4
4
 
5
5
  attr_accessor :id
6
- attr_accessor :up_link
6
+ attr_accessor :up_link_ids
7
7
  attr_accessor :columns
8
8
 
9
9
  def initialize
10
10
  @id = ""
11
- @up_link = ""
12
- @columns = Array.new
11
+ @up_link_ids = nil
12
+ @columns = []
13
13
  end
14
14
 
15
15
  def to_html