ulg 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/ulg +1 -1
- data/lib/ulg.rb +24 -18
- metadata +1 -1
data/bin/ulg
CHANGED
data/lib/ulg.rb
CHANGED
@@ -19,22 +19,22 @@ class ULG
|
|
19
19
|
@rex = []
|
20
20
|
|
21
21
|
@rex << '(?<from_open>[\[\<\(\{]*)'
|
22
|
-
@rex << '(?<from_label>[^\]\>\)\|\}
|
23
|
-
@rex << '(?<from_color>\|[^\]\>\)\} ]
|
24
|
-
@rex << '(?<from_close>[\]\>\)\}]*)
|
22
|
+
@rex << '(?<from_label>[^\]\>\)\|\}]+?)'
|
23
|
+
@rex << '(?<from_color>\|[^\]\>\)\} ]+?)?'
|
24
|
+
@rex << '(?<from_close>[\]\>\)\}]*)'
|
25
25
|
|
26
|
-
@rex << '(?<from_arrow>[\<\>ox]*)'
|
26
|
+
@rex << '\s(?<from_arrow>[\<\>ox]*)'
|
27
27
|
|
28
28
|
@rex << '(?<edge_open>[\=\-\.]+)'
|
29
|
-
@rex << '(?<edge_label>[^\=\-\|\.]
|
30
|
-
@rex << '(?<edge_color>\|[
|
29
|
+
@rex << '(?<edge_label>(?:[^\=\-\|\.][^\|]*?[^\=\-\|\.])?)'
|
30
|
+
@rex << '(?<edge_color>\|[^\=\-\|\.\ ]+)?'
|
31
31
|
@rex << '(?<edge_close>[\=\-\.]+)'
|
32
32
|
|
33
|
-
@rex << '(?<to_arrow>[\<\>ox]*)\s
|
33
|
+
@rex << '(?<to_arrow>[\<\>ox]*)\s'
|
34
34
|
|
35
35
|
@rex << '(?<to_open>[\[\<\(\{]*)'
|
36
|
-
@rex << '(?<to_label>[^\]\>\)\|\}
|
37
|
-
@rex << '(?<to_color>\|[^\]\>\)\} ]
|
36
|
+
@rex << '(?<to_label>[^\]\>\)\|\}]+?)'
|
37
|
+
@rex << '(?<to_color>\|[^\]\>\)\} ]+?)?'
|
38
38
|
@rex << '(?<to_close>[\]\>\)\}]*)'
|
39
39
|
|
40
40
|
@arrow_regex = @rex.join '\s*'
|
@@ -84,9 +84,10 @@ class ULG
|
|
84
84
|
dputs "Building to node for #{to_label} as #{to}"
|
85
85
|
to_node = g.add_nodes to_label, to_opts
|
86
86
|
|
87
|
-
|
88
|
-
|
89
|
-
|
87
|
+
@edges[from][to].keys.each do |edge|
|
88
|
+
dputs "Building edge #{edge} for #{from} #{to}"
|
89
|
+
g.add_edges from_node, to_node, @edges[from][to][edge]["attr"]
|
90
|
+
end
|
90
91
|
end
|
91
92
|
end
|
92
93
|
|
@@ -210,13 +211,18 @@ class ULG
|
|
210
211
|
from_name = label_to_name from
|
211
212
|
to_name = label_to_name to
|
212
213
|
|
213
|
-
|
214
|
+
if not label.empty?
|
215
|
+
edge_name = label_to_name label
|
216
|
+
else
|
217
|
+
edge_name = "none"
|
218
|
+
end
|
214
219
|
|
215
|
-
|
220
|
+
return if @edges.has_key? from_name and @edges[from_name].has_key? to_name and @edges[from_name][to_name].has_key? edge_name
|
216
221
|
|
217
|
-
|
218
|
-
|
219
|
-
|
222
|
+
dputs "Adding edge #{edge_name} for #{from_name} #{to_name}"
|
223
|
+
|
224
|
+
@edges[from_name] = {} unless @edges.has_key? from_name
|
225
|
+
@edges[from_name][to_name] = {} unless @edges[from_name].has_key? to_name
|
220
226
|
|
221
227
|
arrowtail = parse_arrow from_arrow
|
222
228
|
arrowhead = parse_arrow to_arrow
|
@@ -236,7 +242,7 @@ class ULG
|
|
236
242
|
color = "black"
|
237
243
|
end
|
238
244
|
|
239
|
-
@edges[from_name][to_name] = { "attr" => { "style" => style, "label" => label, "arrowtail" => arrowtail, "arrowhead" => arrowhead, "fontcolor" => color } }
|
245
|
+
@edges[from_name][to_name][edge_name] = { "attr" => { "style" => style, "label" => label, "arrowtail" => arrowtail, "arrowhead" => arrowhead, "fontcolor" => color } }
|
240
246
|
end
|
241
247
|
|
242
248
|
def parse_arrow(arrow)
|