Class: Rack::ProcessName

Inherits:
Object
  • Object
show all
Defined in:
lib/rack-process-name.rb

Defined Under Namespace

Classes: Railtie

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ProcessName

Returns a new instance of ProcessName.



5
6
7
8
# File 'lib/rack-process-name.rb', line 5

def initialize(app)
  @app = app
  @name = $0
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/rack-process-name.rb', line 10

def call(env)
  req = Rack::Request.new(env)
  info = "#{req.request_method} #{req.url}"

  set(info, "R")
  @app.call(env).tap { set(info, "S") }
rescue
  set(info, "E")
  raise
end

#set(info, state = nil) ⇒ Object



21
22
23
# File 'lib/rack-process-name.rb', line 21

def set(info, state = nil)
  $0 = "Rack: #{state} #{info}"
end