Sha256: 66ef3ee70b76a04bf7ab4bbbf127f33930fe0d69418821ab2ca41d26c1f77682
Contents?: true
Size: 1.24 KB
Versions: 3
Compression:
Stored size: 1.24 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 = self namespace.build_parent_plans while namespace = namespace.namespace 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 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
blueprints-0.3.4 | lib/blueprints/buildable.rb |
blueprints-0.3.3 | lib/blueprints/buildable.rb |
blueprints-0.3.2 | lib/blueprints/buildable.rb |