Sha256: 9eac6d133566fc6a1dd44de429a9d68c9901cf14f87d2477f13eb2787f44459c

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

require 'resque-dynamic-queues'

module Resque
  module Plugins
    module DynamicQueues
      module Server

        VIEW_PATH = File.join(File.dirname(__FILE__), 'server', 'views')

        def self.registered(app)
          app.get "/dynamicqueues" do
            @queues = Resque.get_dynamic_queues
            dq_view :queues
          end

          app.post "/dynamicqueues" do
            key    = params['name']
            values = params['queues'].to_s.split.collect{|q| q.gsub(/\s/, '')}
            Resque.set_dynamic_queue(key, values)
            redirect url(:dynamicqueues)
          end

          app.post "/dynamicqueues/:key/remove" do
            key    = params['key']
            Resque.set_dynamic_queue(key, [])
            redirect url(:dynamicqueues)
          end

          app.helpers do
            def dq_view(filename, options = {}, locals = {})
              erb(File.read(File.join(::Resque::Plugins::DynamicQueues::Server::VIEW_PATH, "#{filename}.erb")), options, locals)
            end
          end

          app.tabs << "DynamicQueues"
        end
      end
    end
  end
end

Resque::Server.register Resque::Plugins::DynamicQueues::Server

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
resque-dynamic-queues-0.6.1 lib/resque/plugins/dynamic_queues/server.rb
resque-dynamic-queues-0.6.0 lib/resque/plugins/dynamic_queues/server.rb