Module: SidekiqTTY

Defined in:
lib/sidekiq_tty.rb,
lib/sidekiq_tty/version.rb

Constant Summary collapse

VERSION =
'0.1.2'

Class Method Summary collapse

Class Method Details

.configureObject



40
41
42
43
44
# File 'lib/sidekiq_tty.rb', line 40

def configure
  Sidekiq.configure_server do |config|
    config.logger = nil
  end
end

.runObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/sidekiq_tty.rb', line 12

def run
  configure

  box = TTY::Box.frame(
    width: TTY::Screen.width,
    height: TTY::Screen.height,
    title: { top_left: 'Scheduled Jobs', bottom_right: 'v1.0' }
  ) do
    ss = Sidekiq::ScheduledSet.new
    jobs = ss.map { |job|
      [
        job.at,
        job.queue,
        job.item['class'],
        job.args.join(', ')
      ]
    }.reverse

    table = TTY::Table.new(
      ['When', 'Queue', 'Job', 'Arguments'],
      jobs
    )
    table.render(:unicode)
  end

  print box
end