Sha256: e0d26ce70434c2ee9741b28f2f5b3f4ddf36ac08a9685956b50598dd0eeaaa53

Contents?: true

Size: 1.13 KB

Versions: 31

Compression:

Stored size: 1.13 KB

Contents

class Terraspace::Builder
  class Children
    include Terraspace::Util::Logging

    def initialize(mod, options={})
      @mod, @options = mod, options
      @queue = []
    end

    def build
      # Find out if current deploy stack contains dependency
      dependencies = Terraspace::Dependency::Registry.data
      root = dependencies.find do |parent_child|
        parent, _ = parent_child.split(':')
        parent == @mod.name
      end
      return unless root

      # Go down dependency graph to build a queue for processing
      name, _ = root.split(':')
      node = Terraspace::Dependency::Node.find_by(name: name)
      build_queue(node)
      logger.debug "Terraspace::Builder::Children @queue #{@queue}"

      # Process queue in reverse order to build leaf nodes first
      @queue.reverse.each do |node|
        mod = Terraspace::Mod.new(node.name, @options)
        Terraspace::Compiler::Perform.new(mod).compile
      end
    end

    # Use depth first traversal to build queue
    def build_queue(node)
      node.children.each do |child|
        @queue << child
        build_queue(child)
      end
      @queue
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
terraspace-2.2.17 lib/terraspace/builder/children.rb
terraspace-2.2.16 lib/terraspace/builder/children.rb
terraspace-2.2.15 lib/terraspace/builder/children.rb
terraspace-2.2.14 lib/terraspace/builder/children.rb
terraspace-2.2.13 lib/terraspace/builder/children.rb
terraspace-2.2.12 lib/terraspace/builder/children.rb
terraspace-2.2.11 lib/terraspace/builder/children.rb
terraspace-2.2.10 lib/terraspace/builder/children.rb
terraspace-2.2.9 lib/terraspace/builder/children.rb
terraspace-2.2.8 lib/terraspace/builder/children.rb
terraspace-2.2.7 lib/terraspace/builder/children.rb
terraspace-2.2.6 lib/terraspace/builder/children.rb
terraspace-2.2.5 lib/terraspace/builder/children.rb
terraspace-2.2.4 lib/terraspace/builder/children.rb
terraspace-2.2.3 lib/terraspace/builder/children.rb
terraspace-2.2.2 lib/terraspace/builder/children.rb
terraspace-2.2.1 lib/terraspace/builder/children.rb
terraspace-2.2.0 lib/terraspace/builder/children.rb
terraspace-2.1.7 lib/terraspace/builder/children.rb
terraspace-2.1.6 lib/terraspace/builder/children.rb