Class: Opsicle::Monitor::Spy::Deployments

Inherits:
Object
  • Object
show all
Includes:
Dataspyable
Defined in:
lib/opsicle/monitor/spy/deployments.rb

Instance Method Summary collapse

Methods included from Dataspyable

#[], #each

Constructor Details

#initializeDeployments

Returns a new instance of Deployments.



10
11
12
13
# File 'lib/opsicle/monitor/spy/deployments.rb', line 10

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

Instance Method Details

#format_date(date) ⇒ Object



47
48
49
# File 'lib/opsicle/monitor/spy/deployments.rb', line 47

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

#refreshObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/opsicle/monitor/spy/deployments.rb', line 15

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],
      :command_args  => deployment[:command][:args],
      :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

#user_from_arn(amazon_resource_name) ⇒ Object



43
44
45
# File 'lib/opsicle/monitor/spy/deployments.rb', line 43

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