Class: DocFabric

Inherits:
Object
  • Object
show all
Defined in:
lib/almirah/doc_fabric.rb

Constant Summary collapse

@@color_index =
0
@@spec_colors =
%w[cff4d2 fbeee6 ffcad4 bce6ff e4dfd9 f9e07f cbe54e d3e7ee eab595 86e3c3
ffdca2 ffffff ffdd94 d0e6a5 ffb284 f3dbcf c9bbc8 c6c09c]

Class Method Summary collapse

Class Method Details

.add_lazy_doc_id(path) ⇒ Object



14
15
16
17
18
# File 'lib/almirah/doc_fabric.rb', line 14

def self.add_lazy_doc_id(path)
  if res = /(\w+)[.]md$/.match(path)
    TextLine.add_lazy_doc_id(res[1])
  end
end

.create_coverage_matrix(specification) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/almirah/doc_fabric.rb', line 36

def self.create_coverage_matrix(specification)
  doc = Coverage.new specification
  Heading.reset_global_section_number
  doc.headings << Heading.new(doc, doc.title, 0)
  # Build dom
  doc.dom = Document.new(doc.headings)
  doc
end

.create_protocol(path) ⇒ Object



30
31
32
33
34
# File 'lib/almirah/doc_fabric.rb', line 30

def self.create_protocol(path)
  doc = Protocol.new path
  DocFabric.parse_document doc
  doc
end

.create_specification(path) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/almirah/doc_fabric.rb', line 20

def self.create_specification(path)
  color = @@spec_colors[@@color_index]
  @@color_index += 1
  @@color_index = 0 if @@color_index >= @@spec_colors.length
  doc = Specification.new path
  DocFabric.parse_document doc
  doc.color = color
  doc
end

.create_traceability_document(top_document, bottom_document) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/almirah/doc_fabric.rb', line 45

def self.create_traceability_document(top_document, bottom_document)
  doc = Traceability.new top_document, bottom_document
  Heading.reset_global_section_number
  doc.headings << Heading.new(doc, doc.title, 0)
  # Build dom
  doc.dom = Document.new(doc.headings)
  doc
end

.parse_document(doc) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/almirah/doc_fabric.rb', line 54

def self.parse_document(doc)

  file = File.open(doc.path)
  file_lines = file.readlines
  file.close

  DocParser.parse(doc, file_lines)

  # Build dom
  doc.dom = Document.new(doc.headings) if doc.is_a?(Specification) || doc.is_a?(Protocol)
end