Sha256: 516266c30092d634613f676c53ebe1bb2913d0d9f337354b1c650d53288e4655

Contents?: true

Size: 1.59 KB

Versions: 17

Compression:

Stored size: 1.59 KB

Contents

require 'opsicle/deployments'

module Opsicle
  module Monitor
    module Spy
      class Deployments

        include Spy::Dataspyable

        def initialize
          @deployments = Opsicle::Deployments.new(Opsicle::Monitor::App.client)
          refresh
        end

        def refresh
          h = []

          @deployments.data.each do |deployment|
            # Massage the API data for our uses
            h << {
              :deployment_id => deployment[:deployment_id],
              :stack_id      => deployment[:stack_id],
              :app_id        => deployment[:app_id],
              :created_at    => format_date(deployment[:created_at]),
              :completed_at  => format_date(deployment[:completed_at]),
              :duration      => deployment[:duration],
              :user          => user_from_arn(deployment[:iam_user_arn]),
              :comment       => deployment[:comment],
              :command       => deployment[:command][:name],
              :name          => deployment[:name],
              :args          => deployment[:args],
              :value         => deployment[:value],
              :status        => deployment[:status],
              :custom_json   => deployment[:custom_json],
              :instance_ids  => deployment[:instance_ids]
            }
          end

          @data = h
        end

        def user_from_arn(amazon_resource_name)
          /(?::user\/)?([^:\n]+)$/.match(amazon_resource_name).to_a[1].to_s
        end

        def format_date(date)
          date ? Time.parse(date).strftime("%T %m/%d") : ""
        end

      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
opsicle-0.11.0 lib/opsicle/monitor/spy/deployments.rb
opsicle-0.10.0 lib/opsicle/monitor/spy/deployments.rb
opsicle-0.9.0 lib/opsicle/monitor/spy/deployments.rb
opsicle-0.8.2 lib/opsicle/monitor/spy/deployments.rb
opsicle-0.8.1 lib/opsicle/monitor/spy/deployments.rb
opsicle-0.8.0 lib/opsicle/monitor/spy/deployments.rb
opsicle-0.7.1 lib/opsicle/monitor/spy/deployments.rb
opsicle-0.7.0 lib/opsicle/monitor/spy/deployments.rb
opsicle-0.6.0 lib/opsicle/monitor/spy/deployments.rb
opsicle-0.5.1 lib/opsicle/monitor/spy/deployments.rb
opsicle-0.5.0 lib/opsicle/monitor/spy/deployments.rb
opsicle-0.4.2 lib/opsicle/monitor/spy/deployments.rb
opsicle-0.4.0 lib/opsicle/monitor/spy/deployments.rb
opsicle-0.3.1 lib/opsicle/monitor/spy/deployments.rb
opsicle-0.3.0 lib/opsicle/monitor/spy/deployments.rb
opsicle-0.2.1 lib/opsicle/monitor/spy/deployments.rb
opsicle-0.2.0 lib/opsicle/monitor/spy/deployments.rb