222: def extract_to_transportable
223: top = nil
224: current = nil
225: buckets = {}
226:
227: unless main = vertices.find { |res| res.type == "Class" and res.title == :main }
228: raise Puppet::DevError, "Could not find 'main' class; cannot generate catalog"
229: end
230:
231:
232:
233: bucket = nil
234: walk(main, :out) do |source, target|
235:
236: unless tmp = buckets[source.to_s]
237: if tmp = buckets[source.to_s] = source.to_trans
238: bucket = tmp
239: else
240:
241:
242:
243:
244: end
245: end
246: bucket = tmp || bucket
247: if child = target.to_trans
248: unless bucket
249: raise "No bucket created for %s" % source
250: end
251: bucket.push child
252:
253:
254:
255: unless target.builtin?
256: buckets[target.to_s] = child
257: end
258: end
259: end
260:
261:
262: unless result = buckets[main.to_s]
263:
264: result = buckets[main.to_s] = main.to_trans
265: end
266:
267: result.classes = classes
268:
269:
270: buckets.clear
271: return result
272: end