Sha256: cc385af54c11e6ec511c37b0301cfc4f3517c89e112d34cce2681641f147712b

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

# Extend Resque::Server to add tabs
module Resque
  module Plugins
    module Aps
  
      module Server

        def self.included(base)

          base.class_eval do

            aps_dir = File.dirname(File.expand_path(__FILE__)) + "/server/views"

            get "/aps" do
              # Is there a better way to specify alternate template locations with sinatra?
              erb File.read("#{aps_dir}/aps_applications.erb"), :resque => Resque
            end

            get "/aps/:application_name" do
              # Is there a better way to specify alternate template locations with sinatra?
              erb File.read("#{aps_dir}/notifications.erb"), :resque => Resque
            end
        
            post "/aps/:application_name" do
              Resque.enqueue(Resque::Plugins::Aps::Application, params[:application_name])
              redirect url("/aps?page_size=0")
            end
            
            post "/aps/:application_name/reset" do
              Resque.redis.set(Resque.aps_application_queued_key(params[:application_name]), 0)
              redirect url("/aps?page_size=0")
            end
            
            post "/aps/:application_name/delete" do
              Resque.delete_aps_application(params[:application_name])
              redirect url("/aps?page_size=0")
            end
          end

        end

        Resque::Server.tabs << 'APS'

      end
  
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
resque-aps-0.9.17 lib/resque/plugins/aps/server.rb