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.
- checksums.yaml +4 -4
- data/bin/almirah +4 -4
- data/lib/almirah/doc_fabric.rb +65 -65
- data/lib/almirah/doc_items/blockquote.rb +21 -21
- data/lib/almirah/doc_items/code_block.rb +26 -26
- data/lib/almirah/doc_items/controlled_paragraph.rb +112 -112
- data/lib/almirah/doc_items/controlled_table.rb +224 -224
- data/lib/almirah/doc_items/controlled_table_row.rb +22 -22
- data/lib/almirah/doc_items/doc_footer.rb +16 -16
- data/lib/almirah/doc_items/doc_item.rb +22 -20
- data/lib/almirah/doc_items/frontmatter.rb +9 -0
- data/lib/almirah/doc_items/heading.rb +93 -93
- data/lib/almirah/doc_items/image.rb +27 -27
- data/lib/almirah/doc_items/markdown_list.rb +156 -158
- data/lib/almirah/doc_items/markdown_table.rb +61 -63
- data/lib/almirah/doc_items/paragraph.rb +25 -27
- data/lib/almirah/doc_items/text_line.rb +296 -296
- data/lib/almirah/doc_items/todo_block.rb +21 -21
- data/lib/almirah/doc_parser.rb +378 -330
- data/lib/almirah/doc_types/base_document.rb +64 -70
- data/lib/almirah/doc_types/coverage.rb +95 -81
- data/lib/almirah/doc_types/index.rb +173 -169
- data/lib/almirah/doc_types/persistent_document.rb +17 -20
- data/lib/almirah/doc_types/protocol.rb +24 -24
- data/lib/almirah/doc_types/specification.rb +67 -67
- data/lib/almirah/doc_types/traceability.rb +142 -142
- data/lib/almirah/dom/doc_section.rb +25 -25
- data/lib/almirah/dom/document.rb +78 -72
- data/lib/almirah/navigation_pane.rb +16 -16
- data/lib/almirah/project.rb +287 -306
- data/lib/almirah/project_configuration.rb +41 -41
- data/lib/almirah/project_template.rb +298 -0
- data/lib/almirah/project_utility.rb +52 -0
- data/lib/almirah/search/specifications_db.rb +79 -83
- data/lib/almirah/templates/css/main.css +300 -300
- data/lib/almirah/templates/css/search.css +40 -40
- data/lib/almirah/templates/page.html +42 -42
- data/lib/almirah/templates/scripts/main.js +111 -111
- data/lib/almirah/templates/scripts/orama_search.js +138 -138
- data/lib/almirah.rb +93 -49
- metadata +28 -5
    
        data/lib/almirah/project.rb
    CHANGED
    
    | @@ -1,306 +1,287 @@ | |
| 1 | 
            -
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'fileutils'
         | 
| 4 | 
            -
            require_relative 'doc_fabric'
         | 
| 5 | 
            -
            require_relative 'navigation_pane'
         | 
| 6 | 
            -
            require_relative 'doc_types/traceability'
         | 
| 7 | 
            -
            require_relative 'doc_types/index'
         | 
| 8 | 
            -
            require_relative 'search/specifications_db'
         | 
| 9 | 
            -
             | 
| 10 | 
            -
            class Project # rubocop:disable Metrics/ClassLength,Style/Documentation
         | 
| 11 | 
            -
              attr_accessor :specifications, :protocols, :traceability_matrices, :coverage_matrices, :specifications_dictionary,
         | 
| 12 | 
            -
                            :index, :project, :configuration
         | 
| 13 | 
            -
             | 
| 14 | 
            -
              def initialize(configuration)
         | 
| 15 | 
            -
                @configuration = configuration
         | 
| 16 | 
            -
                @specifications = []
         | 
| 17 | 
            -
                @protocols = []
         | 
| 18 | 
            -
                @traceability_matrices = []
         | 
| 19 | 
            -
                @coverage_matrices = []
         | 
| 20 | 
            -
                @specifications_dictionary = {}
         | 
| 21 | 
            -
                @covered_specifications_dictionary = {}
         | 
| 22 | 
            -
                @index = nil
         | 
| 23 | 
            -
                @project = self
         | 
| 24 | 
            -
                FileUtils.remove_dir("#{@configuration.project_root_directory}/build", true)
         | 
| 25 | 
            -
                copy_resources
         | 
| 26 | 
            -
              end
         | 
