Sha256: 7b9a9f1f5695860b368c299d9346eadc482bbff3896f19695a2aa170e454ecfe

Contents?: true

Size: 830 Bytes

Versions: 1

Compression:

Stored size: 830 Bytes

Contents

# frozen_string_literal: true

require 'sidekiq_tty/version'
require 'sidekiq/cli'
require 'tty-box'
require 'tty-screen'
require 'tty-table'

module SidekiqTTY
  module_function

  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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sidekiq_tty-0.1.2 lib/sidekiq_tty.rb