lib/stack_tracy/sinatra.rb in stack_tracy-0.1.3 vs lib/stack_tracy/sinatra.rb in stack_tracy-0.1.4
- old
+ new
@@ -8,14 +8,13 @@
@before_filter = before_filter if block_given?
end
def call(env)
request = ::Sinatra::Request.new env
- if request.path.match /^\/tracy-?(.*)?/
- return open($1)
+ if request.path.match /^\/tracy(-.*)?/
+ return open($1.to_s.gsub(/^-/, ""))
end
-
if @before_filter.nil? || !!@before_filter.call(request.path, request.params)
result = nil
stack_tracy @arg || Dir::tmpdir, @options do
result = @app.call(env)
end
@@ -26,10 +25,20 @@
end
private
def open(match)
- StackTracy.open match.to_s.empty? ? nil : match, (match.to_s.empty? && @arg.to_s != "dump" && !StackTracy.stack_trace.empty?)
+ if match.empty?
+ if StackTracy.stack_trace.empty?
+ StackTracy.open nil, false, @options[:threshold], @options[:limit]
+ else
+ StackTracy.dump do |file|
+ StackTracy.open file, true, @options[:threshold], @options[:limit]
+ end
+ end
+ else
+ StackTracy.open match, false, @options[:threshold], @options[:limit]
+ end
[200, {"Content-Type" => "text/html;charset=utf-8", "Content-Length" => Rack::Utils.bytesize("").to_s}, ""]
end
end
end
\ No newline at end of file