Class: Awshark::CloudFormation::StackEvents
- Inherits:
-
Object
- Object
- Awshark::CloudFormation::StackEvents
- Defined in:
- lib/awshark/cloud_formation/stack_events.rb
Instance Attribute Summary collapse
-
#last_event ⇒ Object
readonly
Returns the value of attribute last_event.
-
#stack ⇒ Object
readonly
Returns the value of attribute stack.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
Instance Method Summary collapse
- #done? ⇒ Boolean
-
#initialize(stack) ⇒ StackEvents
constructor
A new instance of StackEvents.
- #new_events ⇒ Object
- #new_events?(events) ⇒ Boolean
Constructor Details
#initialize(stack) ⇒ StackEvents
Returns a new instance of StackEvents.
9 10 11 12 |
# File 'lib/awshark/cloud_formation/stack_events.rb', line 9 def initialize(stack) @stack = stack @start_time = Time.now - 10 end |
Instance Attribute Details
#last_event ⇒ Object (readonly)
Returns the value of attribute last_event.
7 8 9 |
# File 'lib/awshark/cloud_formation/stack_events.rb', line 7 def last_event @last_event end |
#stack ⇒ Object (readonly)
Returns the value of attribute stack.
6 7 8 |
# File 'lib/awshark/cloud_formation/stack_events.rb', line 6 def stack @stack end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
7 8 9 |
# File 'lib/awshark/cloud_formation/stack_events.rb', line 7 def start_time @start_time end |
Instance Method Details
#done? ⇒ Boolean
14 15 16 17 18 19 |
# File 'lib/awshark/cloud_formation/stack_events.rb', line 14 def done? return false if last_event.nil? return false if last_event.resource_type != 'AWS::CloudFormation::Stack' last_event.resource_status.match(/IN_PROGRESS/).nil? end |
#new_events ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/awshark/cloud_formation/stack_events.rb', line 21 def new_events events = stack.events return [] if events.blank? if last_event.nil? @last_event = events.first new_events = events.select { |e| e. > start_time } return new_events end return [] unless new_events?(events) last_event_index = events.index { |e| e.event_id == last_event.event_id } new_events = events[0..last_event_index - 1] @last_event = new_events.first new_events end |
#new_events?(events) ⇒ Boolean
41 42 43 |
# File 'lib/awshark/cloud_formation/stack_events.rb', line 41 def new_events?(events) events.first.event_id != last_event.event_id end |