lib/toadhopper.rb in toadhopper-0.9.7 vs lib/toadhopper.rb in toadhopper-0.9.8

- old
+ new

@@ -2,11 +2,11 @@ require 'erb' require 'ostruct' # Posts errors to the Hoptoad API class ToadHopper - VERSION = "0.9.7" + VERSION = "0.9.8" # Hoptoad API response class Response < Struct.new(:status, :body, :errors); end attr_reader :api_key @@ -75,17 +75,17 @@ end end # @private def document_for(exception, options={}) - data = filtered_data(exception, options) + data = document_data(exception, options) scope = OpenStruct.new(data).extend(ERB::Util) ERB.new(notice_template, nil, '-').result(scope.send(:binding)) end - def filtered_data(error, options) - defaults = { + def document_defaults(error) + { :error => error, :api_key => api_key, :environment => ENV.to_hash, :backtrace => error.backtrace.map {|l| backtrace_line(l)}, :url => 'http://localhost/', @@ -96,18 +96,16 @@ :notifier_version => VERSION, :notifier_url => 'http://github.com/toolmantim/toadhopper', :session => {}, :framework_env => ENV['RACK_ENV'] || 'development', :project_root => Dir.pwd - }.merge(options) + } + end - # Backwards compatibility - defaults[:params] ||= defaults[:request].params if defaults[:request] - - # Filter params, session and environment - [:params, :session, :environment].each{|n| defaults[n] = clean(defaults[n]) if defaults[n] } - - defaults + def document_data(error, options) + data = document_defaults(error).merge(options) + [:params, :session, :environment].each{|n| data[n] = clean(data[n]) if data[n] } + data end # @private def backtrace_line(line) Struct.new(:file, :number, :method).new(*line.match(%r{^([^:]+):(\d+)(?::in `([^']+)')?$}).captures)