| 27 | 
            -
             | 
| 28 | 
            -
              def copy_resources
         | 
| 29 | 
            -
                # scripts
         | 
| 30 | 
            -
                gem_root = File.expand_path './../..', File.dirname(__FILE__)
         | 
| 31 | 
            -
                src_folder = "#{gem_root}/lib/almirah/templates/scripts"
         | 
| 32 | 
            -
                dst_folder = "#{@configuration.project_root_directory}/build/scripts"
         | 
| 33 | 
            -
                FileUtils.mkdir_p(dst_folder)
         | 
| 34 | 
            -
                FileUtils.copy_entry(src_folder, dst_folder)
         | 
| 35 | 
            -
                # css
         | 
| 36 | 
            -
                src_folder = "#{gem_root}/lib/almirah/templates/css"
         | 
| 37 | 
            -
                dst_folder = "#{@configuration.project_root_directory}/build/css"
         | 
| 38 | 
            -
                FileUtils.mkdir_p(dst_folder)
         | 
| 39 | 
            -
                FileUtils.copy_entry(src_folder, dst_folder)
         | 
| 40 | 
            -
              end
         | 
| 41 | 
            -
             | 
| 42 | 
            -
              def specifications_and_protocols # rubocop:disable Metrics/MethodLength
         | 
| 43 | 
            -
                parse_all_specifications
         | 
| 44 | 
            -
                parse_all_protocols
         | 
| 45 | 
            -
                link_all_specifications
         | 
| 46 | 
            -
                link_all_protocols
         | 
| 47 | 
            -
                check_wrong_specification_referenced
         | 
| 48 | 
            -
                create_index
         | 
| 49 | 
            -
                render_all_specifications(@specifications)
         | 
| 50 | 
            -
                render_all_specifications(@traceability_matrices)
         | 
| 51 | 
            -
                render_all_specifications(@coverage_matrices)
         | 
| 52 | 
            -
                render_all_protocols
         | 
| 53 | 
            -
                render_index
         | 
| 54 | 
            -
                create_search_data
         | 
| 55 | 
            -
              end
         | 
| 56 | 
            -
             | 
| 57 | 
            -
              def specifications_and_results(test_run) # rubocop:disable Metrics/MethodLength
         | 
| 58 | 
            -
                parse_all_specifications
         | 
| 59 | 
            -
                parse_test_run test_run
         | 
| 60 | 
            -
                link_all_specifications
         | 
| 61 | 
            -
                link_all_protocols
         | 
| 62 | 
            -
                check_wrong_specification_referenced
         | 
| 63 | 
            -
                create_index
         | 
| 64 | 
            -
                render_all_specifications(@specifications)
         | 
| 65 | 
            -
                render_all_specifications(@traceability_matrices)
         | 
| 66 | 
            -
                render_all_specifications(@coverage_matrices)
         | 
| 67 | 
            -
                render_all_protocols
         | 
| 68 | 
            -
                render_index
         | 
| 69 | 
            -
                create_search_data
         | 
| 70 | 
            -
              end
         | 
| 71 | 
            -
             | 
| 72 | 
            -
              def  | 
| 73 | 
            -
                 | 
| 74 | 
            -
             | 
| 75 | 
            -
             | 
| 76 | 
            -
             | 
| 77 | 
            -
                 | 
| 78 | 
            -
             | 
| 79 | 
            -
                #  | 
| 80 | 
            -
             | 
| 81 | 
            -
                   | 
| 82 | 
            -
                   | 
| 83 | 
            -
             | 
| 84 | 
            -
             | 
| 85 | 
            -
             | 
| 86 | 
            -
             | 
| 87 | 
            -
             | 
| 88 | 
            -
                 | 
| 89 | 
            -
             | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
| 92 | 
            -
             | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 96 | 
            -
                 | 
| 97 | 
            -
             | 
| 98 | 
            -
             | 
| 99 | 
            -
             | 
| 100 | 
            -
             | 
| 101 | 
            -
             | 
| 102 | 
            -
             | 
| 103 | 
            -
             | 
| 104 | 
            -
             | 
| 105 | 
            -
             | 
| 106 | 
            -
             | 
| 107 | 
            -
                 | 
| 108 | 
            -
             | 
| 109 | 
            -
             | 
| 110 | 
            -
             | 
| 111 | 
            -
             | 
| 112 | 
            -
             | 
