Skip to content

Commit

Permalink
Merge pull request #34 from oggy/master
Browse files Browse the repository at this point in the history
Collection of fixes for ruby 1.9 and mysql2
  • Loading branch information
lukemelia committed May 10, 2011
2 parents 5af9fc7 + 46b1b54 commit 1698c26
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/rack/bug/filtered_backtrace.rb
Expand Up @@ -19,7 +19,7 @@ def filtered_backtrace

def root_for_backtrace_filtering(sub_path = nil)
if defined?(Rails) && Rails.respond_to?(:root)
sub_path ? Rails.root.join(sub_path) : Rails.root
(sub_path ? Rails.root.join(sub_path) : Rails.root).to_s
else
root = if defined?(RAILS_ROOT)
RAILS_ROOT
Expand Down
11 changes: 7 additions & 4 deletions lib/rack/bug/panels/templates_panel.rb
Expand Up @@ -7,12 +7,15 @@ class TemplatesPanel < Panel
autoload :Trace, "rack/bug/panels/templates_panel/trace"
autoload :Rendering, "rack/bug/panels/templates_panel/rendering"

def self.record(template, &block)
return block.call unless Rack::Bug.enabled?
def self.record(template)
return yield unless Rack::Bug.enabled?

template_trace.start(template)
result = block.call
template_trace.finished(template)
begin
result = yield
ensure
template_trace.finished(template)
end
return result
end

Expand Down
1 change: 1 addition & 0 deletions lib/rack/bug/render.rb
@@ -1,3 +1,4 @@
# encoding: utf-8
require "erb"

module Rack
Expand Down
10 changes: 8 additions & 2 deletions lib/rack/bug/views/panels/execute_sql.html.erb
Expand Up @@ -13,8 +13,14 @@
<table class="sortable">
<thead>
<tr>
<% result.fetch_fields.each do |field| %>
<th><%= field.name.upcase %></th>
<% if defined?(Mysql2) %>
<% result.fields.each do |field| %>
<th><%= field.upcase %></th>
<% end %>
<% else %>
<% result.fetch_fields.each do |field| %>
<th><%= field.name.upcase %></th>
<% end %>
<% end %>
</tr>
</thead>
Expand Down
12 changes: 9 additions & 3 deletions lib/rack/bug/views/panels/explain_sql.html.erb
Expand Up @@ -13,10 +13,16 @@
<table class="sortable">
<thead>
<tr>
<% result.fetch_fields.each do |field| %>
<th><%= field.name.upcase %></th>
<% if defined?(Mysql2) %>
<% result.fields.each do |field| %>
<th><%= field.upcase %></th>
<% end %>
<% else %>
<% result.fetch_fields.each do |field| %>
<th><%= field.name.upcase %></th>
<% end %>
<% end %>
</tr>
</tr>
</thead>
<tbody>
<% i = 1 %>
Expand Down
10 changes: 8 additions & 2 deletions lib/rack/bug/views/panels/profile_sql.html.erb
Expand Up @@ -13,8 +13,14 @@
<table class="sortable">
<thead>
<tr>
<% result.fetch_fields.each do |field| %>
<th><%= field.name.upcase %></th>
<% if defined?(Mysql2) %>
<% result.fields.each do |field| %>
<th><%= field.upcase %></th>
<% end %>
<% else %>
<% result.fetch_fields.each do |field| %>
<th><%= field.name.upcase %></th>
<% end %>
<% end %>
</tr>
</thead>
Expand Down

0 comments on commit 1698c26

Please sign in to comment.