Sha256: d452729e50ce39e7823d01506e055d6f4eec27a3c2749e99e1713834e0be450b

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 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_private_ip_addresses
      }
    end

    def instances_private_ip_addresses
      stack_reader.instances.map do |i| 
        i['instancesSet'].first['privateIpAddress'] if i['instancesSet'].first['privateIpAddress']
      end
    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

1 entries across 1 versions & 1 rubygems

Version Path
stackster-0.1.3 lib/stackster/stack/stack_formater.rb