Skip to content

Commit

Permalink
Starting on request variables panel
Browse files Browse the repository at this point in the history
  • Loading branch information
brynary committed Mar 16, 2009
1 parent 37a85e9 commit 1bad62e
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 2 deletions.
25 changes: 25 additions & 0 deletions lib/rack/bug/panels/request_variables_panel.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module Rack
module Bug

class RequestVariablesPanel < Panel

def name
"request_variables"
end

def before(env)
@env = env
end

def heading
"Request Vars"
end

def content
render_template "panels/requeest_variables", :env => @env
end

end

end
end
2 changes: 1 addition & 1 deletion lib/rack/bug/render.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def render_template(filename, local_assigns = {})
def compile(filename, local_assigns)
render_symbol = method_name(filename, local_assigns)

if !CompiledTemplates.method_defined?(render_symbol)
if !CompiledTemplates.instance_methods.include?(render_symbol.to_s)
compile!(filename, local_assigns)
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/rack/bug/toolbar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def public_path

def call(env)
@env = @default_options.merge(env)
@env["rack-bug.panels"] = []
@original_request = Request.new(@env)

if ip_authorized? && password_authorized?
Expand Down
19 changes: 19 additions & 0 deletions lib/rack/bug/views/panels/request_variables.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<h3>GET</h3>
<table>
<thead>
<tr>
<th>Variable</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<% i = 1 %>
<% env.sort_by { |k, v| k.to_s }.each do |key, val| %>
<tr class="<%= i % 2 == 0 ? "even" : "odd" %>">
<td><%=h key %></td>
<td class="code"><div><%=h val %></div></td>
</tr>
<% i += 1 %>
<% end %>
</tbody>
</table>
4 changes: 3 additions & 1 deletion spec/fixtures/config.ru
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require "rubygems"
require "sample_app"
require File.dirname(__FILE__) + "/../../lib/rack/bug"

$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__)) + '/../../lib'
require "rack/bug"

use Rack::Bug, :password => "secret"
run SampleApp
2 changes: 2 additions & 0 deletions spec/fixtures/sample_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class SampleApp < Sinatra::Default

<<-HTML
<html>
<head>
</head>
<body>
<p>Hello</p>
</body>
Expand Down

0 comments on commit 1bad62e

Please sign in to comment.