lib/toadhopper.rb in toadhopper-0.9.4 vs lib/toadhopper.rb in toadhopper-0.9.5

- old
+ new

@@ -3,11 +3,11 @@ require 'haml/engine' require 'nokogiri' # Posts errors to the Hoptoad API class ToadHopper - VERSION = "0.9.4" + VERSION = "0.9.5" # Hoptoad API response class Response < Struct.new(:status, :body, :errors); end attr_reader :api_key @@ -76,14 +76,18 @@ end end # @private def document_for(exception, options={}) + Haml::Engine.new(notice_template, :escape_html => true).render(Object.new, filtered_data(exception, options)) + end + + def filtered_data(exception, options) defaults = { :error => exception, :api_key => api_key, - :environment => clean(ENV.to_hash), + :environment => ENV.to_hash, :backtrace => exception.backtrace.map {|l| backtrace_line(l)}, :url => 'http://localhost/', :component => 'http://localhost/', :action => nil, :request => nil, @@ -92,11 +96,17 @@ :session => {}, :framework_env => ENV['RACK_ENV'] || 'development', :project_root => Dir.pwd }.merge(options) - Haml::Engine.new(notice_template, :escape_html => true).render(Object.new, defaults) + # Filter session and environment + [:session, :environment].each{|n| defaults[n] = clean(defaults[n]) if defaults[n] } + + # Filter params + defaults[:request].params = clean(defaults[:request].params) if defaults[:request] && defaults[:request].params + + defaults end # @private def backtrace_line(line) Struct.new(:file, :number, :method).new(*line.match(%r{^([^:]+):(\d+)(?::in `([^']+)')?$}).captures) @@ -133,6 +143,6 @@ # Convenience method for creating ToadHoppers # # @return [ToadHopper] def ToadHopper(api_key) ToadHopper.new(api_key) -end \ No newline at end of file +end