Sha256: 70a6c8c148758fe618b5218babf6358d10b9ebfa95b3deab524520dbd0306c0c
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
module Blueprints class Buildable attr_reader :name attr_accessor :namespace def initialize(name) @name, parents = parse_name(name) depends_on(*parents) Namespace.root.add_child(self) if Namespace.root end def depends_on(*scenarios) @parents = (@parents || []) + scenarios.map{|s| s.to_sym} end def build namespace.build_parent_plans build_parent_plans build_plan end protected def path @path = (namespace.path + "_" unless namespace.nil? or namespace.path.empty?).to_s + @name.to_s end def build_parent_plans @parents.each do |p| parent = begin namespace[p] rescue PlanNotFoundError Namespace.root[p] end parent.build_parent_plans parent.build_plan end end def parse_name(name) case name when Hash return name.keys.first.to_sym, [name.values.first].flatten.map{|sc| parse_name(sc).first} when Symbol, String name = name.to_sym unless name == '' return name, [] else raise TypeError, "Pass plan names as strings or symbols only, cannot build plan #{name.inspect}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
blueprints-0.3.1 | lib/blueprints/buildable.rb |