Sha256: 9ef5a5d8cb493acb844801c5ee726626fad04f4788c3c513ee8d41f94e21b25a

Contents?: true

Size: 892 Bytes

Versions: 2

Compression:

Stored size: 892 Bytes

Contents

require 'sinatra/base'
require 'toadhopper'

module Sinatra
  # The Toadhopper helper methods
  module Toadhopper
    # Reports the current sinatra error to Hoptoad
    def post_error_to_hoptoad!
      options.toadhopper.each_pair {|k, v| ::Toadhopper.__send__("#{k}=", v)}
      unless ::Toadhopper.api_key
        STDERR.puts "WARNING: Ignoring hoptoad notification - :api_key not set"
        return
      end
      ::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
          }
        }
      )
    end
  end
  def self.registered(app)
    app.set :hoptoad, {}
  end
  helpers Toadhopper
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
toadhopper-sinatra-0.5 lib/sinatra/toadhopper.rb
toadhopper-sinatra-0.4 lib/sinatra/toadhopper.rb