Sha256: f9e2c1fc7a71e5bdf64e7663338c012f0c685393be6004408d61fcb78ddc77e1

Contents?: true

Size: 1.47 KB

Versions: 26

Compression:

Stored size: 1.47 KB

Contents

require 'stacco/base'

class Stacco::Layer
  def self.load(stack, name)
    self.new(stack, name, Stacco::Resources::LayerTemplates[name])
  end

  def initialize(stack, name, config)
    @stack = stack
    @name = name.gsub(/^task-/, '')
    @is_task = (not name.scan(/^task-/).empty?)
    @config = config
  end

  def enabled?
    @stack.enabled_layer_names.include? self.name
  end

  attr_reader :stack, :name, :config

  def task?
    @is_task
  end

  def service?
    not @is_task
  end

  def to_s
    [('task' if @is_task), @name].compact.join('-')
  end

  def full_name
    [@stack.name, self.name].join('/')
  end

  def inspect
    "#<layer #{self.full_name}: #{self.resource_definitions.length} resource(s) defined>"
  end

  def has_live_resources?
    not self.resource_summaries.empty?
  end

  def state
    case [self.enabled?, self.has_live_resources?]
    when [false, false]
      :down
    when [false, true]
      :zombie
    when [true, false]
      :queued
    when [true, true]
      :healthy
    end
  end

  def condition_definitions
    @config['Conditions'] || {}
  end

  def resource_definitions
    @config['Resources'] || {}
  end

  def resource_summaries
    provided_resource_names = self.resource_definitions.keys
    @stack.resource_summaries.find_all{ |rsum| provided_resource_names.include? rsum[:logical_resource_id] }
  end

  def output_definitions
    @config['Outputs'] || {}
  end

  def parameter_definitions
    @config['Parameters'] || {}
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
stacco-0.1.70 ./lib/stacco/layer.rb
stacco-0.1.68 ./lib/stacco/layer.rb
stacco-0.1.66 ./lib/stacco/layer.rb
stacco-0.1.64 ./lib/stacco/layer.rb
stacco-0.1.63 ./lib/stacco/layer.rb
stacco-0.1.62 ./lib/stacco/layer.rb
stacco-0.1.61 ./lib/stacco/layer.rb
stacco-0.1.60 ./lib/stacco/layer.rb
stacco-0.1.59 ./lib/stacco/layer.rb
stacco-0.1.57 ./lib/stacco/layer.rb
stacco-0.1.53 ./lib/stacco/layer.rb
stacco-0.1.52 ./lib/stacco/layer.rb
stacco-0.1.50 ./lib/stacco/layer.rb
stacco-0.1.49 ./lib/stacco/layer.rb
stacco-0.1.48 ./lib/stacco/layer.rb
stacco-0.1.47 ./lib/stacco/layer.rb
stacco-0.1.46 ./lib/stacco/layer.rb
stacco-0.1.44 ./lib/stacco/layer.rb
stacco-0.1.43 ./lib/stacco/layer.rb
stacco-0.1.42 ./lib/stacco/layer.rb