better titles
This commit is contained in:
parent
4a6dabaa0e
commit
4c2d1b89b3
|
@ -5,7 +5,7 @@ class Travis::Api::App
|
||||||
class Middleware
|
class Middleware
|
||||||
def initialize(app, title = nil)
|
def initialize(app, title = nil)
|
||||||
@app = app
|
@app = app
|
||||||
@title = title || "Rack: use #{app.class.name}"
|
@title = title || StackInstrumentation.title_for(app, :use)
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
|
@ -22,18 +22,28 @@ class Travis::Api::App
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.title_for(verb, object)
|
||||||
|
object &&= case object
|
||||||
|
when ::Sinatra::Wrapper then object.settings.inspect
|
||||||
|
when Class, Module then object.inspect
|
||||||
|
when String then object
|
||||||
|
else object.class.inspect
|
||||||
|
end
|
||||||
|
"Rack: #{verb} #{object}"
|
||||||
|
end
|
||||||
|
|
||||||
def use(*)
|
def use(*)
|
||||||
super(Middleware)
|
super(Middleware)
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
def run(app)
|
def run(app)
|
||||||
super Middleware.new(app, "Rack: run %p" % app.class)
|
super Middleware.new(app, StackInstrumentation.title_for(app, :run))
|
||||||
end
|
end
|
||||||
|
|
||||||
def map(path, &block)
|
def map(path, &block)
|
||||||
super(path) do
|
super(path) do
|
||||||
use(Middleware, "Rack: map %p" % path)
|
use(Middleware, StackInstrumentation.title_for(path, :map))
|
||||||
extend StackInstrumentation
|
extend StackInstrumentation
|
||||||
instance_eval(&block)
|
instance_eval(&block)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user