| 113 | 
            -
             | 
| 114 | 
            -
             | 
| 115 | 
            -
             | 
| 116 | 
            -
                   | 
| 117 | 
            -
             | 
| 118 | 
            -
             | 
| 119 | 
            -
             | 
| 120 | 
            -
             | 
| 121 | 
            -
             | 
| 122 | 
            -
             | 
| 123 | 
            -
             | 
| 124 | 
            -
             | 
| 125 | 
            -
             | 
| 126 | 
            -
             | 
| 127 | 
            -
             | 
| 128 | 
            -
                 | 
| 129 | 
            -
             | 
| 130 | 
            -
             | 
| 131 | 
            -
                   | 
| 132 | 
            -
                   | 
| 133 | 
            -
             | 
| 134 | 
            -
             | 
| 135 | 
            -
             | 
| 136 | 
            -
             | 
| 137 | 
            -
             | 
| 138 | 
            -
             | 
| 139 | 
            -
             | 
| 140 | 
            -
             | 
| 141 | 
            -
             | 
| 142 | 
            -
             | 
| 143 | 
            -
             | 
| 144 | 
            -
             | 
| 145 | 
            -
                     | 
| 146 | 
            -
             | 
| 147 | 
            -
             | 
| 148 | 
            -
             | 
| 149 | 
            -
             | 
| 150 | 
            -
             | 
| 151 | 
            -
             | 
| 152 | 
            -
             | 
| 153 | 
            -
             | 
| 154 | 
            -
             | 
| 155 | 
            -
             | 
| 156 | 
            -
             | 
| 157 | 
            -
             | 
| 158 | 
            -
             | 
| 159 | 
            -
             | 
| 160 | 
            -
             | 
| 161 | 
            -
             | 
| 162 | 
            -
             | 
| 163 | 
            -
             | 
| 164 | 
            -
             | 
| 165 | 
            -
             | 
| 166 | 
            -
             | 
| 167 | 
            -
             | 
| 168 | 
            -
             | 
| 169 | 
            -
             | 
| 170 | 
            -
             | 
| 171 | 
            -
             | 
| 172 | 
            -
             | 
| 173 | 
            -
             | 
| 174 | 
            -
             | 
| 175 | 
            -
             | 
| 176 | 
            -
             | 
| 177 | 
            -
             | 
| 178 | 
            -
             | 
| 179 | 
            -
             | 
| 180 | 
            -
             | 
| 181 | 
            -
             | 
| 182 | 
            -
             | 
| 183 | 
            -
             | 
| 184 | 
            -
             | 
| 185 | 
            -
             | 
| 186 | 
            -
             | 
| 187 | 
            -
             | 
| 188 | 
            -
             | 
| 189 | 
            -
             | 
| 190 | 
            -
             | 
| 191 | 
            -
             | 
| 192 | 
            -
             | 
| 193 | 
            -
             | 
| 194 | 
            -
             | 
| 195 | 
            -
             | 
| 196 | 
            -
             | 
| 197 | 
            -
             | 
| 198 | 
            -
             | 
| 199 | 
            -
             | 
| 200 | 
            -
             | 
| 201 | 
            -
             | 
| 202 | 
            -
             | 
| 203 | 
            -
             | 
| 204 | 
            -
             | 
| 205 | 
            -
             | 
| 206 | 
            -
             | 
| 207 | 
            -
             | 
| 208 | 
            -
             | 
| 209 | 
            -
             | 
| 210 | 
            -
             | 
| 211 | 
            -
             | 
| 212 | 
            -
             | 
| 213 | 
            -
                       | 
| 214 | 
            -
             | 
| 215 | 
            -
             | 
| 216 | 
            -
             | 
| 217 | 
            -
             | 
| 218 | 
            -
             | 
| 219 | 
            -
             | 
| 220 | 
            -
             | 
| 221 | 
            -
             | 
| 222 | 
            -
             | 
| 223 | 
            -
             | 
| 224 | 
            -
             | 
| 225 | 
            -
             | 
| 226 | 
            -
             | 
| 227 | 
            -
             | 
| 228 | 
            -
             | 
| 229 | 
            -
             | 
| 230 | 
            -
             | 
| 231 | 
            -
             | 
| 232 | 
            -
             | 
| 233 | 
            -
             | 
| 234 | 
            -
             | 
| 235 | 
            -
             | 
| 236 | 
            -
             | 
