Almirah 0.1.3 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48020d93e573f2cf9f630bc92e1b74f0f64fcdf3fe74986ab1f833437bb13aed
4
- data.tar.gz: e38751efb3beaa7abc28c9eb58d0b604c0dc658a22e25498b39e27001e5c163c
3
+ metadata.gz: 99a9591235fc0f0e1820c572da3c24a1365e93ff7f32a78ceda1083e982f9ad3
4
+ data.tar.gz: 95a400de1b4ad0c471d1fbbc1ee68339618127ac18d9cb5e9429dc36bda2d252
5
5
  SHA512:
6
- metadata.gz: 1cf68af758e43a86e79215b9017084246713b3a72b189a154e609a7f8da1709d7fe30de638493d52668349ed4a49e07977e53b6534f4a6fd92ba3ad8d484c4ac
7
- data.tar.gz: 4eed1d68e546d5cb6ef70e7b6f6e2cb2217a22b6c6ba1356108cc341456889e3d857b50551a1398c53fe5d54eb1f27674a17955f60e7606b7fa4003b2eee12f0
6
+ metadata.gz: f77bcf2b93586fe371b48b863d27604390c22180666441cc8bc7329d2e87d361ce33d08da873b410245d77cabbc0784c285fad17946838fbd9f4d30d1ca34da2
7
+ data.tar.gz: 5f227475da116c2b5d13a023d3d1cb4476a49a862392819a854ac35e4d0624af20f7abe8730fa092177fa733259953bf1ab410dc96ba3f37d1e635955b4b0647
@@ -8,12 +8,14 @@ require_relative "doc_items/doc_item"
8
8
  require_relative "doc_items/heading"
9
9
  require_relative "doc_items/paragraph"
10
10
  require_relative "doc_items/blockquote"
11
+ require_relative "doc_items/code_block"
11
12
  require_relative "doc_items/todo_block"
12
13
  require_relative "doc_items/controlled_paragraph"
13
14
  require_relative "doc_items/markdown_table"
14
15
  require_relative "doc_items/controlled_table"
15
16
  require_relative "doc_items/image"
16
17
  require_relative "doc_items/markdown_list"
18
+ require_relative "doc_items/doc_footer"
17
19
 
18
20
  class DocFabric
19
21
 
@@ -39,6 +41,7 @@ class DocFabric
39
41
 
40
42
  tempMdTable = nil
41
43
  tempMdList = nil
44
+ tempCodeBlock = nil
42
45
 
43
46
  file = File.open( doc.path )
44
47
  file_lines = file.readlines
@@ -186,7 +189,7 @@ class DocFabric
186
189
 
187
190
  doc.items.append(item)
188
191
 
189
- elsif res = /^(\*\s?)(.*)/.match(s) #check if unordered list start
192
+ elsif res = /^(\*\s+)(.*)/.match(s) #check if unordered list start
190
193
 
191
194
  if tempMdTable
192
195
  doc.items.append tempMdTable
@@ -272,6 +275,32 @@ class DocFabric
272
275
  item = Blockquote.new(res[1])
273
276
  item.parent_doc = doc
274
277
  doc.items.append(item)
