Almirah 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/bin/almirah +4 -4
  3. data/lib/almirah/doc_fabric.rb +65 -65
  4. data/lib/almirah/doc_items/blockquote.rb +21 -21
  5. data/lib/almirah/doc_items/code_block.rb +26 -26
  6. data/lib/almirah/doc_items/controlled_paragraph.rb +112 -112
  7. data/lib/almirah/doc_items/controlled_table.rb +224 -224
  8. data/lib/almirah/doc_items/controlled_table_row.rb +22 -22
  9. data/lib/almirah/doc_items/doc_footer.rb +16 -16
  10. data/lib/almirah/doc_items/doc_item.rb +22 -22
  11. data/lib/almirah/doc_items/frontmatter.rb +9 -9
  12. data/lib/almirah/doc_items/heading.rb +93 -93
  13. data/lib/almirah/doc_items/image.rb +27 -27
  14. data/lib/almirah/doc_items/markdown_list.rb +156 -156
  15. data/lib/almirah/doc_items/markdown_table.rb +61 -61
  16. data/lib/almirah/doc_items/paragraph.rb +25 -25
  17. data/lib/almirah/doc_items/text_line.rb +296 -296
  18. data/lib/almirah/doc_items/todo_block.rb +21 -21
  19. data/lib/almirah/doc_parser.rb +378 -378
  20. data/lib/almirah/doc_types/base_document.rb +64 -64
  21. data/lib/almirah/doc_types/coverage.rb +95 -80
  22. data/lib/almirah/doc_types/index.rb +173 -173
  23. data/lib/almirah/doc_types/persistent_document.rb +17 -17
  24. data/lib/almirah/doc_types/protocol.rb +24 -24
  25. data/lib/almirah/doc_types/specification.rb +67 -67
  26. data/lib/almirah/doc_types/traceability.rb +142 -142
  27. data/lib/almirah/dom/doc_section.rb +25 -25
  28. data/lib/almirah/dom/document.rb +78 -78
  29. data/lib/almirah/navigation_pane.rb +16 -16
  30. data/lib/almirah/project.rb +287 -287
  31. data/lib/almirah/project_configuration.rb +41 -41
  32. data/lib/almirah/project_template.rb +298 -298
  33. data/lib/almirah/project_utility.rb +52 -0
  34. data/lib/almirah/search/specifications_db.rb +79 -79
  35. data/lib/almirah/templates/css/main.css +300 -300
  36. data/lib/almirah/templates/css/search.css +40 -40
  37. data/lib/almirah/templates/page.html +42 -42
  38. data/lib/almirah/templates/scripts/main.js +111 -111
  39. data/lib/almirah/templates/scripts/orama_search.js +138 -138
  40. data/lib/almirah.rb +93 -58
  41. metadata +4 -3
@@ -1,64 +1,64 @@
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
+ # 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,80 +1,95 @@
1
- require_relative 'base_document'
2
-
3
- class Coverage < BaseDocument
4
- attr_accessor :top_doc, :bottom_doc, :covered_items, :passed_steps_number, :failed_steps_number
5
-
6
- def initialize(top_doc)
7
- super()
8
- @top_doc = top_doc
9
- @bottom_doc = nil
10
-
11
- @id = top_doc.id + '-' + 'tests'
12
- @title = 'Coverage Matrix: ' + @id
13
- @covered_items = {}
14
- @passed_steps_number = 0
15
- @failed_steps_number = 0
16
- end
17
-
18
- def to_console
19
- puts "\e[35m" + 'Traceability: ' + @id + "\e[0m"
20
- end
21
-
22
- def to_html(nav_pane, output_file_path)
23
- html_rows = []
24
-
25
- html_rows.append('')
26
- s = "<h1>#{@title}</h1>\n"
27
- s += "<table class=\"controlled\">\n"
28
- s += "\t<thead> <th>#</th> <th style='font-weight: bold;'>#{@top_doc.title}</th> <th>#</th> <th style='font-weight: bold;'>Test CaseId.StepId</th> </thead>\n"
29
- html_rows.append s
30
-
31
- sorted_items = @top_doc.controlled_items.sort_by { |w| w.id }
32
-
33
- sorted_items.each do |top_item|
34
- row = render_table_row top_item
35
- html_rows.append row
36
- end
37
- html_rows.append "</table>\n"
38
-
39
- save_html_to_file(html_rows, nav_pane, output_file_path)
40
- end
41
-
42
- def render_table_row(top_item)
43
- s = ''
44
- if top_item.coverage_links
45
- id_color = if top_item.coverage_links.length > 1
46
- '' # "style='background-color: #fff8c5;'" # disabled for now
47
- else
48
- ''
49
- end
50
- top_item.coverage_links.each do |bottom_item|
51
- s += "\t<tr>\n"
52
- 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"
53
- s += "\t\t<td class=\"item_text\" style='width: 42%;'>#{top_item.text}</td>\n"
54
-
55
- test_step_color = if bottom_item.columns[-2].text.downcase == 'pass'
56
- @passed_steps_number += 1
57
- "style='background-color: #cfc;'"
58
- elsif bottom_item.columns[-2].text.downcase == 'fail'
59
- @failed_steps_number += 1
60
- "style='background-color: #fcc;'"
61
- else
62
- ''
63
- end
64
-
65
- 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"
66
- s += "\t\t<td class=\"item_text\" style='width: 42%;'>#{bottom_item.columns[1].text}</td>\n"
67
- s += "\t</tr>\n"
68
- @covered_items[top_item.id.to_s.downcase] = top_item
69
- end
70
- else
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: 42%;'>#{top_item.text}</td>\n"
74
- s += "\t\t<td class=\"item_id\"></td>\n"
75
- s += "\t\t<td class=\"item_text\" style='width: 42%;'></td>\n"
76
- s += "\t</tr>\n"
77
- end
78
- s
79
- end
80
- end
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