lib/sidekiq_tty.rb in sidekiq_tty-0.1.1 vs lib/sidekiq_tty.rb in sidekiq_tty-0.1.2
- old
+ new
@@ -1,31 +1,41 @@
# 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
- ss = Sidekiq::ScheduledSet.new
- jobs = ss.map { |job|
- [
- job.at,
- job.queue,
- job.item['class'],
- job.args.join(', ')
- ]
- }.reverse
+ 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)
+ 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