0
+ @last_
request = Rack::Request.new(env)0
request_started_at = Time.now
0
+ def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false)
0
+ from_time = from_time.to_time if from_time.respond_to?(:to_time)
0
+ to_time = to_time.to_time if to_time.respond_to?(:to_time)
0
+ distance_in_minutes = (((to_time - from_time).abs)/60).round
0
+ distance_in_seconds = ((to_time - from_time).abs).round
0
+ case distance_in_minutes
0
+ return (distance_in_minutes == 0) ? 'less than a minute' : '1 minute' unless include_seconds
0
+ case distance_in_seconds
0
+ when 0..4 then 'less than 5 seconds'
0
+ when 5..9 then 'less than 10 seconds'
0
+ when 10..19 then 'less than 20 seconds'
0
+ when 20..39 then 'half a minute'
0
+ when 40..59 then 'less than a minute'
0
+ when 2..44 then "#{distance_in_minutes} minutes"
0
+ when 45..89 then 'about 1 hour'
0
+ when 90..1439 then "about #{(distance_in_minutes.to_f / 60.0).round} hours"
0
+ when 1440..2879 then '1 day'
0
+ when 2880..43199 then "#{(distance_in_minutes / 1440).round} days"
0
+ when 43200..86399 then 'about 1 month'
0
+ when 86400..525599 then "#{(distance_in_minutes / 43200).round} months"
0
+ when 525600..1051199 then 'about 1 year'
0
+ else "over #{(distance_in_minutes / 525600).round} years"
0
# Taken from Rack::ShowException
0
# adapted from Django <djangoproject.com>
0
# Copyright (c) 2005, the Lawrence Journal-World
0
<h2><%= Thin::SERVER %></h2>
0
- <%= Time.now - @start_time %> uptime
0
+ <td><%= distance_of_time_in_words(@start_time, Time.now) %> (<%= Time.now - @start_time %> sec)</td>
0
+ <td><%=h Process.pid %></td>
0
+ <% if @last_request %>
0
+ <li><a href="#get-info">GET</a></li>
0
+ <li><a href="#post-info">POST</a></li>
0
+ <li><a href="#cookie-info">Cookies</a></li>
0
+ <li><a href="#env-info">ENV</a></li>
0
<td><%= @last_request_time %> sec</td>
0
- <% @last_env.sort_by { |k, v| k.to_s }.each do |key, val| %>
0
- <td class="code"><div><%=h val.inspect %></div></td>
0
+ <div id="requestinfo">
0
+ <h2>Last Request information</h2>
0
+ <h3 id="get-info">GET</h3>
0
+ <% unless @last_request.GET.empty? %>
0
+ <% @last_request.GET.sort_by { |k, v| k.to_s }.each { |key, val| %>
0
+ <td class="code"><div><%=h val.inspect %></div></td>
0
+ <h3 id="post-info">POST</h3>
0
+ <% unless @last_request.POST.empty? %>
0
+ <% @last_request.POST.sort_by { |k, v| k.to_s }.each { |key, val| %>
0
+ <td class="code"><div><%=h val.inspect %></div></td>
0
+ <h3 id="cookie-info">COOKIES</h3>
0
+ <% unless @last_request.cookies.empty? %>
0
+ <% @last_request.cookies.each { |key, val| %>
0
+ <td class="code"><div><%=h val.inspect %></div></td>
0
+ <p>No cookie data.</p>
0
+ <h3 id="env-info">Rack ENV</h3>
0
+ <% @last_request.env.sort_by { |k, v| k.to_s }.each { |key, val| %>
0
+ <td class="code"><div><%=h val %></div></td>
Comments
No one has commented yet.