| 237 | 
            -
             | 
| 238 | 
            -
             | 
| 239 | 
            -
             | 
| 240 | 
            -
             | 
| 241 | 
            -
             | 
| 242 | 
            -
             | 
| 243 | 
            -
             | 
| 244 | 
            -
             | 
| 245 | 
            -
                   | 
| 246 | 
            -
             | 
| 247 | 
            -
             | 
| 248 | 
            -
             | 
| 249 | 
            -
             | 
| 250 | 
            -
             | 
| 251 | 
            -
             | 
| 252 | 
            -
             | 
| 253 | 
            -
             | 
| 254 | 
            -
             | 
| 255 | 
            -
             | 
| 256 | 
            -
             | 
| 257 | 
            -
             | 
| 258 | 
            -
             | 
| 259 | 
            -
             | 
| 260 | 
            -
             | 
| 261 | 
            -
                   | 
| 262 | 
            -
             | 
| 263 | 
            -
             | 
| 264 | 
            -
             | 
| 265 | 
            -
             | 
| 266 | 
            -
             | 
| 267 | 
            -
             | 
| 268 | 
            -
                  nav_pane  | 
| 269 | 
            -
             | 
| 270 | 
            -
             | 
| 271 | 
            -
             | 
| 272 | 
            -
             | 
| 273 | 
            -
             | 
| 274 | 
            -
             | 
| 275 | 
            -
             | 
| 276 | 
            -
                 | 
| 277 | 
            -
             | 
| 278 | 
            -
                 | 
| 279 | 
            -
             | 
| 280 | 
            -
             | 
| 281 | 
            -
             | 
| 282 | 
            -
             | 
| 283 | 
            -
             | 
| 284 | 
            -
             | 
| 285 | 
            -
             | 
| 286 | 
            -
             | 
| 287 | 
            -
             | 
| 288 | 
            -
                end
         | 
| 289 | 
            -
              end
         | 
| 290 | 
            -
             | 
| 291 | 
            -
              def render_index
         | 
| 292 | 
            -
                path = @configuration.project_root_directory
         | 
| 293 | 
            -
             | 
| 294 | 
            -
                doc = @index
         | 
| 295 | 
            -
                doc.to_console
         | 
| 296 | 
            -
             | 
| 297 | 
            -
                doc.to_html("#{path}/build/")
         | 
| 298 | 
            -
              end
         | 
| 299 | 
            -
             | 
| 300 | 
            -
              def create_search_data
         | 
| 301 | 
            -
                db = SpecificationsDb.new @specifications
         | 
| 302 | 
            -
                data_path = "#{@configuration.project_root_directory}/build/data"
         | 
| 303 | 
            -
                FileUtils.mkdir_p(data_path)
         | 
| 304 | 
            -
                db.save(data_path)
         | 
| 305 | 
            -
              end
         | 
| 306 | 
            -
            end
         | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'fileutils'
         | 
| 4 | 
            +
            require_relative 'doc_fabric'
         | 
| 5 | 
            +
            require_relative 'navigation_pane'
         | 
| 6 | 
            +
            require_relative 'doc_types/traceability'
         | 
| 7 | 
            +
            require_relative 'doc_types/index'
         | 
| 8 | 
            +
            require_relative 'search/specifications_db'
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            class Project # rubocop:disable Metrics/ClassLength,Style/Documentation
         | 
| 11 | 
            +
              attr_accessor :specifications, :protocols, :traceability_matrices, :coverage_matrices, :specifications_dictionary,
         | 
| 12 | 
            +
                            :index, :project, :configuration
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              def initialize(configuration)
         | 
| 15 | 
            +
                @configuration = configuration
         | 
| 16 | 
            +
                @specifications = []
         | 
| 17 | 
            +
                @protocols = []
         | 
| 18 | 
            +
                @traceability_matrices = []
         | 
| 19 | 
            +
                @coverage_matrices = []
         | 
| 20 | 
            +
                @specifications_dictionary = {}
         | 
| 21 | 
            +
                @covered_specifications_dictionary = {}
         | 
| 22 | 
            +
                @index = nil
         | 
| 23 | 
            +
                @project = self
         | 
| 24 | 
            +
                FileUtils.remove_dir("#{@configuration.project_root_directory}/build", true)
         | 
| 25 | 
            +
                copy_resources
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              def copy_resources
         | 
