Class: Ruboty::Docker::Actions::Top

Inherits:
Base
  • Object
show all
Defined in:
lib/ruboty/docker/actions/top.rb

Constant Summary

Constants inherited from Base

Base::NAMESPACE

Instance Attribute Summary

Attributes inherited from Base

#message

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Ruboty::Docker::Actions::Base

Instance Method Details

#callObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ruboty/docker/actions/top.rb', line 5

def call
    container = message[:container_name]
    top  = ::Docker::Container.get(container).top
    rows = []
    top.each do |t|
        rows.push [t['PID'], t['USER'], t['COMMAND']]
    end
    table       = ::Terminal::Table.new title: 'CONTAINER TOP', headings: ['PID', 'USER', 'COMMAND'], rows: rows
    table.style = { :padding_left => 0, :border_x => '', :border_y => ' ', :border_i => '' }
    message.reply(table, code: true)
rescue => e
    value = [e.class.name, e.message].join("\n")
    message.reply value
ensure
end