Almirah 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,3 @@
1
- require_relative "specification"
2
- require_relative "doc_items/doc_item"
3
1
 
4
2
  class HtmlRender
5
3
 
@@ -7,13 +5,15 @@ class HtmlRender
7
5
  attr_accessor :htmlRows
8
6
  attr_accessor :outputFile
9
7
  attr_accessor :document
8
+ attr_accessor :nav_pane
10
9
 
11
- def initialize(document, template, outputFile)
10
+ def initialize(document, nav_pane, template, outputFile)
12
11
 
13
12
  @template = template
14
13
  @outputFile = outputFile
15
14
  @htmlRows = Array.new
16
15
  @document = document
16
+ @nav_pane = nav_pane
17
17
 
18
18
  self.render()
19
19
  self.saveRenderToFile()
@@ -22,7 +22,7 @@ class HtmlRender
22
22
  def render()
23
23
  self.htmlRows.append('')
24
24
 
25
- self.document.docItems.each do |item|
25
+ self.document.items.each do |item|
26
26
  a = item.to_html
27
27
  self.htmlRows.append a
28
28
  end
@@ -40,6 +40,10 @@ class HtmlRender
40
40
  self.htmlRows.each do |r|
41
41
  file.puts r
42
42
  end
43
+ elsif s.include?('{{NAV_PANE}}')
44
+ if @nav_pane
45
+ file.puts self.nav_pane.to_html
46
+ end
43
47
  else
44
48
  file.puts s
45
49
  end
