Module: Resque::Plugins::Aps::Server

Defined in:
lib/resque/plugins/aps/server.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/resque/plugins/aps/server.rb', line 9

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