Sha256: 2735ad9e919231872b12cfa7d9ef7d5790f769e5e5334efdbd35bada10bc528f

Contents?: true

Size: 987 Bytes

Versions: 1

Compression:

Stored size: 987 Bytes

Contents

require 'sidekiq/web'

module Sidetiq
  module Web
    def self.registered(app)
      app.helpers do
        def find_template(view, *args, &block)
          path = File.expand_path(File.join('..', 'views'), __FILE__)
          super(path, *args, &block)
          super
        end
      end

      app.get "/sidetiq" do
        clock = Sidetiq::Clock.instance
        @schedules = clock.schedules
        @time = clock.gettime
        slim :sidetiq
      end

      app.get "/sidetiq/:name" do
        halt 404 unless (name = params[:name])

        clock = Sidetiq::Clock.instance
        schedules = clock.schedules

        @time = clock.gettime

        @worker, @schedule = schedules.select do |worker, schedule|
          worker.name == name
        end.flatten

        slim :sidetiq_details
      end
    end
  end
end

Sidekiq::Web.register(Sidetiq::Web)

if Sidekiq::Web.tabs.is_a?(Array)
  Sidekiq::Web.tabs << "sidetiq"
else
  Sidekiq::Web.tabs["Sidetiq"] = "sidetiq"
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sidetiq-0.1.3 lib/sidetiq/web.rb