Almirah 0.2.4 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/almirah +4 -4
- data/lib/almirah/doc_fabric.rb +65 -65
- data/lib/almirah/doc_items/blockquote.rb +21 -21
- data/lib/almirah/doc_items/code_block.rb +26 -26
- data/lib/almirah/doc_items/controlled_paragraph.rb +112 -112
- data/lib/almirah/doc_items/controlled_table.rb +224 -224
- data/lib/almirah/doc_items/controlled_table_row.rb +22 -22
- data/lib/almirah/doc_items/doc_footer.rb +16 -16
- data/lib/almirah/doc_items/doc_item.rb +22 -20
- data/lib/almirah/doc_items/frontmatter.rb +9 -0
- data/lib/almirah/doc_items/heading.rb +93 -93
- data/lib/almirah/doc_items/image.rb +27 -27
- data/lib/almirah/doc_items/markdown_list.rb +156 -158
- data/lib/almirah/doc_items/markdown_table.rb +61 -63
- data/lib/almirah/doc_items/paragraph.rb +25 -27
- data/lib/almirah/doc_items/text_line.rb +296 -296
- data/lib/almirah/doc_items/todo_block.rb +21 -21
- data/lib/almirah/doc_parser.rb +378 -330
- data/lib/almirah/doc_types/base_document.rb +64 -70
- data/lib/almirah/doc_types/coverage.rb +95 -81
- data/lib/almirah/doc_types/index.rb +173 -169
- data/lib/almirah/doc_types/persistent_document.rb +17 -20
- data/lib/almirah/doc_types/protocol.rb +24 -24
- data/lib/almirah/doc_types/specification.rb +67 -67
- data/lib/almirah/doc_types/traceability.rb +142 -142
- data/lib/almirah/dom/doc_section.rb +25 -25
- data/lib/almirah/dom/document.rb +78 -72
- data/lib/almirah/navigation_pane.rb +16 -16
- data/lib/almirah/project.rb +287 -306
- data/lib/almirah/project_configuration.rb +41 -41
- data/lib/almirah/project_template.rb +298 -0
- data/lib/almirah/project_utility.rb +52 -0
- data/lib/almirah/search/specifications_db.rb +79 -83
- data/lib/almirah/templates/css/main.css +300 -300
- data/lib/almirah/templates/css/search.css +40 -40
- data/lib/almirah/templates/page.html +42 -42
- data/lib/almirah/templates/scripts/main.js +111 -111
- data/lib/almirah/templates/scripts/orama_search.js +138 -138
- data/lib/almirah.rb +93 -49
- metadata +28 -5
@@ -1,70 +1,64 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
file.puts s
|
66
|
-
end
|
67
|
-
end
|
68
|
-
file.close
|
69
|
-
end
|
70
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class BaseDocument # rubocop:disable Style/Documentation
|
4
|
+
attr_accessor :title, :id, :dom, :headings
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@items = []
|
8
|
+
@headings = []
|
9
|
+
@title = ''
|
10
|
+
@id = ''
|
11
|
+
@dom = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def save_html_to_file(html_rows, nav_pane, output_file_path) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
15
|
+
gem_root = File.expand_path './../../..', File.dirname(__FILE__)
|
16
|
+
template_file = "#{gem_root}/lib/almirah/templates/page.html"
|
17
|
+
|
18
|
+
file = File.open(template_file)
|
19
|
+
file_data = file.readlines
|
20
|
+
file.close
|
21
|
+
|
22
|
+
output_file_path += if @id == 'index'
|
23
|
+
"#{@id}.html"
|
24
|
+
else
|
25
|
+
"#{@id}/#{@id}.html"
|
26
|
+
end
|
27
|
+
file = File.open(output_file_path, 'w')
|
28
|
+
file_data.each do |s| # rubocop:disable Metrics/BlockLength
|
29
|
+
if s.include?('{{CONTENT}}')
|
30
|
+
html_rows.each do |r|
|
31
|
+
file.puts r
|
32
|
+
end
|
33
|
+
elsif s.include?('{{NAV_PANE}}')
|
34
|
+
file.puts nav_pane.to_html if nav_pane
|
35
|
+
elsif s.include?('{{DOCUMENT_TITLE}}')
|
36
|
+
file.puts s.gsub! '{{DOCUMENT_TITLE}}', @title
|
37
|
+
elsif s.include?('{{STYLES_AND_SCRIPTS}}')
|
38
|
+
if @id == 'index'
|
39
|
+
file.puts '<script type="module" src="./scripts/orama_search.js"></script>'
|
40
|
+
file.puts '<link rel="stylesheet" href="./css/search.css">'
|
41
|
+
file.puts '<link rel="stylesheet" href="./css/main.css">'
|
42
|
+
file.puts '<script src="./scripts/main.js"></script>'
|
43
|
+
elsif instance_of? Specification
|
44
|
+
file.puts '<link rel="stylesheet" href="../../css/main.css">'
|
45
|
+
file.puts '<script src="../../scripts/main.js"></script>'
|
46
|
+
elsif instance_of? Traceability
|
47
|
+
file.puts '<link rel="stylesheet" href="../../css/main.css">'
|
48
|
+
file.puts '<script src="../../scripts/main.js"></script>'
|
49
|
+
elsif instance_of? Coverage
|
50
|
+
file.puts '<link rel="stylesheet" href="../../css/main.css">'
|
51
|
+
file.puts '<script src="../../scripts/main.js"></script>'
|
52
|
+
elsif instance_of? Protocol
|
53
|
+
file.puts '<link rel="stylesheet" href="../../../css/main.css">'
|
54
|
+
file.puts '<script src="../../../scripts/main.js"></script>'
|
55
|
+
end
|
56
|
+
elsif s.include?('{{GEM_VERSION}}')
|
57
|
+
file.puts "(#{Gem.loaded_specs['Almirah'].version.version})"
|
58
|
+
else
|
59
|
+
file.puts s
|
60
|
+
end
|
61
|
+
end
|
62
|
+
file.close
|
63
|
+
end
|
64
|
+
end
|
@@ -1,81 +1,95 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base_document'
|
4
|
+
|
5
|
+
class Coverage < BaseDocument # rubocop:disable Style/Documentation
|
6
|
+
attr_accessor :top_doc, :bottom_doc, :covered_items, :passed_steps_number, :failed_steps_number
|
7
|
+
|
8
|
+
def initialize(top_doc)
|
9
|
+
super()
|
10
|
+
@top_doc = top_doc
|
11
|
+
@bottom_doc = nil
|
12
|
+
|
13
|
+
@id = "#{top_doc.id}-tests"
|
14
|
+
@title = "Coverage Matrix: #{@id}"
|
15
|
+
@covered_items = {}
|
16
|
+
@passed_steps_number = 0
|
17
|
+
@failed_steps_number = 0
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_console
|
21
|
+
puts "\e[35mTraceability: #{@id}\e[0m"
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_html(nav_pane, output_file_path) # rubocop:disable Metrics/MethodLength
|
25
|
+
html_rows = []
|
26
|
+
|
27
|
+
html_rows.append('')
|
28
|
+
s = "<h1>#{@title}</h1>\n"
|
29
|
+
s += "<table class=\"controlled\">\n"
|
30
|
+
s += "\t<thead> <th>#</th> <th style='font-weight: bold;'>#{@top_doc.title}</th> "
|
31
|
+
s += "<th title='TestCaseId.TestStepId'>#</th> <th style='font-weight: bold;'>Test Step Description</th> "
|
32
|
+
s += "<th style='font-weight: bold;'>Result</th> </thead>\n"
|
33
|
+
html_rows.append s
|
34
|
+
|
35
|
+
sorted_items = @top_doc.controlled_items.sort_by(&:id)
|
36
|
+
|
37
|
+
sorted_items.each do |top_item|
|
38
|
+
row = render_table_row top_item
|
39
|
+
html_rows.append row
|
40
|
+
end
|
41
|
+
html_rows.append "</table>\n"
|
42
|
+
|
43
|
+
save_html_to_file(html_rows, nav_pane, output_file_path)
|
44
|
+
end
|
45
|
+
|
46
|
+
def render_table_row(top_item) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
47
|
+
s = ''
|
48
|
+
if top_item.coverage_links
|
49
|
+
id_color = if top_item.coverage_links.length > 1
|
50
|
+
'' # "style='background-color: #fff8c5;'" # disabled for now
|
51
|
+
else
|
52
|
+
''
|
53
|
+
end
|
54
|
+
top_item.coverage_links.each do |bottom_item|
|
55
|
+
s += "\t<tr>\n"
|
56
|
+
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"
|
57
|
+
s += "\t\t<td class=\"item_text\" style='width: 40%;'>#{top_item.text}</td>\n"
|
58
|
+
|
59
|
+
test_step_color = case bottom_item.columns[-2].text.downcase
|
60
|
+
when 'pass'
|
61
|
+
@passed_steps_number += 1
|
62
|
+
"style='background-color: #cfc;'"
|
63
|
+
when 'fail'
|
64
|
+
@failed_steps_number += 1
|
65
|
+
"style='background-color: #fcc;'"
|
66
|
+
else
|
67
|
+
"style='background-color: #ffffee;'"
|
68
|
+
end
|
69
|
+
test_step_result = case bottom_item.columns[-2].text.downcase
|
70
|
+
when 'pass'
|
71
|
+
'PASS'
|
72
|
+
when 'fail'
|
73
|
+
'FAIL'
|
74
|
+
else
|
75
|
+
'N/A'
|
76
|
+
end
|
77
|
+
|
78
|
+
s += "\t\t<td class=\"item_id\"><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"
|
79
|
+
s += "\t\t<td class=\"item_text\" style='width: 42%;'>#{bottom_item.columns[1].text}</td>\n"
|
80
|
+
s += "\t\t<td class=\"item_id\" #{test_step_color}>#{test_step_result}</td>\n"
|
81
|
+
s += "\t</tr>\n"
|
82
|
+
@covered_items[top_item.id.to_s.downcase] = top_item
|
83
|
+
end
|
84
|
+
else
|
85
|
+
s += "\t<tr>\n"
|
86
|
+
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"
|
87
|
+
s += "\t\t<td class=\"item_text\" style='width: 40%;'>#{top_item.text}</td>\n"
|
88
|
+
s += "\t\t<td class=\"item_id\"></td>\n"
|
89
|
+
s += "\t\t<td class=\"item_text\" style='width: 42%;'></td>\n"
|
90
|
+
s += "\t\t<td class=\"item_id\"></td>\n"
|
91
|
+
s += "\t</tr>\n"
|
92
|
+
end
|
93
|
+
s
|
94
|
+
end
|
95
|
+
end
|