Sha256: 4b13a1894e71adfa658bbf037aedf83166654ac865dde85b596b466a4fbc270d

Contents?: true

Size: 954 Bytes

Versions: 1

Compression:

Stored size: 954 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
          }
        },
        {'X-Hoptoad-Client-Name'    => 'toadhopper-sinatra'}
      )
    end
  end
  def self.registered(app)
    app.set :hoptoad, {}
  end
  helpers Toadhopper
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
toadhopper-sinatra-0.6 lib/sinatra/toadhopper.rb