Almirah 0.2.5 → 0.2.7

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 +97 -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 +379 -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,61 +1,97 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'doc_item'
4
-
5
- class MarkdownTable < DocItem
6
- attr_accessor :column_names, :rows, :heading_row, :is_separator_detected
7
-
8
- def initialize(doc, heading_row)
9
- super(doc)
10
- @heading_row = heading_row
11
-
12
- res = /^[|](.*[|])/.match(heading_row)
13
- @column_names = if res
14
- res[1].split('|')
15
- else
16
- ['# ERROR# ']
17
- end
18
- @rows = []
19
- @is_separator_detected = false
20
- end
21
-
22
- def add_row(row)
23
- columns = row.split('|')
24
- @rows.append(columns.map!(&:strip))
25
- true
26
- end
27
-
28
- def to_html
29
- s = ''
30
- if @@html_table_render_in_progress
31
- s += "</table>\n"
32
- @@html_table_render_in_progress = false
33
- end
34
-
35
- s += "<table class=\"markdown_table\">\n"
36
- s += "\t<thead>"
37
-
38
- @column_names.each do |h|
39
- s += " <th>#{h}</th>"
40
- end
41
-
42
- s += " </thead>\n"
43
-
44
- @rows.each do |row|
45
- s += "\t<tr>\n"
46
- row.each do |col|
47
- if col.to_i.positive? && col.to_i.to_s == col # autoalign cells with numbers
48
- s += "\t\t<td style=\"text-align: center;\">#{col}</td>\n"
49
- else
50
- f_text = format_string(col)
51
- s += "\t\t<td>#{f_text}</td>\n"
52
- end
53
- end
54
- s += "\t</tr>\n"
55
- end
56
-
57
- s += "</table>\n"
58
-
59
- s
60
- end
61
- end
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'doc_item'
4
+
5
+ class MarkdownTable < DocItem
6
+ attr_accessor :column_names, :rows, :heading_row, :is_separator_detected, :column_aligns
7
+
8
+ def initialize(doc, heading_row)
9
+ super(doc)
10
+ @heading_row = heading_row
11
+
12
+ res = /^[|](.*[|])/.match(heading_row)
13
+ @column_names = if res
14
+ res[1].split('|')
15
+ else
16
+ ['# ERROR# ']
17
+ end
18
+ @rows = []
19
+ @is_separator_detected = false
20
+ @column_aligns = []
21
+ end
22
+
23
+ def add_separator(line)
24
+ res = /^[|](.*[|])/.match(line)
25
+ columns = if res
26
+ res[1].split('|')
27
+ else
28
+ ['# ERROR# ']
29
+ end
30
+
31
+ columns.each do |c|
32
+ res = /(:?)(-{3,})(:?)/.match(c)
33
+ @column_aligns << if res.length == 4
34
+ if (res[1] != '') && (res[2] != '') && (res[3] != '')
35
+ 'center'
36
+ elsif (res[1] != '') && (res[2] != '') && (res[3] == '')
37
+ 'left'
38
+ elsif (res[1] == '') && (res[2] != '') && (res[3] != '')
39
+ 'right'
40
+ else
41
+ 'default'
42
+ end
43
+ else
44
+ 'default'
45
+ end
46
+ end
47
+ end
48
+
49
+ def add_row(row)
50
+ columns = row.split('|')
51
+ @rows.append(columns.map!(&:strip))
52
+ true
53
+ end
54
+
55
+ def to_html
56
+ s = ''
57
+ if @@html_table_render_in_progress
58
+ s += "</table>\n"
59
+ @@html_table_render_in_progress = false
60
+ end
61
+
62
+ s += "<table class=\"markdown_table\">\n"
63
+ s += "\t<thead>"
64
+
65
+ @column_names.each do |h|
66
+ s += " <th>#{h}</th>"
67
+ end
68
+
69
+ s += " </thead>\n"
70
+
71
+ @rows.each do |row|
72
+ s += "\t<tr>\n"
73
+ row.each_with_index do |col, index|
74
+ if col.to_i.positive? && col.to_i.to_s == col # autoalign cells with numbers
75
+ s += "\t\t<td style=\"text-align: center;\">#{col}</td>\n"
76
+ else
77
+ align = ''
78
+ case @column_aligns[index]
79
+ when 'left'
80
+ align = 'style="text-align: left;"'
81
+ when 'right'
82
+ align = 'style="text-align: right;"'
83
+ when 'center'
84
+ align = 'style="text-align: center;"'
85
+ end
86
+ f_text = format_string(col)
87
+ s += "\t\t<td #{align}>#{f_text}</td>\n"
88
+ end
89
+ end
90
+ s += "\t</tr>\n"
91
+ end
92
+
93
+ s += "</table>\n"
94
+
95
+ s
96
+ end
97
+ end
@@ -1,25 +1,25 @@
1
- require_relative 'doc_item'
2
-
3
- class Paragraph < DocItem
4
- attr_accessor :text
5
-
6
- def initialize(doc, text)
7
- super(doc)
8
- @text = text.strip
9
- end
10
-
11
- def getTextWithoutSpaces
12
- @text.split.join('-').downcase
13
- end
14
-
15
- def to_html
16
- s = ''
17
- if @@html_table_render_in_progress
18
- s += '</table>'
19
- @@html_table_render_in_progress = false
20
- end
21
-
22
- s += "<p>#{format_string(@text)}"
23
- s
24
- end
25
- end
1
+ require_relative 'doc_item'
2
+
3
+ class Paragraph < DocItem
4
+ attr_accessor :text
5
+
6
+ def initialize(doc, text)
7
+ super(doc)
8
+ @text = text.strip
9
+ end
10
+
11
+ def getTextWithoutSpaces
12
+ @text.split.join('-').downcase
13
+ end
14
+
15
+ def to_html
16
+ s = ''
17
+ if @@html_table_render_in_progress
18
+ s += '</table>'
19
+ @@html_table_render_in_progress = false
20
+ end
21
+
22
+ s += "<p>#{format_string(@text)}"
23
+ s
24
+ end
25
+ end