lib/sinatra/toadhopper.rb in toadhopper-sinatra-0.7 vs lib/sinatra/toadhopper.rb in toadhopper-sinatra-0.10

- old
+ new

@@ -1,33 +1,33 @@ require 'sinatra/base' require 'toadhopper' module Sinatra # The Toadhopper helper methods - module Toadhopper + module ToadHopper + VERSION = "0.10" # Reports the current sinatra error to Hoptoad def post_error_to_hoptoad! - options.toadhopper.each_pair {|k, v| ::Toadhopper.__send__("#{k}=", v)} if options.respond_to?(:toadhopper) - unless ::Toadhopper.api_key - STDERR.puts "WARNING: Ignoring hoptoad notification - :api_key not set" - return + unless options.toadhopper && options.toadhopper[:api_key] + STDERR.puts "ToadHopper api key not set, e.g. set :toadhopper, :api_key => 'my api key'" end - ::Toadhopper.post!( + toadhopper = ToadHopper(options.toadhopper[:api_key]) + toadhopper.filters = options.toadhopper[:filters] if options.toadhopper[:filters] + toadhopper.post!( env['sinatra.error'], { - :environment => ENV, - :request => { - :params => params, - :rails_root => options.root, - :url => request.url - }, - :session => { - :key => 42, # Doesn't apply to Rack sessions - :data => session - } + :url => request.url, + :request => request, + :session => session.to_hash, + :environment => ENV.to_hash, + :framework_env => options.environment.to_s, + :project_root => options.root, + :notifier_name => (notifier_name = "toadhopper-sinatra"), + :notifier_version => VERSION, + :notifier_url => 'http://github.com/toolmantim/toadhopper-sinatra' }, - {'X-Hoptoad-Client-Name' => 'toadhopper-sinatra'} + {'X-Hoptoad-Client-Name' => notifier_name} ) end end - helpers Toadhopper + helpers ToadHopper end \ No newline at end of file