| 29 | 
            +
                # scripts
         | 
| 30 | 
            +
                gem_root = File.expand_path './../..', File.dirname(__FILE__)
         | 
| 31 | 
            +
                src_folder = "#{gem_root}/lib/almirah/templates/scripts"
         | 
| 32 | 
            +
                dst_folder = "#{@configuration.project_root_directory}/build/scripts"
         | 
| 33 | 
            +
                FileUtils.mkdir_p(dst_folder)
         | 
| 34 | 
            +
                FileUtils.copy_entry(src_folder, dst_folder)
         | 
| 35 | 
            +
                # css
         | 
| 36 | 
            +
                src_folder = "#{gem_root}/lib/almirah/templates/css"
         | 
| 37 | 
            +
                dst_folder = "#{@configuration.project_root_directory}/build/css"
         | 
| 38 | 
            +
                FileUtils.mkdir_p(dst_folder)
         | 
| 39 | 
            +
                FileUtils.copy_entry(src_folder, dst_folder)
         | 
| 40 | 
            +
              end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
              def specifications_and_protocols # rubocop:disable Metrics/MethodLength
         | 
| 43 | 
            +
                parse_all_specifications
         | 
| 44 | 
            +
                parse_all_protocols
         | 
| 45 | 
            +
                link_all_specifications
         | 
| 46 | 
            +
                link_all_protocols
         | 
| 47 | 
            +
                check_wrong_specification_referenced
         | 
| 48 | 
            +
                create_index
         | 
| 49 | 
            +
                render_all_specifications(@specifications)
         | 
| 50 | 
            +
                render_all_specifications(@traceability_matrices)
         | 
| 51 | 
            +
                render_all_specifications(@coverage_matrices)
         | 
| 52 | 
            +
                render_all_protocols
         | 
| 53 | 
            +
                render_index
         | 
| 54 | 
            +
                create_search_data
         | 
| 55 | 
            +
              end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
              def specifications_and_results(test_run) # rubocop:disable Metrics/MethodLength
         | 
| 58 | 
            +
                parse_all_specifications
         | 
| 59 | 
            +
                parse_test_run test_run
         | 
| 60 | 
            +
                link_all_specifications
         | 
| 61 | 
            +
                link_all_protocols
         | 
| 62 | 
            +
                check_wrong_specification_referenced
         | 
| 63 | 
            +
                create_index
         | 
| 64 | 
            +
                render_all_specifications(@specifications)
         | 
| 65 | 
            +
                render_all_specifications(@traceability_matrices)
         | 
| 66 | 
            +
                render_all_specifications(@coverage_matrices)
         | 
| 67 | 
            +
                render_all_protocols
         | 
| 68 | 
            +
                render_index
         | 
| 69 | 
            +
                create_search_data
         | 
| 70 | 
            +
              end
         | 
| 71 | 
            +
             | 
| 72 | 
            +
              def parse_all_specifications
         | 
| 73 | 
            +
                path = @configuration.project_root_directory
         | 
| 74 | 
            +
                # do a lasy pass first to get the list of documents id
         | 
| 75 | 
            +
                Dir.glob("#{path}/specifications/**/*.md").each do |f|
         | 
| 76 | 
            +
                  DocFabric.add_lazy_doc_id(f)
         | 
| 77 | 
            +
                end
         | 
| 78 | 
            +
                # parse documents in the second pass
         | 
| 79 | 
            +
                Dir.glob("#{path}/specifications/**/*.md").each do |f| # rubocop:disable Style/CombinableLoops
         | 
| 80 | 
            +
                  doc = DocFabric.create_specification(f)
         | 
| 81 | 
            +
                  @specifications.append(doc)
         | 
| 82 | 
            +
                  @specifications_dictionary[doc.id.to_s.downcase] = doc
         | 
| 83 | 
            +
                end
         | 
| 84 | 
            +
              end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
              def parse_all_protocols
         | 
| 87 | 
            +
                path = @configuration.project_root_directory
         | 
| 88 | 
            +
                Dir.glob("#{path}/tests/protocols/**/*.md").each do |f|
         | 
| 89 | 
            +
                  doc = DocFabric.create_protocol(f)
         | 
| 90 | 
            +
                  @protocols.append(doc)
         | 
| 91 | 
            +
                end
         | 
| 92 | 
            +
              end
         | 
| 93 | 
            +
             | 
