Class: Steve::Interface

Inherits:
Object
  • Object
show all
Defined in:
lib/steve/interface.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/steve/interface.rb', line 6

def call(env)
  @req = Rack::Request.new(env)
  case env['PATH_INFO'].to_s
  when ''
    [200, {'Content-type' => 'text/html'}, [haml(:index)]]
  when /failed/
    [200, {'Content-type' => 'text/html'}, [haml(:failed)]]
  when /completed/
    [200, {'Content-type' => 'text/html'}, [haml(:completed)]]
  when /object/
    @jobs = Steve::QueuedJob.where(:associated_object_type => @req.params['type'], :associated_object_id => @req.params['id']).order('created_at desc').limit(25)
    [200, {'Content-type' => 'text/html'}, [haml(:object)]]
  when /view/
    @job = Steve::QueuedJob.find(@req.params['id'])
    [200, {'Content-type' => 'text/html'}, [haml(:view)]]

  else
    path = static_path(env['PATH_INFO'])
    if File.exist?(path)
      [200, {}, [File.read(path)]]
    else
      [404, {'Content-type' => 'text/plain'}, ["Not found"]]
    end
    
  end
end