Almirah 0.2.3 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34b91589658288fe6c451f14cbb14601ac2c4d083e28b4495aef3f1bb1edcd34
4
- data.tar.gz: 3d834bb51eb285b7acac6b7c44090bab14c40d0d2e64b4743c5867b41375c0ef
3
+ metadata.gz: 71154c27766a7774835e0c6b51d555c859cadb28297f4f66c40e8687dcf53692
4
+ data.tar.gz: 6ec9713d086508afe732073729a8e97e3ac5bb985e43a111f29608d6de87948c
5
5
  SHA512:
6
- metadata.gz: 48e6c007534e2af97110faa435a2596fdd772c2a0acc8cc4980432cdc7c9d99b517f13a9460a05d8d5c0a7d3564ebd53249cffcb571f3087dd9cb3317c5c4093
7
- data.tar.gz: 22ec1eaef53f7cf629ebd607fc321555f759c33b18510ec0787bdea61918636a985d84d7068ce02f6a81803a6dfe17fdd7250fc7ca8cd75a2fb1f4ed47a99981
6
+ metadata.gz: b56be1e40f2ebdafffe0bdac306f98f015e7221f98ee87305cf3e574b19824ef44513f11c8a1912414673b4d7fe582797f9d58dcf49654e701f76bfb0e221dd7
7
+ data.tar.gz: 6a389036b0e41048be97450e7148853adfa192eebf14725cb912c8baebb159f4d0940481e668a5292ad26607ade67742b4edbde7be36dab769b1df6db17fc92a
@@ -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
@@ -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 @@html_table_render_in_progress
23
- s += "<table class=\"controlled\">\n"
24
- s += "\t<thead> <th>#</th> <th></th> <th title=\"Up-links\">UL</th> <th title=\"Down-links\">DL</th> <th title=\"Test Coverage\">COV</th> </thead>\n"
25
- @@html_table_render_in_progress = 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}\" title=\"Paragraph 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\" title=\"Linked to\">#{@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\" title=\"Number of up-links\">#{@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\" title=\"Linked to\">#{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\" title=\"Referenced in\">#{@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\" title=\"Number of references\">#{@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\" title=\"Referenced in\">#{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\" title=\"Number of verification steps\">#{@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,181 +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
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>"
80
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
137
+
138
+ def initialize(doc, markdown_table) # rubocop:disable Lint/MissingSuper
139
+ @parent_doc = doc
140
+ @parent_heading = doc.headings[-1]
85
141
 
86
- class ControlledTable < DocItem
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 = []
87
146
 
88
- attr_accessor :column_names
89
- attr_accessor :rows
90
- attr_accessor :is_separator_detected
147
+ markdown_table.rows.each do |r|
148
+ @rows.append(format_columns(r))
149
+ end
150
+ end
91
151
 
92
- def initialize(doc, markdown_table)
93
- @parent_doc = doc
94
- @parent_heading = doc.headings[-1]
152
+ def add_row(row)
153
+ columns = row.split('|')
95
154
 
96
- @column_names = markdown_table.column_names
97
- @is_separator_detected = markdown_table.is_separator_detected
98
- # copy and re-format existing rows
99
- @rows = Array.new
155
+ @rows.append(format_columns(columns))
100
156
 
101
- markdown_table.rows.each do |r|
102
- @rows.append(format_columns(r))
103
- end
104
- end
157
+ true
158
+ end
105
159
 
106
- def addRow(row)
160
+ def format_columns(columns) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
161
+ new_row = ControlledTableRow.new
162
+ new_row.parent_doc = @parent_doc
107
163
 
108
- columns = row.split('|')
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
109
166
 
110
- @rows.append(format_columns(columns))
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
111
171
 
112
- return true
113
- end
172
+ elsif index + 1 == columns.length # it is expected that a link is placed to the last column only
114
173
 
115
- def format_columns(columns)
116
-
117
- new_row = ControlledTableRow.new
118
- new_row.parent_doc = @parent_doc
119
-
120
- columns.each_with_index do | element, index |
121
-
122
- if index == 0 # it is expected that test step id is placed in the first columl
123
-
124
- col = TestStepNumberColumn.new element
125
- new_row.columns.append col
126
- new_row.id = @parent_doc.id + '.' + col.text
127
- col.row_id = new_row.id
128
-
129
- elsif index + 1 == columns.length # it is expected that a link is placed to the last column only
130
-
131
- col = TestStepReferenceColumn.new element
132
- new_row.columns.append col
133
- # save uplink key but do not rewrite
134
- if col.up_link_doc_id != nil
135
-
136
- @parent_doc.up_link_docs[ col.up_link_doc_id.to_s ] = col.up_link_doc_id
137
-
138
- # save reference to the test step
139
- new_row.up_link = col.up_link
140
- @parent_doc.controlled_items.append new_row
141
- end
142
-
143
- elsif index + 2 == columns.length # it is expected that test step result is placed to the pre-last column only
144
-
145
- col = TestStepResultColumn.new element
146
- new_row.columns.append col
147
-
148
- else
149
- col = RegualrColumn.new element
150
- new_row.columns.append col
151
- end
152
- end
153
- return new_row
154
- end
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
155
180
 
156
- def to_html
157
- s = ''
158
- if @@html_table_render_in_progress
159
- s += "</table>\n"
160
- @@html_table_render_in_progress = false
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
161
185
  end
162
-
163
- s += "<table class=\"markdown_table\">\n"
164
- s += "\t<thead>"
165
186
 
166
- @column_names.each do |h|
167
- s += " <th>#{h}</th>"
168
- end
187
+ elsif index + 2 == columns.length # it is expected that test step result is placed to the pre-last column only
169
188
 
170
- s += " </thead>\n"
189
+ col = TestStepResultColumn.new element
190
+ new_row.columns.append col
171
191
 
172
- @rows.each do |row|
173
- s += row.to_html
174
- end
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
175
206
 
176
- s += "</table>\n"
207
+ s += "<table class=\"markdown_table\">\n"
208
+ s += "\t<thead>"
177
209
 
178
- return s
210
+ @column_names.each do |h|
211
+ s += " <th>#{h}</th>"
179
212
  end
180
213
 
181
- 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