| 94 | 
            +
              def parse_test_run(test_run)
         | 
| 95 | 
            +
                path = @configuration.project_root_directory
         | 
| 96 | 
            +
                Dir.glob("#{path}/tests/runs/#{test_run}/**/*.md").each do |f|
         | 
| 97 | 
            +
                  doc = DocFabric.create_protocol(f)
         | 
| 98 | 
            +
                  @protocols.append(doc)
         | 
| 99 | 
            +
                end
         | 
| 100 | 
            +
              end
         | 
| 101 | 
            +
             | 
| 102 | 
            +
              def link_all_specifications # rubocop:disable Metrics/MethodLength
         | 
| 103 | 
            +
                comb_list = @specifications.combination(2)
         | 
| 104 | 
            +
                comb_list.each do |c|
         | 
| 105 | 
            +
                  link_two_specifications(c[0], c[1])
         | 
| 106 | 
            +
                  # puts "Link: #{c[0].id} - #{c[1].id}"
         | 
| 107 | 
            +
                end
         | 
| 108 | 
            +
                # separatelly create design inputs treceability
         | 
| 109 | 
            +
                @configuration.get_design_inputs.each do |i|
         | 
| 110 | 
            +
                  next unless @specifications_dictionary.key? i.to_s.downcase
         | 
| 111 | 
            +
             | 
| 112 | 
            +
                  document = @specifications_dictionary[i.to_s.downcase]
         | 
| 113 | 
            +
                  if document
         | 
| 114 | 
            +
                    doc = DocFabric.create_traceability_document(document, nil)
         | 
| 115 | 
            +
                    @traceability_matrices.append doc
         | 
| 116 | 
            +
                  end
         | 
| 117 | 
            +
                end
         | 
| 118 | 
            +
              end
         | 
| 119 | 
            +
             | 
| 120 | 
            +
              def link_all_protocols # rubocop:disable Metrics/MethodLength
         | 
| 121 | 
            +
                @protocols.each do |p|
         | 
| 122 | 
            +
                  @specifications.each do |s|
         | 
| 123 | 
            +
                    if p.up_link_docs.key?(s.id.to_s)
         | 
| 124 | 
            +
                      link_protocol_to_spec(p, s)
         | 
| 125 | 
            +
                      @covered_specifications_dictionary[s.id.to_s] = s
         | 
| 126 | 
            +
                    end
         | 
| 127 | 
            +
                  end
         | 
| 128 | 
            +
                end
         | 
| 129 | 
            +
                # create coverage documents
         | 
| 130 | 
            +
                @covered_specifications_dictionary.each do |_key, value|
         | 
| 131 | 
            +
                  doc = DocFabric.create_coverage_matrix(value)
         | 
| 132 | 
            +
                  @coverage_matrices.append doc
         | 
| 133 | 
            +
                end
         | 
| 134 | 
            +
              end
         | 
| 135 | 
            +
             | 
| 136 | 
            +
              def check_wrong_specification_referenced # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
         | 
| 137 | 
            +
                available_specification_ids = {}
         | 
| 138 | 
            +
             | 
| 139 | 
            +
                @specifications.each do |s|
         | 
| 140 | 
            +
                  available_specification_ids[s.id.to_s.downcase] = s
         | 
| 141 | 
            +
                end
         | 
| 142 | 
            +
             | 
| 143 | 
            +
                @specifications.each do |s| # rubocop:disable Style/CombinableLoops
         | 
| 144 | 
            +
                  s.up_link_docs.each do |key, _value|
         | 
| 145 | 
            +
                    next if available_specification_ids.key?(key)
         | 
| 146 | 
            +
             | 
| 147 | 
            +
                    # now key points to the doc_id that does not exist
         | 
| 148 | 
            +
                    wrong_doc_id = key
         | 
| 149 | 
            +
                    # find the item that reference to it
         | 
| 150 | 
            +
                    s.controlled_items.each do |item|
         | 
| 151 | 
            +
                      next if item.up_link_ids.nil?
         | 
| 152 | 
            +
             | 
| 153 | 
            +
                      item.up_link_ids.each do |up_link_id|
         | 
| 154 | 
            +
                        next unless tmp = /^([a-zA-Z]+)-\d+/.match(up_link_id) # SRS
         | 
| 155 | 
            +
             | 
| 156 | 
            +
                        if tmp[1].downcase == wrong_doc_id
         | 
