Sha256: d251619364ccf63389e5dd3330d7ff6f0a37f0ae50c55c478e1b5f177d4e60f1

Contents?: true

Size: 1.26 KB

Versions: 6

Compression:

Stored size: 1.26 KB

Contents

module Stackster
  class StackFormater

    def initialize(args)
      @name = args[:name]
      @config = args[:config]
    end

    def display
      { 
        'attributes'      => stack_reader.attributes,
        'status'          => stack_reader.status,
        'outputs'         => stack_reader.outputs,
        'events'          => stack_reader.events,
        'resources'       => stack_reader.resources,
        'instances'       => instances_public_ip_addresses
      }
    end

    def instances_public_ip_addresses
      stack_reader.instances.map { |i| i['instancesSet'].first['ipAddress'] }
    end

    def attribute_names
      attributes.keys
    end

    def attributes
      stack_reader.attributes
    end

    def resources_summary
      stack_reader.resources.map do |i| 
        { 'LogicalResourceId' => i['LogicalResourceId'],
          'PhysicalResourceId' => i['PhysicalResourceId'] }
      end
    end

    def events_summary
      stack_reader.events.map do |i| 
        { 'ResourceStatus' => i['ResourceStatus'],
          'LogicalResourceId' => i['LogicalResourceId'] }
      end
    end

    private

    def stack_reader
      @stack_reader ||= StackReader.new :name   => @name,
                                        :config => @config
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
stackster-0.1.2 lib/stackster/stack/stack_formater.rb
stackster-0.1.1 lib/stackster/stack/stack_formater.rb
stackster-0.1.0 lib/stackster/stack/stack_formater.rb
stackster-0.0.5 lib/stackster/stack/stack_formater.rb
stackster-0.0.4 lib/stackster/stack/stack_formater.rb
stackster-0.0.3 lib/stackster/stack/stack_formater.rb