6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/almirah/source_file_parser.rb', line 6
def self.parse(doc, file_lines)
Heading.reset_global_section_number
title = "[#{doc.repository}] : #{doc.id}"
item = Heading.new(doc, title, 0)
doc.items.append(item)
doc.headings.append(item)
doc.title = title
item = Heading.new(doc, 'References', 2)
doc.items.append(item)
doc.headings.append(item)
file_lines.each do |s|
res = %r{<REQ>(.*)</REQ>}.match(s) next unless res
text = res[1].strip
up_links = nil
first_pos = text.length tmp = text.scan(/(>\[(?>[^\[\]]|\g<0>)*\])/) if tmp.length.positive?
up_links = []
tmp.each do |ul|
lnk = ul[0]
doc_id = /([a-zA-Z]+)-\d+/.match(lnk) up_links << lnk.upcase if doc_id
pos = text.index(lnk)
first_pos = pos if pos < first_pos
text = text.split(lnk, 1).join('')
end
if text.length > first_pos
first_pos -= 1
text = text[0..first_pos].strip
end
end
item = SourceCodeParagraph.new(doc, text)
if up_links
up_links.uniq! doc.items_with_uplinks_number += 1 up_links.each do |ul|
next unless tmp = />\[(\S*)\]$/.match(ul)
up_link_id = tmp[1]
item.up_link_ids = [] unless item.up_link_ids
item.up_link_ids.append(up_link_id)
if tmp = /^([a-zA-Z]+)-\d+/.match(up_link_id) doc.up_link_docs[tmp[1].downcase.to_s] = tmp[1].downcase end
end
end
doc.items.append(item)
if doc.dictionary.has_key?(item.id.to_s)
doc.duplicated_ids_number += 1
doc.duplicates_list.append(item)
else
doc.dictionary[item.id.to_s] = item end
doc.controlled_items.append(item) end
item = Heading.new(doc, 'Source Code', 2)
doc.items.append(item)
doc.headings.append(item)
end
|