ulg 0.1.4 → 0.2.0
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.
- data/lib/ulg.rb +26 -8
- metadata +1 -1
data/lib/ulg.rb
CHANGED
@@ -70,12 +70,12 @@ class ULG
|
|
70
70
|
@edges.keys.each do |from|
|
71
71
|
@edges[from].keys.each do |to|
|
72
72
|
|
73
|
-
from_label = @nodes[from]["label"]
|
74
|
-
from_opts = @nodes[from].clone
|
73
|
+
from_label = @nodes[from]["attr"]["label"]
|
74
|
+
from_opts = @nodes[from]["attr"].clone
|
75
75
|
from_opts.delete "label"
|
76
76
|
|
77
|
-
to_label = @nodes[to]["label"]
|
78
|
-
to_opts = @nodes[to].clone
|
77
|
+
to_label = @nodes[to]["attr"]["label"]
|
78
|
+
to_opts = @nodes[to]["attr"].clone
|
79
79
|
to_opts.delete "label"
|
80
80
|
|
81
81
|
dputs "Building from node for #{from_label} as #{from}"
|
@@ -84,7 +84,7 @@ class ULG
|
|
84
84
|
to_node = g.add_nodes to_label, to_opts
|
85
85
|
|
86
86
|
dputs "Building edge for #{from} #{to}"
|
87
|
-
g.add_edges from_node, to_node, @edges[from][to]
|
87
|
+
g.add_edges from_node, to_node, @edges[from][to]["attr"]
|
88
88
|
|
89
89
|
end
|
90
90
|
end
|
@@ -137,6 +137,9 @@ class ULG
|
|
137
137
|
when /^\s*include\s+(?<file>.*)$/i
|
138
138
|
parse $~[:file]
|
139
139
|
|
140
|
+
when /^\s*clear\s+(?<node>.*)$/i
|
141
|
+
clear $~[:node]
|
142
|
+
|
140
143
|
when /^\s*#{@arrow_regex}\s*$/
|
141
144
|
from = add_node $~[:from_open], $~[:from_label], $~[:from_color], $~[:from_close]
|
142
145
|
to = add_node $~[:to_open], $~[:to_label], $~[:to_color], $~[:to_close]
|
@@ -149,12 +152,27 @@ class ULG
|
|
149
152
|
@graphviz_options[option] = value
|
150
153
|
end
|
151
154
|
|
155
|
+
def clear(node)
|
156
|
+
node.lstrip.rstrip!
|
157
|
+
name = label_to_name node
|
158
|
+
|
159
|
+
if @nodes.has_key? name
|
160
|
+
dputs "Clearing node #{node}"
|
161
|
+
@nodes[name]['cleared'] = true
|
162
|
+
@nodes[name]['attr']['shape'] = 'box'
|
163
|
+
@nodes[name]['attr']['fontcolor'] = 'black'
|
164
|
+
else
|
165
|
+
wputs "Node not found #{node}"
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
152
169
|
def add_node(open, label, color, close)
|
153
170
|
|
154
171
|
label.lstrip.rstrip!
|
155
172
|
name = label_to_name label
|
156
173
|
|
157
|
-
if @nodes.has_key? name
|
174
|
+
if @nodes.has_key? name and not @nodes[name].has_key? 'cleared'
|
175
|
+
dputs "Skipping node #{name} as already defined"
|
158
176
|
return name
|
159
177
|
end
|
160
178
|
|
@@ -177,7 +195,7 @@ class ULG
|
|
177
195
|
shape = "box"
|
178
196
|
end
|
179
197
|
|
180
|
-
@nodes[name] = { "shape" => shape, "label" => label, "fontcolor" => color }
|
198
|
+
@nodes[name] = { "attr" => { "shape" => shape, "label" => label, "fontcolor" => color } }
|
181
199
|
|
182
200
|
return name
|
183
201
|
end
|
@@ -215,7 +233,7 @@ class ULG
|
|
215
233
|
color = "black"
|
216
234
|
end
|
217
235
|
|
218
|
-
@edges[from_name][to_name] = { "style" => style, "label" => label, "arrowtail" => arrowtail, "arrowhead" => arrowhead, "fontcolor" => color }
|
236
|
+
@edges[from_name][to_name] = { "attr" => { "style" => style, "label" => label, "arrowtail" => arrowtail, "arrowhead" => arrowhead, "fontcolor" => color } }
|
219
237
|
end
|
220
238
|
|
221
239
|
def parse_arrow(arrow)
|