@@ -0,0 +1,23 @@
1
+
2
+ class NavigationPane
3
+
4
+ attr_accessor :specifications
5
+
6
+ def initialize(specifications)
7
+ @specifications = specifications
8
+ end
9
+
10
+ def to_html
11
+ s = "<ul class=\"fa-ul\">\n"
12
+ @specifications.each do |spec|
13
+ s += "\t<li><span class=\"fa-li\"><i class=\"fa fa-folder-open-o\"> </i></span> #{spec.id}\n"
14
+ s += "\t\t<ul class=\"fa-ul\">\n"
15
+ s += "\t\t\t<li><span class=\"fa-li\"><i class=\"fa fa-plus-square-o\"> </i></span>\n"
16
+ s += "\t\t\t\t<a href=\".\\..\\#{spec.id }\\#{spec.id }.html\">#{spec.title}</a>\n"
17
+ s += "\t\t\t</li>\n"
18
+ s += "\t\t</ul>\n"
19
+ s += "\t</li>\n"
20
+ end
21
+ s += "</ul>\n"
22
+ end
23
+ end
@@ -0,0 +1,186 @@
1
+ require_relative "doc_fabric"
2
+ require_relative "html_render"
3
+ require_relative "navigation_pane"
4
+
5
+ class Project
6
+
7
+ attr_accessor :specifications
8
+ attr_accessor :protocols
9
+ attr_accessor :project_root_directory
10
+ attr_accessor :gem_root
11
+ attr_accessor :specifications_dictionary
12
+
13
+ def initialize(path, gem_root)
14
+ @project_root_directory = path
15
+ @specifications = Array.new
16
+ @protocols = Array.new
17
+ @gem_root = gem_root
18
+ @specifications_dictionary = Hash.new
19
+
20
+ FileUtils.remove_dir(@project_root_directory + "/build", true)
21
+ end
22
+
23
+ def specifications_and_protocols
24
+
25
+ parse_all_specifications
26
+ parse_all_protocols
27
+ link_all_specifications
28
+ link_all_protocols
29
+ render_all_specifications
30
+ render_all_protocols
31
+ end
32
+
33
+ def specifications_and_results( test_run )
34
+
35
+ parse_all_specifications
36
+ parse_test_run test_run
37
+ link_all_specifications
38
+ link_all_protocols
39
+ render_all_specifications
40
+ render_all_protocols
41
+ end
42
+
43
+ def parse_all_specifications
44
+ Dir.glob( "#{@project_root_directory}/specifications/**/*.md" ).each do |f|
45
+ puts "Spec: " + f
46
+ doc = DocFabric.create_specification(f)
47
+ @specifications.append(doc)
48
+ end
49
+ end
50
+
51
+ def parse_all_protocols
52
+ Dir.glob( "#{@project_root_directory}/tests/protocols/**/*.md" ).each do |f|
53
+ puts "Prot: " + f
54
+ doc = DocFabric.create_protocol(f)
55
+ @protocols.append(doc)
56
+ end
57
+ end
58
+
59
+ def parse_test_run( test_run )
60
+ Dir.glob( "#{@project_root_directory}/tests/runs/#{test_run}/**/*.md" ).each do |f|
61
+ puts "Run: " + f
62
+ doc = DocFabric.create_protocol(f)
63
+ @protocols.append(doc)
64
+ end
65
+ end
66
+
67
+ def link_all_specifications
68
+ combList = @specifications.combination(2)
69
+ combList.each do |c|
70
+ link_two_specifications(c[0], c[1])
71
+ end
72
+ end
73
+
74
+ def link_all_protocols
75
+ @protocols.each do |p|
76
+ @specifications.each do |s|
77
+ if s.id == p.up_link_doc_id
78
+ link_protocol_to_spec(p,s)
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+ def link_two_specifications(doc_A, doc_B)
85
+
86
+ if doc_A.id == doc_B.up_link_doc_id
87
+ top_document = doc_A
88
+ bottom_document = doc_B
89
+ elsif doc_B.id == doc_A.up_link_doc_id
90
+ top_document = doc_B
91
+ bottom_document = doc_A
92
+ else
93
+ puts "No Links"
94
+ return # no links
95
+ end
96
+
97
+ bottom_document.controlled_items.each do |item|
98
+
99
+ if top_document.dictionary.has_key?(item.up_link.to_s)
100
+
101
+ topItem = top_document.dictionary[item.up_link.to_s]
102
+
103
+ unless topItem.down_links
104
+ topItem.down_links = Array.new
105
+ end
106
+ topItem.down_links.append(item)
107
+
108
+ #if tmp = /^([a-zA-Z]+)[-]\d+/.match(item.id)
109
+ # top_document.downlinkKey = tmp[1].upcase
110
+ #end
111
+ end
112
+ end
113
+ end
114
+
115
+ def link_protocol_to_spec(protocol, specification)
116
+
117
+ top_document = specification
118
+ bottom_document = protocol
119
+
120
+ bottom_document.controlled_items.each do |item|
121
+
122
+ if top_document.dictionary.has_key?(item.up_link.to_s)
123
+
124
+ topItem = top_document.dictionary[item.up_link.to_s]
125
+
126
+ unless topItem.coverage_links
127
+ topItem.coverage_links = Array.new
128
+ end
129
+ topItem.coverage_links.append(item)
130
+ end
131
+ end
132
+ end
133
+
134
+ def render_all_specifications
135
+
136
+ # create a sidebar first
137
+ nav_pane = NavigationPane.new(@specifications)
138
+
139
+ pass = @project_root_directory
140
+
141
+ FileUtils.mkdir_p(pass + "/build/specifications")
142
+
143
+ @specifications.each do |doc|
144
+
145
+ img_src_dir = pass + "/specifications/" + doc.id + "/img"
146
+ img_dst_dir = pass + "/build/specifications/" + doc.id + "/img"
147
+
148
+ FileUtils.mkdir_p(img_dst_dir)
149
+
150
+ if File.directory?(img_src_dir)
151
+ FileUtils.copy_entry( img_src_dir, img_dst_dir )
152
+ end
153
+
154
+ HtmlRender.new( doc, nav_pane,
155
+ @gem_root + "/lib/almirah/templates/page.html",
156
+ "#{pass}/build/specifications/#{doc.id}/#{doc.id}.html" )
157
+ end
158
+ end
159
+
160
+ def render_all_protocols
161
+
162
+ # create a sidebar first
163
+ #nav_pane = NavigationPane.new(@specifications)
164
+
165
+ pass = @project_root_directory
166
+
167
+ # FileUtils.remove_dir(pass + "/build/tests", true)
168
+ FileUtils.mkdir_p(pass + "/build/tests/protocols")
169
+
170
+ @protocols.each do |doc|
171
+
172
+ img_src_dir = pass + "/tests/protocols/" + doc.id + "/img"
173
+ img_dst_dir = pass + "/build/tests/protocols/" + doc.id + "/img"
174
+
175
+ FileUtils.mkdir_p(img_dst_dir)
176
+
177
+ if File.directory?(img_src_dir)
178
+ FileUtils.copy_entry( img_src_dir, img_dst_dir )
179
+ end
180
+
181
+ HtmlRender.new( doc, nil,
182
+ @gem_root + "/lib/almirah/templates/page.html",
183
+ "#{pass}/build/tests/protocols/#{doc.id}/#{doc.id}.html" )
184
+ end
185
+ end
186
+ end
@@ -3,6 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
5
  <!-- CSS -->
6
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
6
7
  <style>
