class StackMaster::Commands::Events

Public Instance Methods

perform() click to toggle source
# File lib/stack_master/commands/events.rb, line 7
def perform
  events = StackEvents::Fetcher.fetch(@stack_definition.stack_name, @stack_definition.region)
  filter_events(events).each do |event|
    StackEvents::Presenter.print_event(StackMaster.stdout, event)
  end
  if @options.tail
    StackEvents::Streamer.stream(@stack_definition.stack_name, @stack_definition.region, io: StackMaster.stdout)
  end
end

Private Instance Methods

filter_events(events) click to toggle source
# File lib/stack_master/commands/events.rb, line 19
def filter_events(events)
  if @options.all
    events
  else
    n = @options.number || 25
    from = events.count - n
    if from < 0
      from = 0
    end
    events[from..-1]
  end
end