Sha256: ae0d67b98925dc8986702302f44a461cab7fdffa9384f1e02481d3c5f2c0712a

Contents?: true

Size: 939 Bytes

Versions: 2

Compression:

Stored size: 939 Bytes

Contents

require 'orange-core/middleware/base'

module Orange::Middleware
  class Debugger < Base
    def init(opts = {})
      orange.add_pulp Orange::Pulp::DebuggerHelpers if orange.options[:development_mode]
    end
    
    # Passes packet then parses the return
    def packet_call(packet)
      if orange.options[:development_mode]
        packet.session['flash.redirect_to'] = packet.request.path
        packet.add_css('debug_bar.css', :module => '_debugger_')
      end
      pass packet
      if orange.options[:development_mode]
        bar = orange[:parser].haml('debug_bar.haml', packet)
        packet[:content] = packet[:content].gsub('</body>', bar + '</body>')
      end
      packet.finish
    end
    
  end
end

module Orange::Pulp::DebuggerHelpers
  def h_debug(obj)                  # :nodoc:
    case obj
    when String
      Rack::Utils.escape_html(obj)
    else
      Rack::Utils.escape_html(obj.inspect)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
orange-0.1.8 lib/orange-more/debugger/middleware/debugger.rb
orange-0.1.7 lib/orange-more/debugger/middleware/debugger.rb