Almirah 0.2.4 → 0.2.6

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.
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 -20
  11. data/lib/almirah/doc_items/frontmatter.rb +9 -0
  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 -158
  15. data/lib/almirah/doc_items/markdown_table.rb +61 -63
  16. data/lib/almirah/doc_items/paragraph.rb +25 -27
  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 -330
  20. data/lib/almirah/doc_types/base_document.rb +64 -70
  21. data/lib/almirah/doc_types/coverage.rb +95 -81
  22. data/lib/almirah/doc_types/index.rb +173 -169
  23. data/lib/almirah/doc_types/persistent_document.rb +17 -20
  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 -72
  29. data/lib/almirah/navigation_pane.rb +16 -16
  30. data/lib/almirah/project.rb +287 -306
  31. data/lib/almirah/project_configuration.rb +41 -41
  32. data/lib/almirah/project_template.rb +298 -0
  33. data/lib/almirah/project_utility.rb +52 -0
  34. data/lib/almirah/search/specifications_db.rb +79 -83
  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 -49
  41. metadata +28 -5
@@ -1,70 +1,64 @@
1
-
2
- class BaseDocument
3
-
4
- attr_accessor :title
5
- attr_accessor :id
6
- attr_accessor :dom
7
- attr_accessor :headings
8
-
9
- def initialize()
10
- @items = Array.new
11
- @headings = Array.new
12
- @title = ""
13
- @id = ""
14
- @dom = nil
15
- end
16
-
17
- def save_html_to_file html_rows, nav_pane, output_file_path
18
-
19
- gem_root = File.expand_path './../../..', File.dirname(__FILE__)
20
- template_file = gem_root + "/lib/almirah/templates/page.html"
21
-
22
- file = File.open( template_file )
23
- file_data = file.readlines
24
- file.close
25
-
26
- if @id == 'index'
27
- output_file_path += "#{@id}.html"
28
- else
29
- output_file_path += "#{@id}/#{@id}.html"
30
- end
31
- file = File.open( output_file_path, "w" )
32
- file_data.each do |s|
33
- if s.include?('{{CONTENT}}')
34
- html_rows.each do |r|
35
- file.puts r
36
- end
37
- elsif s.include?('{{NAV_PANE}}')
38
- if nav_pane
39
- file.puts nav_pane.to_html
40
- end
41
- elsif s.include?('{{DOCUMENT_TITLE}}')
42
- file.puts s.gsub! '{{DOCUMENT_TITLE}}', @title
43
- elsif s.include?('{{STYLES_AND_SCRIPTS}}')
44
- if @id == 'index'
45
- file.puts '<script type="module" src="./scripts/orama_search.js"></script>'
46
- file.puts '<link rel="stylesheet" href="./css/search.css">'
47
- file.puts '<link rel="stylesheet" href="./css/main.css">'
48
- file.puts '<script src="./scripts/main.js"></script>'
49
- elsif self.instance_of? Specification
50
- file.puts '<link rel="stylesheet" href="../../css/main.css">'
51
- file.puts '<script src="../../scripts/main.js"></script>'
52
- elsif self.instance_of? Traceability
53
- file.puts '<link rel="stylesheet" href="../../css/main.css">'
54
- file.puts '<script src="../../scripts/main.js"></script>'
55
- elsif self.instance_of? Coverage
56
- file.puts '<link rel="stylesheet" href="../../css/main.css">'
57
- file.puts '<script src="../../scripts/main.js"></script>'
58
- elsif self.instance_of? Protocol
59
- file.puts '<link rel="stylesheet" href="../../../css/main.css">'
60
- file.puts '<script src="../../../scripts/main.js"></script>'
61
- end
62
- elsif s.include?('{{GEM_VERSION}}')
63
- file.puts "(" + Gem.loaded_specs['Almirah'].version.version + ")"
64
- else
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
- require_relative "base_document"
2
-
3
- class Coverage < BaseDocument
4
-
5
- attr_accessor :top_doc
6
- attr_accessor :bottom_doc
7
- attr_accessor :covered_items
8
-
9
- def initialize(top_doc)
10
- super()
11
- @top_doc = top_doc
12
- @bottom_doc = nil
13
-
14
- @id = top_doc.id + "-" + "tests"
15
- @title = "Coverage Matrix: " + @id
16
- @covered_items = {}
17
- end
18
-
19
- def to_console
20
- puts "\e[35m" + "Traceability: " + @id + "\e[0m"
21
- end
22
-
23
- def to_html(nav_pane, output_file_path)
24
-
25
- html_rows = Array.new
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> <th>#</th> <th style='font-weight: bold;'>Test CaseId.StepId</th> </thead>\n"
31
- html_rows.append s
32
-
33
- sorted_items = @top_doc.controlled_items.sort_by { |w| w.id }
34
-
35
- sorted_items.each do |top_item|
36
- row = render_table_row top_item
37
- html_rows.append row
38
- end
39
- html_rows.append "</table>\n"
40
-
41
- self.save_html_to_file(html_rows, nav_pane, output_file_path)
42
-
43
- end
44
-
45
- def render_table_row(top_item)
46
- s = ""
47
- if top_item.coverage_links
48
- if top_item.coverage_links.length > 1
49
- id_color = "" # "style='background-color: #fff8c5;'" # disabled for now
50
- else
51
- id_color = ""
52
- end
53
- top_item.coverage_links.each do |bottom_item|
54
- s += "\t<tr>\n"
55
- 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"
56
- s += "\t\t<td class=\"item_text\" style='width: 42%;'>#{top_item.text}</td>\n"
57
-
58
- if bottom_item.columns[-2].text.downcase == "pass"
59
- test_step_color = "style='background-color: #cfc;'"
60
- elsif bottom_item.columns[-2].text.downcase == "fail"
61
- test_step_color = "style='background-color: #fcc;'"
62
- else
63
- test_step_color = ""
64
- end
65
-
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"
67
- s += "\t\t<td class=\"item_text\" style='width: 42%;'>#{bottom_item.columns[1].text}</td>\n"
68
- s += "\t</tr>\n"
69
- @covered_items[top_item.id.to_s.downcase] = top_item
70
- end
71
- else
72
- s += "\t<tr>\n"
73
- 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"
74
- s += "\t\t<td class=\"item_text\" style='width: 42%;'>#{top_item.text}</td>\n"
75
- s += "\t\t<td class=\"item_id\"></td>\n"
76
- s += "\t\t<td class=\"item_text\" style='width: 42%;'></td>\n"
77
- s += "\t</tr>\n"
78
- end
79
- return s
80
- end
81
- 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