278
+
279
+ elsif res = /^```(\w*)/.match(s) #check if code block
280
+
281
+ if tempMdTable
282
+ doc.items.append tempMdTable
283
+ tempMdTable = nil
284
+ end
285
+ if tempMdList
286
+ doc.items.append tempMdList
287
+ tempMdList = nil
288
+ end
289
+
290
+ suggested_format = ""
291
+ if res.length == 2
292
+ suggested_format = res[1]
293
+ end
294
+
295
+ if tempCodeBlock
296
+ # close already opened block
297
+ doc.items.append(tempCodeBlock)
298
+ tempCodeBlock = nil
299
+ else
300
+ #start code block
301
+ tempCodeBlock = CodeBlock.new(suggested_format)
302
+ tempCodeBlock.parent_doc = doc
303
+ end
275
304
 
276
305
  elsif res = /^TODO\:(.*)/.match(s) #check if TODO block
277
306
 
@@ -305,10 +334,13 @@ class DocFabric
305
334
  tempMdList = nil
306
335
  end
307
336
  end
308
-
309
- item = Paragraph.new(s)
310
- item.parent_doc = doc
311
- doc.items.append(item)
337
+ if tempCodeBlock
338
+ tempCodeBlock.code_lines.append(s)
339
+ else
340
+ item = Paragraph.new(s)
341
+ item.parent_doc = doc
342
+ doc.items.append(item)
343
+ end
312
344
  end
313
345
  else
314
346
  if tempMdList # lists are separated by emty line from each other
@@ -326,5 +358,13 @@ class DocFabric
326
358
  doc.items.append tempMdList
327
359
  tempMdList = nil
328
360
  end
361
+ if tempCodeBlock
362
+ doc.items.append tempCodeBlock
363
+ tempCodeBlock = nil
364
+ end
365
+ # Add footer to close opened tables if any
366
+ item = DocFooter.new
367
+ item.parent_doc = doc
368
+ doc.items.append(item)
329
369
  end
330
370
  end
@@ -0,0 +1,27 @@
1
+ require_relative "doc_item"
2
+
3
+ class CodeBlock < DocItem
4
+
5
+ attr_accessor :suggested_format
6
+ attr_accessor :code_lines
7
+
8
+ def initialize(suggested_format)
9
+ @suggested_format = suggested_format
10
+ @code_lines = Array.new
11
+ end
12
+
13
+ def to_html
14
+ s = ''
15
+
16
+ if @@htmlTableRenderInProgress
17
+ s += "</table>\n"
18
+ @@htmlTableRenderInProgress = false
19
+ end
20
+ s += "<code>"
21
+ @code_lines.each do |l|
22
+ s += l + " </br>"
23
+ end
24
+ s += "</code>\n"
25
+ return s
26
+ end
27
+ end
@@ -0,0 +1,17 @@
1
+ require_relative "doc_item"
2
+
3
+ class DocFooter < DocItem
4
+
5
+ def initialize
6
+ end
7
+
8
+ def to_html
9
+ s = ''
10
+ if @@htmlTableRenderInProgress
11
+ s += "</table>\n"
12
+ @@htmlTableRenderInProgress = false
13
+ end
14
+ return s
15
+ end
16
+
17
+ end
@@ -47,7 +47,9 @@ class MarkdownList < DocItem
47
47
 
48
48
  elsif pos < @@lists_stack[-1].indent_position
49
49
 
50
- @@lists_stack.pop
50
+ while pos < @@lists_stack[-1].indent_position
51
+ @@lists_stack.pop
52
+ end
51
53
  @@lists_stack[-1].rows.append(row)
52
54
 
53
55
  else
@@ -70,14 +72,27 @@ class MarkdownList < DocItem
70
72
  def calculate_text_position(s)
71
73
  s.downcase
72
74
  pos = 0
73
- space_detected = false
75
+ state = 'looking_for_list_item_marker'
74
76
  s.each_char do |c|
75
- if space_detected
76
- if c != ' ' && c != '\t' && c != '*' && c != '.' && !numeric?(c)
77
+ if state == 'looking_for_list_item_marker'
78
+ if c == '*'
79
+ state = 'looking_for_space'
80
+ elsif numeric?(c)
81
+ state = 'looking_for_dot'
82
+ end
83
+ elsif state == 'looking_for_dot'
84
+ if c == '.'
85
+ state = 'looking_for_space'
86
+ end
87
+ elsif state == 'looking_for_space'
88
+ if c == ' ' || c == '\t'
89
+ state = 'looking_for_non_space'
90
+ end
91
+ elsif state == 'looking_for_non_space'
92
+ if c != ' ' || c != '\t'
93
+ state = 'list_item_text_pos_found'
77
94
  break
78
95
  end
79
- elsif c == ' ' || c == '\t'
80
- space_detected = true
81
96
  end
82
97
  pos += 1
83
98
  end
@@ -155,7 +155,7 @@ class TextLine
155
155
  def link(link_text, link_url)
156
156
 
157
157
  # define default result first
158
- result = "<a href=\"#{link_url}\" class=\"external\">#{link_text}</a>"
158
+ result = "<a target=\"_blank\" rel=\"noopener\" href=\"#{link_url}\" class=\"external\">#{link_text}</a>"
159
159
 
160
160
  lazy_doc_id, anchor = nil, nil
161
161
 
@@ -34,6 +34,7 @@ class Index < BaseDocument
34
34
  s += "\t\t<th>Items<br>w/ Downlinks</th>\n"
35
35
  s += "\t\t<th>Covered<br>by Tests</th>\n"
36
36
  s += "\t\t<th>Duplicated<br>ids</th>\n"
37
+ s += "\t\t<th>Wrong<br>links</th>\n"
37
38
  s += "\t\t<th>TODOs</th>\n"
38
39
  s += "\t\t<th>Last Used<br>id</th>\n"
39
40
  s += "</thead>\n"
@@ -63,6 +64,22 @@ class Index < BaseDocument
63
64
  else
64
65
  s += "\t\t<td class=\"item_id\" style='width: 7%;'>#{doc.duplicated_ids_number.to_s}</td>\n"
65
66
  end
67
+
68
+ if doc.wrong_links_hash.length >0
69
+ s += "\t\t<td class=\"item_id\" style='width: 7%; background-color: #fcc;'>"
70
+ s += "<div id=\"DL_#{doc.id}wl\" style=\"display: block;\">"
71
+ s += "<a href=\"#\" onclick=\"downlink_OnClick(this.parentElement); return false;\" class=\"external\">#{doc.wrong_links_hash.length.to_s}</a>"
72
+ s += "</div>"
73
+ s += "<div id=\"DLS_#{doc.id}wl\" style=\"display: none;\">"
74
+ doc.wrong_links_hash.each do |wrong_lnk, item|
75
+ s += "\t\t\t<a href=\"./specifications/#{doc.id}/#{doc.id}.html##{item.id}\" class=\"external\">#{wrong_lnk}</a>\n<br>"
76
+ end
77
+ s += "</div>"
78
+ s += "</td>\n"
79
+ else
80
+ s += "\t\t<td class=\"item_id\" style='width: 7%;'>#{doc.wrong_links_hash.length.to_s}</td>\n"
81
+ end
82
+
66
83
  if doc.todo_blocks.length >0
67
84
  color = "background-color: #fcc;"
68
85
  else
@@ -6,6 +6,7 @@ class Specification < BaseDocument
6
6
  attr_accessor :dictionary
7
7
  attr_accessor :controlled_items
8
8
  attr_accessor :todo_blocks
9
+ attr_accessor :wrong_links_hash
9
10
 
10
11
  attr_accessor :items_with_uplinks_number
11
12
  attr_accessor :items_with_downlinks_number
@@ -25,6 +26,7 @@ class Specification < BaseDocument
25
26
  @dictionary = Hash.new
26
27
  @duplicates_list = Array.new
27
28
  @todo_blocks = Array.new
29
+ @wrong_links_hash = Hash.new
28
30
 
29
31
  @items_with_uplinks_number = 0
30
32
  @items_with_downlinks_number = 0
@@ -57,7 +57,7 @@ class Traceability < BaseDocument
57
57
  def render_table_row(top_item)
58
58
  s = ""
59
59
  top_f_text = top_item.format_string( top_item.text )
60
-
60
+
61
61
  if top_item.down_links
62
62
 
63
63
  if @is_agregated
@@ -81,6 +81,7 @@ class Traceability < BaseDocument
81
81
  end
82
82
 
83
83
  else
84
+ top_item_rendered = false
84
85
  top_item.down_links.each do |bottom_item|
85
86
 
86
87
  id_color = ""
@@ -97,8 +98,18 @@ class Traceability < BaseDocument
97
98
  s += "\t\t<td class=\"item_text\" style='width: 34%;'>#{bottom_f_text}</td>\n"
98
99
  s += "\t\t<td class=\"item_text\" style='width: 16%;'>#{document_section}</td>\n"
99
100
  s += "\t</tr>\n"
101
+ top_item_rendered = true
100
102
  end
101
103
  end
104
+ unless top_item_rendered
105
+ s += "\t<tr>\n"
106
+ 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"
107
+ s += "\t\t<td class=\"item_text\" style='width: 34%;'>#{top_f_text}</td>\n"
108
+ s += "\t\t<td class=\"item_id\"></td>\n"
109
+ s += "\t\t<td class=\"item_text\" style='width: 34%;'></td>\n"
110
+ s += "\t\t<td class=\"item_text\" style='width: 16%;'></td>\n"
111
+ s += "\t</tr>\n"
112
+ end
102
113
  end
103
114
  else
104
115
  s += "\t<tr>\n"
@@ -15,6 +15,7 @@ class Project
15
15
  attr_accessor :specifications_dictionary
16
16
  attr_accessor :index
17
17
  attr_accessor :project
18
+ attr_accessor :on_server
18
19
 
19
20
  def initialize(path)
20
21
  @project_root_directory = path
@@ -25,6 +26,7 @@ class Project
25
26
  @specifications_dictionary = Hash.new
26
27
  @index = nil
27
28
  @project = self
29
+ @on_server = false
28
30
 
29
31
  FileUtils.remove_dir(@project_root_directory + "/build", true)
30
32
  end
@@ -35,6 +37,7 @@ class Project
35
37
  parse_all_protocols
36
38
  link_all_specifications
37
39
  link_all_protocols
40
+ check_wrong_specification_referenced
38
41
  create_index
39
42
  render_all_specifications(@specifications)
40
43
  render_all_specifications(@traceability_matrices)
@@ -49,6 +52,7 @@ class Project
49
52
  parse_test_run test_run
50
53
  link_all_specifications
51
54
  link_all_protocols
55
+ check_wrong_specification_referenced
52
56
  create_index
53
57
  render_all_specifications(@specifications)
54
58
  render_all_specifications(@traceability_matrices)
@@ -123,6 +127,37 @@ class Project
123
127
  end
124
128
  end
125
129
 
130
+ def check_wrong_specification_referenced
131
+
132
+ available_specification_ids = Hash.new
133
+
134
+ @specifications.each do |s|
135
+ available_specification_ids[ s.id.to_s.downcase ] = s
136
+ end
137
+
138
+ @specifications.each do |s|
139
+ s.up_link_doc_id.each do |key, value|
140
+ unless available_specification_ids.has_key?(key)
141
+ # now key points to the doc_id that does not exist
142
+ wrong_doc_id = key
143
+ # find the item that reference to it
144
+ s.controlled_items.each do |item|
145
+ unless item.up_link_ids.nil?
146
+ item.up_link_ids.each do |up_link_id|
147
+ if tmp = /^([a-zA-Z]+)[-]\d+/.match(up_link_id) # SRS
148
+ if tmp[1].downcase == wrong_doc_id
149
+ # we got it finally!
150
+ s.wrong_links_hash[ up_link_id.to_s ] = item
151
+ end
152
+ end
153
+ end
154
+ end
155
+ end
156
+ end
157
+ end
158
+ end
159
+ end
160
+
126
161
  def link_two_specifications(doc_A, doc_B)
127
162
 
128
163
  if doc_B.up_link_doc_id.has_key?(doc_A.id.to_s)
@@ -149,6 +184,13 @@ class Project
149
184
  top_document.items_with_downlinks_number += 1 # for statistics
150
185
  end
151
186
  topItem.down_links.append(item)
187
+ else
188
+ # check if there is a non existing link with the right doc_id
189
+ if tmp = /^([a-zA-Z]+)[-]\d+/.match(up_lnk) # SRS
190
+ if tmp[1].downcase == top_document.id.downcase
191
+ bottom_document.wrong_links_hash[ up_lnk ] = item
192
+ end
193
+ end
152
194
  end
153
195
  end
154
196
  end
@@ -145,6 +145,15 @@
145
145
  margin-top: 4px;
146
146
  margin-bottom: 4px;
147
147
  }
148
+ code {
149
+ display: block;
150
+ background:#ffffee;
151
+ border-left: 3px double #bbb;
152
+ font-family: Consolas, Menlo, "Liberation Mono", Courier, monospace;
153
+ padding: 4px 1em 4px 4px;
154
+ margin-top: 4px;
155
+ margin-bottom: 4px;
156
+ }
148
157
  div.todoblock {
149
158
  display: block;
150
159
  background:#fcc;
@@ -294,6 +303,13 @@ window.onload = (event) => {
294
303
  elem.style.width = "640px";
295
304
  }
296
305
  }
306
+ // Scroll a bit to make navigated anchor visible
307
+ setTimeout(function() {
308
+ window.scrollBy({
309
+ top: -40,
310
+ behavior: "smooth"
311
+ });
312
+ }, 200);
297
313
  };
298
314
 
299
315
  function downlink_OnClick(clicked){
@@ -307,6 +323,8 @@ function navigate_to_home(){
307
323
  if (document.title != "Document Index")
308
324
  {
309
325
  window.location.href = "./../../index.html";
326
+ }else{
327
+ window.location.href = "./index.html";
310
328
  }
311
329
  }
312
330
 
@@ -341,16 +359,16 @@ function modal_close_OnClick(clicked){
341
359
  </div>
342
360
  <div id="content" href="javascript:void(0)" onclick="closeNav()">
343
361
  {{CONTENT}}
344
- </div>
345
- </div>
362
+ </div><!-- content -->
363
+ </div><!-- main -->
364
+ <div id="footer">
365
+ Powered by <a target="_blank" rel="noopener" href="https://www.almirah.site/">Almirah Framework</a>
366
+ </div><!-- footer -->
346
367
  <!-- The modal window for image zoom -->
347
368
  <div id="image_modal_div" class="modal">
348
369
  <span class="modal_close_btn" href="javascript:void(0)" onclick="modal_close_OnClick(this)">&times;</span>
349
370
  <img class="modal_image" id="modal_image_id">
350
371
  <div id="modal_image_caption"></div>
351
372
  </div>
352
- <div id="footer">
353
- Powered by <a target="_blank" rel="noopener" href="https://www.almirah.site/">Almirah Framework</a>
354
- </div>
355
373
  </body>
356
374
 
data/lib/almirah.rb CHANGED
@@ -7,9 +7,9 @@ class CLI < Thor
7
7
  def please(project_folder)
8
8
  a = Almirah.new project_folder
9
9
  if options[:results]
10
- a.results options[:results]
10
+ a.results( options[:results], false )
11
11
  else
12
- a.default
12
+ a.default(false)
13
13
  end
14
14
  end
15
15
 
@@ -18,6 +18,17 @@ class CLI < Thor
18
18
  a = Almirah.new project_folder
19
19
  a.transform "docx"
20
20
  end
21
+
22
+ option :results
23
+ desc "server <project_folder>", "say <project_folder>"
24
+ def server(project_folder)
25
+ a = Almirah.new project_folder
26
+ if options[:results]
27
+ a.results( options[:results], true )
28
+ else
29
+ a.default(true)
30
+ end
31
+ end
21
32
  end
22
33
 
23
34
  class Almirah
@@ -32,7 +43,8 @@ class Almirah
32
43
  File.expand_path './..', File.dirname(__FILE__)
33
44
  end
34
45
 
35
- def results( test_run )
46
+ def results( test_run, on_server )
47
+ @project.on_server = on_server
36
48
  @project.specifications_and_results test_run
37
49
  end
38
50
 
@@ -40,7 +52,8 @@ class Almirah
40
52
  @project.transform file_extension
41
53
  end
42
54
 
43
- def default()
55
+ def default(on_server)
56
+ @project.on_server = on_server
44
57
  @project.specifications_and_protocols
45
58
  end
46
59
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Almirah
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleksandr Ivanov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-30 00:00:00.000000000 Z
11
+ date: 2024-04-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: The software part of the Almirah framework
14
14
  email: oleksandr.ivanov.development@gmail.com
@@ -21,9 +21,11 @@ files:
21
21
  - lib/almirah.rb
22
22
  - lib/almirah/doc_fabric.rb
23
23
  - lib/almirah/doc_items/blockquote.rb
24
+ - lib/almirah/doc_items/code_block.rb
24
25
  - lib/almirah/doc_items/controlled_paragraph.rb
25
26
  - lib/almirah/doc_items/controlled_table.rb
26
27
  - lib/almirah/doc_items/controlled_table_row.rb
28
+ - lib/almirah/doc_items/doc_footer.rb
27
29
  - lib/almirah/doc_items/doc_item.rb
28
30
  - lib/almirah/doc_items/heading.rb
29
31
  - lib/almirah/doc_items/image.rb
@@ -60,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
62
  - !ruby/object:Gem::Version
61
63
  version: '0'
62
64
  requirements: []
63
- rubygems_version: 3.5.6
65
+ rubygems_version: 3.5.9
64
66
  signing_key:
65
67
  specification_version: 4
66
68
  summary: Almirah