7
8
  body {
8
9
  font-family: Verdana, sans-serif;
@@ -15,12 +16,12 @@
15
16
  #main {
16
17
  flex-grow: 2;
17
18
  display: flex;
18
- flex-direction: row-reverse;
19
+ flex-direction: row;
19
20
  }
20
21
  #content {
21
22
  flex-grow: 1;
22
23
  background-color: #fff;
23
- margin: 0px;
24
+ margin-top: 30px;
24
25
  padding: 10px 16px 10px 16px;
25
26
  overflow-x: auto;
26
27
  }
@@ -88,7 +89,7 @@
88
89
  background-color:#e1f1fa;
89
90
  padding: 4px;
90
91
  white-space:nowrap;
91
- font-weight:bold;
92
+ font-weight:normal;
92
93
  border: 1px solid #bbb;
93
94
  }
94
95
  table.controlled td {
@@ -135,11 +136,68 @@
135
136
  margin-top: 4px;
136
137
  margin-bottom: 4px;
137
138
  }
139
+ #nav_pane{
140
+ flex-shrink: 0;
141
+ padding: 16px 8px 2px 8px;
142
+ background: #EEEEEE;
143
+ border-left: 1px solid #ddd;
144
+ position: fixed;
145
+ height: 100%; /* 100% Full-height */
146
+ visibility: hidden;
147
+ }
148
+ @media screen and (min-width: 0px) and (max-width: 1089px) {#nav_pane{width: 22%;}}
149
+ @media screen and (min-width: 1090px) and (max-width: 1279px) {#nav_pane{width: 240px;}}
150
+ @media screen and (min-width: 1280px) and (max-width: 1599px) {#nav_pane{width: 280px;}}
151
+ @media screen and (min-width: 1600px) and (max-width: 1919px) {#nav_pane{width: 320px;}}
152
+ @media screen and (min-width: 1920px) and (max-width: 2559px) {#nav_pane{width: 360px;}}
153
+ @media screen and (min-width: 2560px) {#nav_pane{width: 380px;}}
154
+ #top_nav{
155
+ background-color: #169;
156
+ overflow: hidden;
157
+ position: fixed;
158
+ width: 100%;
159
+ }
160
+ #top_nav a {
161
+ float: left;
162
+ color: white;
163
+ text-align: center;
164
+ padding: 4px 6px;
165
+ text-decoration: none;
166
+ font-size: 1.5em;
167
+ font-family: "Trebuchet MS", Verdana, sans-serif;
168
+ }
169
+ #top_nav a:hover {
170
+ background-color: black;
171
+ color: white;
172
+ }
173
+ #top_nav a.active {
174
+ background-color: #169;
175
+ color: white;
176
+ }
177
+
138
178
  </style>
179
+ <script>
180
+ function openNav() {
181
+ document.getElementById("nav_pane").style.visibility = "visible";
182
+ console.log("Mouse In")
183
+ }
184
+
185
+ function closeNav() {
186
+ document.getElementById("nav_pane").style.visibility = "hidden";
187
+ console.log("Mouse Out");
188
+ }
189
+ </script>
139
190
  </head>
140
191
  <body>
192
+ <div id="top_nav">
193
+ <a href="javascript:void(0)" onclick="openNav()"><span><i class="fa fa-bars" aria-hidden="true"></i></span>&nbsp;Navigation</a>
194
+ <a href="javascript:void(0)"> About</a>
195
+ </div>
141
196
  <div id="main">
142
- <div id="content">
197
+ <div id="nav_pane">
198
+ {{NAV_PANE}}
199
+ </div>
200
+ <div id="content" href="javascript:void(0)" onclick="closeNav()">
143
201
  {{CONTENT}}
144
202
  </div>
145
203
  </div>
data/lib/almirah.rb CHANGED
@@ -1,58 +1,37 @@
1
1
  require "thor"
2
- require_relative "almirah/specification"
3
- require_relative "almirah/linker"
4
- require_relative "almirah/html_render"
2
+ require_relative "almirah/project"
5
3
 
6
4
  class CLI < Thor
7
- desc "please <pass>", "say <pass>"
8
- def please(pass)
9
- Almirah.new().start(pass)
5
+ desc "please <project_folder>", "say <project_folder>"
6
+ option :results
7
+ def please(project_folder)
8
+ a = Almirah.new project_folder
9
+ if options[:results]
10
+ a.results options[:results]
11
+ else
12
+ a.default
13
+ end
10
14
  end
11
15
  end
12
16
 
13
17
  class Almirah
14
18
 
19
+ attr_accessor :project
20
+
21
+ def initialize project_folder
22
+ @project = Project.new project_folder, getGemRoot
23
+ end
24
+
15
25
  def getGemRoot
16
26
  File.expand_path './..', File.dirname(__FILE__)
17
27
  end
18
28
 
19
- def start(pass)
20
- # Documents
21
- documentList = Array.new
22
-
23
- # Parse
24
- Dir.glob( "#{pass}/**/*.md" ).each do |f|
25
- puts f
26
- spec = Specification.new(f)
27
- documentList.append(spec)
28
- end
29
-
30
- # Link
31
- linker = Linker.new
32
- combList = documentList.combination(2)
33
- combList.each do |c|
34
- linker.link(c[0], c[1])
35
- end
36
-
37
- # Render
38
- FileUtils.remove_dir(pass + "/build", true)
39
- FileUtils.mkdir_p(pass + "/build/specifications")
40
-
41
- documentList.each do |spec|
42
-
43
- img_src_dir = pass + "/specifications/" + spec.key.downcase + "/img"
44
- img_dst_dir = pass + "/build/specifications/" + spec.key.downcase + "/img"
45
-
46
- FileUtils.mkdir_p(img_dst_dir)
47
-
48
- if File.directory?(img_src_dir)
49
- FileUtils.copy_entry( img_src_dir, img_dst_dir )
50
- end
29
+ def results( test_run )
30
+ @project.specifications_and_results test_run
31
+ end
51
32
 
52
- HtmlRender.new( spec,
53
- getGemRoot() + "/lib/almirah/templates/page.html",
54
- "#{pass}/build/specifications/#{spec.key.downcase}/#{spec.key.downcase}.html" )
55
- end
33
+ def default
34
+ @project.specifications_and_protocols
56
35
  end
57
36
 
58
37
  end
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.0.5
4
+ version: 0.0.7
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-01-29 00:00:00.000000000 Z
11
+ date: 2024-02-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: The software part of the Almirah system
14
14
  email: oleksandr.ivanov.development@gmail.com
@@ -19,17 +19,23 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - bin/almirah
21
21
  - lib/almirah.rb
22
+ - lib/almirah/doc_fabric.rb
22
23
  - lib/almirah/doc_items/blockquote.rb
23
24
  - lib/almirah/doc_items/controlled_paragraph.rb
25
+ - lib/almirah/doc_items/controlled_table.rb
26
+ - lib/almirah/doc_items/controlled_table_row.rb
24
27
  - lib/almirah/doc_items/doc_item.rb
25
28
  - lib/almirah/doc_items/heading.rb
26
29
  - lib/almirah/doc_items/image.rb
27
30
  - lib/almirah/doc_items/markdown_list.rb
28
31
  - lib/almirah/doc_items/markdown_table.rb
29
32
  - lib/almirah/doc_items/paragraph.rb
33
+ - lib/almirah/doc_types/base_document.rb
34
+ - lib/almirah/doc_types/protocol.rb
35
+ - lib/almirah/doc_types/specification.rb
30
36
  - lib/almirah/html_render.rb
31
- - lib/almirah/linker.rb
32
- - lib/almirah/specification.rb
37
+ - lib/almirah/navigation_pane.rb
38
+ - lib/almirah/project.rb
33
39
  - lib/almirah/templates/page.html
34
40
  homepage: http://almirah.site
35
41
  licenses:
@@ -1,42 +0,0 @@
1
- require_relative "doc_items/doc_item"
2
- require_relative "specification"
3
-
4
- class Linker
5
-
6
- attr_accessor :field
7
-
8
- def initialize()
9
- @field = "field"
10
- end
11
-
12
- def link(doc_A, doc_B)
13
-
14
- if doc_A.key == doc_B.up_link_key
15
- top_document = doc_A
16
- bottom_document = doc_B
17
- elsif doc_B.key == doc_A.up_link_key
18
- top_document = doc_B
19
- bottom_document = doc_A
20
- else
21
- puts "No Links"
22
- return # no links
23
- end
24
-
25
- bottom_document.controlledParagraphs.each do |item|
26
-
27
- if top_document.dictionary.has_key?(item.up_link.to_s)
28
-
29
- topItem = top_document.dictionary[item.up_link.to_s]
30
-
31
- unless topItem.down_links
32
- topItem.down_links = Array.new
33
- end
34
- topItem.down_links.append(item)
35
-
36
- #if tmp = /^([a-zA-Z]+)[-]\d+/.match(item.id)
37
- # top_document.downlinkKey = tmp[1].upcase
38
- #end
39
- end
40
- end
41
- end
42
- end