| 157 | 
            +
                          # we got it finally!
         | 
| 158 | 
            +
                          s.wrong_links_hash[up_link_id.to_s] = item
         | 
| 159 | 
            +
                        end
         | 
| 160 | 
            +
                      end
         | 
| 161 | 
            +
                    end
         | 
| 162 | 
            +
                  end
         | 
| 163 | 
            +
                end
         | 
| 164 | 
            +
              end
         | 
| 165 | 
            +
             | 
| 166 | 
            +
              def link_two_specifications(doc_a, doc_b) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
         | 
| 167 | 
            +
                if doc_b.up_link_docs.key?(doc_a.id.to_s)
         | 
| 168 | 
            +
                  top_document = doc_a
         | 
| 169 | 
            +
                  bottom_document = doc_b
         | 
| 170 | 
            +
                elsif doc_a.up_link_docs.key?(doc_b.id.to_s)
         | 
| 171 | 
            +
                  top_document = doc_b
         | 
| 172 | 
            +
                  bottom_document = doc_a
         | 
| 173 | 
            +
                else
         | 
| 174 | 
            +
                  return # no links
         | 
| 175 | 
            +
                end
         | 
| 176 | 
            +
                # puts "Link: #{doc_a.id} - #{doc_b.id}"
         | 
| 177 | 
            +
                bottom_document.controlled_items.each do |item|
         | 
| 178 | 
            +
                  next unless item.up_link_ids
         | 
| 179 | 
            +
             | 
| 180 | 
            +
                  item.up_link_ids.each do |up_lnk|
         | 
| 181 | 
            +
                    if top_document.dictionary.key?(up_lnk.to_s)
         | 
| 182 | 
            +
             | 
| 183 | 
            +
                      top_item = top_document.dictionary[up_lnk.to_s]
         | 
| 184 | 
            +
             | 
| 185 | 
            +
                      unless top_item.down_links
         | 
| 186 | 
            +
                        top_item.down_links = []
         | 
| 187 | 
            +
                        top_document.items_with_downlinks_number += 1 # for statistics
         | 
| 188 | 
            +
                      end
         | 
| 189 | 
            +
                      top_item.down_links.append(item)
         | 
| 190 | 
            +
                    elsif tmp = /^([a-zA-Z]+)-\d+/.match(up_lnk)
         | 
| 191 | 
            +
                      # check if there is a non existing link with the right doc_id
         | 
| 192 | 
            +
                      if tmp[1].downcase == top_document.id.downcase
         | 
| 193 | 
            +
                        bottom_document.wrong_links_hash[up_lnk] = item
         | 
| 194 | 
            +
                      end # SRS
         | 
| 195 | 
            +
                    end
         | 
| 196 | 
            +
                  end
         | 
| 197 | 
            +
                end
         | 
| 198 | 
            +
                # create treceability document
         | 
| 199 | 
            +
                doc = DocFabric.create_traceability_document(top_document, bottom_document)
         | 
| 200 | 
            +
                @traceability_matrices.append doc
         | 
| 201 | 
            +
              end
         | 
| 202 | 
            +
             | 
| 203 | 
            +
              def link_protocol_to_spec(protocol, specification) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
         | 
| 204 | 
            +
                top_document = specification
         | 
| 205 | 
            +
                bottom_document = protocol
         | 
| 206 | 
            +
             | 
| 207 | 
            +
                bottom_document.controlled_items.each do |item|
         | 
| 208 | 
            +
                  next unless item.up_link_ids
         | 
| 209 | 
            +
             | 
| 210 | 
            +
                  item.up_link_ids.each do |up_lnk|
         | 
| 211 | 
            +
                    if top_document.dictionary.key?(up_lnk.to_s)
         | 
| 212 | 
            +
             | 
| 213 | 
            +
                      top_item = top_document.dictionary[up_lnk.to_s]
         | 
| 214 | 
            +
             | 
| 215 | 
            +
                      unless top_item.coverage_links
         | 
| 216 | 
            +
                        top_item.coverage_links = []
         | 
| 217 | 
            +
                        top_document.items_with_coverage_number += 1 # for statistics
         | 
| 218 | 
            +
                      end
         | 
| 219 | 
            +
                      top_item.coverage_links.append(item)
         | 
| 220 | 
            +
                    elsif tmp = /^([a-zA-Z]+)-\d+/.match(up_lnk)
         | 
