Almirah 0.2.3 → 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 +4 -4
- data/lib/almirah/doc_fabric.rb +21 -2
- data/lib/almirah/doc_items/controlled_paragraph.rb +100 -79
- data/lib/almirah/doc_items/controlled_table.rb +180 -137
- data/lib/almirah/doc_items/controlled_table_row.rb +3 -3
- data/lib/almirah/doc_items/markdown_list.rb +2 -2
- data/lib/almirah/doc_items/markdown_table.rb +1 -1
- data/lib/almirah/doc_items/paragraph.rb +1 -1
- data/lib/almirah/doc_parser.rb +6 -6
- data/lib/almirah/doc_types/base_document.rb +1 -0
- data/lib/almirah/doc_types/coverage.rb +4 -1
- data/lib/almirah/doc_types/index.rb +9 -1
- data/lib/almirah/doc_types/traceability.rb +6 -2
- data/lib/almirah/dom/doc_section.rb +21 -24
- data/lib/almirah/dom/document.rb +66 -57
- data/lib/almirah/project.rb +257 -275
- data/lib/almirah/templates/page.html +3 -3
- data/lib/almirah/templates/scripts/main.js +34 -0
- metadata +2 -2
data/lib/almirah/doc_parser.rb
CHANGED
@@ -153,10 +153,10 @@ class DocParser
|
|
153
153
|
row = res[2]
|
154
154
|
|
155
155
|
if temp_md_list
|
156
|
-
temp_md_list.
|
156
|
+
temp_md_list.add_row(s)
|
157
157
|
else
|
158
158
|
item = MarkdownList.new(doc, false)
|
159
|
-
item.
|
159
|
+
item.add_row(s)
|
160
160
|
temp_md_list = item
|
161
161
|
end
|
162
162
|
|
@@ -167,10 +167,10 @@ class DocParser
|
|
167
167
|
row = res[1]
|
168
168
|
|
169
169
|
if temp_md_list
|
170
|
-
temp_md_list.
|
170
|
+
temp_md_list.add_row(s)
|
171
171
|
else
|
172
172
|
item = MarkdownList.new(doc, true)
|
173
|
-
item.
|
173
|
+
item.add_row(s)
|
174
174
|
temp_md_list = item
|
175
175
|
end
|
176
176
|
|
@@ -208,7 +208,7 @@ class DocParser
|
|
208
208
|
temp_md_table = ControlledTable.new(doc, temp_md_table)
|
209
209
|
end
|
210
210
|
end
|
211
|
-
temp_md_table.
|
211
|
+
temp_md_table.add_row(row)
|
212
212
|
else
|
213
213
|
# replece table heading with regular paragraph
|
214
214
|
item = Paragraph.new(doc, temp_md_table.heading_row)
|
@@ -279,7 +279,7 @@ class DocParser
|
|
279
279
|
temp_md_table = process_temp_table(doc, temp_md_table)
|
280
280
|
if temp_md_list
|
281
281
|
if MarkdownList.unordered_list_item?(s) || MarkdownList.ordered_list_item?(s)
|
282
|
-
temp_md_list.
|
282
|
+
temp_md_list.add_row(s)
|
283
283
|
next
|
284
284
|
else
|
285
285
|
doc.items.append temp_md_list
|
@@ -4,14 +4,16 @@ class Coverage < BaseDocument
|
|
4
4
|
|
5
5
|
attr_accessor :top_doc
|
6
6
|
attr_accessor :bottom_doc
|
7
|
+
attr_accessor :covered_items
|
7
8
|
|
8
9
|
def initialize(top_doc)
|
9
10
|
super()
|
10
11
|
@top_doc = top_doc
|
11
|
-
@bottom_doc =
|
12
|
+
@bottom_doc = nil
|
12
13
|
|
13
14
|
@id = top_doc.id + "-" + "tests"
|
14
15
|
@title = "Coverage Matrix: " + @id
|
16
|
+
@covered_items = {}
|
15
17
|
end
|
16
18
|
|
17
19
|
def to_console
|
@@ -64,6 +66,7 @@ class Coverage < BaseDocument
|
|
64
66
|
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"
|
65
67
|
s += "\t\t<td class=\"item_text\" style='width: 42%;'>#{bottom_item.columns[1].text}</td>\n"
|
66
68
|
s += "\t</tr>\n"
|
69
|
+
@covered_items[top_item.id.to_s.downcase] = top_item
|
67
70
|
end
|
68
71
|
else
|
69
72
|
s += "\t<tr>\n"
|
@@ -136,6 +136,9 @@ class Index < BaseDocument
|
|
136
136
|
s += "<table class=\"controlled\">\n"
|
137
137
|
s += "\t<thead>\n"
|
138
138
|
s += "\t\t<th>Title</th>\n"
|
139
|
+
s += "\t\t<th title=\"The ratio of Controlled Paragraphs mentioned in test protocols \
|
140
|
+
and total number of Controlled Paragraphs\">Coverage</th>\n"
|
141
|
+
s += "\t\t<th title=\"Numbers of passed and failed test steps\">Test Results</th>\n"
|
139
142
|
s += "\t\t<th>Specification Covered</th>\n"
|
140
143
|
s += "</thead>\n"
|
141
144
|
html_rows.append s
|
@@ -144,8 +147,13 @@ class Index < BaseDocument
|
|
144
147
|
|
145
148
|
sorted_items.each do |doc|
|
146
149
|
s = "\t<tr>\n"
|
150
|
+
coverage = doc.covered_items.length.to_f / doc.top_doc.controlled_items.length * 100.0
|
147
151
|
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"
|
148
|
-
s += "\t\t<td class=\"
|
152
|
+
s += "\t\t<td class=\"item_id\" style='width: 7%;'>#{'%.2f' % coverage}%</td>\n"
|
153
|
+
s += "\t\t<td class=\"item_id\" style='width: 7%;'> n/a </td>\n"
|
154
|
+
s += "\t\t<td class=\"item_text\" style='width: 25%; padding: 5px;'>\
|
155
|
+
<i class=\"fa fa-file-text-o\" style='background-color: ##{doc.top_doc.color};'> </i>\
|
156
|
+
#{doc.top_doc.title}</td>\n"
|
149
157
|
s += "</tr>\n"
|
150
158
|
html_rows.append s
|
151
159
|
end
|
@@ -8,11 +8,15 @@ class Traceability < BaseDocument
|
|
8
8
|
attr_accessor :is_agregated
|
9
9
|
attr_accessor :traced_items
|
10
10
|
|
11
|
-
def initialize(top_doc, bottom_doc
|
11
|
+
def initialize(top_doc, bottom_doc)
|
12
12
|
super()
|
13
13
|
@top_doc = top_doc
|
14
14
|
@bottom_doc = bottom_doc
|
15
|
-
@is_agregated =
|
15
|
+
@is_agregated = if bottom_doc
|
16
|
+
false
|
17
|
+
else
|
18
|
+
true
|
19
|
+
end
|
16
20
|
@traced_items = {}
|
17
21
|
|
18
22
|
if @is_agregated
|
@@ -1,28 +1,25 @@
|
|
1
1
|
class DocSection
|
2
|
+
attr_accessor :sections, :heading, :parent_section
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
4
|
+
def initialize(heading)
|
5
|
+
@sections = []
|
6
|
+
@heading = heading
|
7
|
+
@parent_section = nil
|
8
|
+
end
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
def to_html # rubocop:disable Metrics/MethodLength
|
11
|
+
s = ''
|
12
|
+
s += "\t<li onclick=\"nav_toggle_expand_list(this, event)\">" \
|
13
|
+
'<span class="fa-li"><i class="fa fa-minus-square-o"> </i></span>'
|
14
|
+
s += "<a href=\"##{@heading.anchor_id}\">#{@heading.get_section_info}</a>\n"
|
15
|
+
unless @sections.empty?
|
16
|
+
s += "\t\t<ul class=\"fa-ul\">\n"
|
17
|
+
@sections.each do |sub_section|
|
18
|
+
s += sub_section.to_html
|
19
|
+
end
|
20
|
+
s += "\t\t</ul>\n"
|
11
21
|
end
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
s += "<a href=\"\#" + @heading.anchor_id.to_s + "\">" + @heading.get_section_info + "</a>\n"
|
17
|
-
if @sections.length >0
|
18
|
-
s += "\t\t<ul class=\"fa-ul\">\n"
|
19
|
-
@sections.each do |sub_section|
|
20
|
-
s += sub_section.to_html()
|
21
|
-
end
|
22
|
-
s += "\t\t</ul>\n"
|
23
|
-
end
|
24
|
-
s += "</li>\n"
|
25
|
-
return s
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
22
|
+
s += "</li>\n"
|
23
|
+
s
|
24
|
+
end
|
25
|
+
end
|
data/lib/almirah/dom/document.rb
CHANGED
@@ -1,63 +1,72 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative 'doc_section'
|
2
2
|
|
3
3
|
class Document
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
s = DocSection.new(h)
|
29
|
-
@@sections_stack[-2].sections.append(s)
|
30
|
-
@@sections_stack[-1] = s
|
31
|
-
|
32
|
-
elsif h.level > @@sections_stack[-1].heading.level
|
33
|
-
|
34
|
-
s = DocSection.new(h)
|
35
|
-
@@sections_stack[-1].sections.append(s)
|
36
|
-
@@sections_stack.push s
|
37
|
-
|
38
|
-
else
|
39
|
-
while h.level < @@sections_stack[-1].heading.level
|
40
|
-
@@sections_stack.pop
|
41
|
-
end
|
42
|
-
|
43
|
-
s = DocSection.new(h)
|
44
|
-
@@sections_stack[-2].sections.append(s)
|
45
|
-
@@sections_stack[-1] = s
|
46
|
-
end
|
4
|
+
attr_accessor :root_section
|
5
|
+
|
6
|
+
def initialize(headings_list)
|
7
|
+
@root_section = nil
|
8
|
+
|
9
|
+
build_sections_tree(headings_list)
|
10
|
+
end
|
11
|
+
|
12
|
+
def build_sections_tree(headings_list)
|
13
|
+
sections_stack = []
|
14
|
+
headings_list.each do |h|
|
15
|
+
if @root_section.nil?
|
16
|
+
|
17
|
+
s = DocSection.new(h)
|
18
|
+
s.parent_section = nil
|
19
|
+
@root_section = s
|
20
|
+
sections_stack.push s
|
21
|
+
# one more artificial section copy if root is not a Document Title (level 0)
|
22
|
+
if h.level.positive?
|
23
|
+
a = DocSection.new(h)
|
24
|
+
a.parent_section = @root_section
|
25
|
+
@root_section.sections.append(a)
|
26
|
+
sections_stack.push a
|
47
27
|
end
|
48
|
-
end
|
49
28
|
|
50
|
-
|
51
|
-
|
52
|
-
s
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
29
|
+
elsif sections_stack[-1].heading.level == h.level
|
30
|
+
|
31
|
+
s = DocSection.new(h)
|
32
|
+
s.parent_section = sections_stack[-1].parent_section
|
33
|
+
sections_stack[-1].parent_section.sections.append(s)
|
34
|
+
sections_stack[-1] = s
|
35
|
+
|
36
|
+
elsif h.level > sections_stack[-1].heading.level
|
37
|
+
|
38
|
+
s = DocSection.new(h)
|
39
|
+
s.parent_section = sections_stack[-1]
|
40
|
+
sections_stack[-1].sections.append(s)
|
41
|
+
sections_stack.push s
|
42
|
+
|
43
|
+
else
|
44
|
+
sections_stack.pop while h.level < sections_stack[-1].heading.level
|
45
|
+
sections_stack.push @root_section if sections_stack.empty?
|
46
|
+
s = DocSection.new(h)
|
47
|
+
if h.level == sections_stack[-1].heading.level
|
48
|
+
s.parent_section = sections_stack[-1].parent_section
|
49
|
+
sections_stack[-1].parent_section.sections.append(s)
|
50
|
+
else
|
51
|
+
s.parent_section = sections_stack[-1]
|
52
|
+
sections_stack[-1].sections.append(s)
|
59
53
|
end
|
60
|
-
|
61
|
-
|
54
|
+
sections_stack[-1] = s
|
55
|
+
end
|
62
56
|
end
|
63
|
-
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def section_tree_to_html
|
60
|
+
s = ''
|
61
|
+
s += "<a href=\"##{@root_section.heading.anchor_id}\">#{@root_section.heading.get_section_info}</a>\n"
|
62
|
+
unless @root_section.sections.empty?
|
63
|
+
s += "\t<ul class=\"fa-ul\" style=\"margin-top: 2px;\">\n"
|
64
|
+
@root_section.sections.each do |sub_section|
|
65
|
+
s += sub_section.to_html
|
66
|
+
end
|
67
|
+
s += "\t</ul>\n"
|
68
|
+
end
|
69
|
+
|
70
|
+
s
|
71
|
+
end
|
72
|
+
end
|