| 221 | 
            +
                      # check if there is a non existing link with the right doc_id
         | 
| 222 | 
            +
                      if tmp[1].downcase == top_document.id.downcase
         | 
| 223 | 
            +
                        bottom_document.wrong_links_hash[up_lnk] = item
         | 
| 224 | 
            +
                      end # SRS
         | 
| 225 | 
            +
                    end
         | 
| 226 | 
            +
                  end
         | 
| 227 | 
            +
                end
         | 
| 228 | 
            +
              end
         | 
| 229 | 
            +
             | 
| 230 | 
            +
              def create_index
         | 
| 231 | 
            +
                @index = Index.new(@project)
         | 
| 232 | 
            +
              end
         | 
| 233 | 
            +
             | 
| 234 | 
            +
              def render_all_specifications(spec_list) # rubocop:disable Metrics/MethodLength
         | 
| 235 | 
            +
                path = @configuration.project_root_directory
         | 
| 236 | 
            +
             | 
| 237 | 
            +
                FileUtils.mkdir_p("#{path}/build/specifications")
         | 
| 238 | 
            +
             | 
| 239 | 
            +
                spec_list.each do |doc|
         | 
| 240 | 
            +
                  doc.to_console
         | 
| 241 | 
            +
             | 
| 242 | 
            +
                  img_src_dir = "#{path}/specifications/#{doc.id}/img"
         | 
| 243 | 
            +
                  img_dst_dir = "#{path}/build/specifications/#{doc.id}/img"
         | 
| 244 | 
            +
             | 
| 245 | 
            +
                  FileUtils.mkdir_p(img_dst_dir)
         | 
| 246 | 
            +
             | 
| 247 | 
            +
                  FileUtils.copy_entry(img_src_dir, img_dst_dir) if File.directory?(img_src_dir)
         | 
| 248 | 
            +
             | 
| 249 | 
            +
                  nav_pane = NavigationPane.new(doc)
         | 
| 250 | 
            +
                  doc.to_html(nav_pane, "#{path}/build/specifications/")
         | 
| 251 | 
            +
                end
         | 
| 252 | 
            +
              end
         | 
| 253 | 
            +
             | 
| 254 | 
            +
              def render_all_protocols
         | 
| 255 | 
            +
                path = @configuration.project_root_directory
         | 
| 256 | 
            +
             | 
| 257 | 
            +
                FileUtils.mkdir_p("#{path}/build/tests/protocols")
         | 
| 258 | 
            +
             | 
| 259 | 
            +
                @protocols.each do |doc|
         | 
| 260 | 
            +
                  img_src_dir = "#{path}/tests/protocols/#{doc.id}/img"
         | 
| 261 | 
            +
                  img_dst_dir = "#{path}/build/tests/protocols/#{doc.id}/img"
         | 
| 262 | 
            +
             | 
| 263 | 
            +
                  FileUtils.mkdir_p(img_dst_dir)
         | 
| 264 | 
            +
             | 
| 265 | 
            +
                  FileUtils.copy_entry(img_src_dir, img_dst_dir) if File.directory?(img_src_dir)
         | 
| 266 | 
            +
             | 
| 267 | 
            +
                  nav_pane = NavigationPane.new(doc)
         | 
| 268 | 
            +
                  doc.to_html(nav_pane, "#{path}/build/tests/protocols/")
         | 
| 269 | 
            +
                end
         | 
| 270 | 
            +
              end
         | 
| 271 | 
            +
             | 
| 272 | 
            +
              def render_index
         | 
| 273 | 
            +
                path = @configuration.project_root_directory
         | 
| 274 | 
            +
             | 
| 275 | 
            +
                doc = @index
         | 
| 276 | 
            +
                doc.to_console
         | 
| 277 | 
            +
             | 
| 278 | 
            +
                doc.to_html("#{path}/build/")
         | 
| 279 | 
            +
              end
         | 
| 280 | 
            +
             | 
| 281 | 
            +
              def create_search_data
         | 
| 282 | 
            +
                db = SpecificationsDb.new @specifications
         | 
| 283 | 
            +
                data_path = "#{@configuration.project_root_directory}/build/data"
         | 
| 284 | 
            +
                FileUtils.mkdir_p(data_path)
         | 
| 285 | 
            +
                db.save(data_path)
         | 
| 286 | 
            +
              end
         | 
| 287 | 
            +
            end
         |