Sha256: fd6a2eb56b4f67a5b239d40d9dbc631a52c0056c2a35a2ca73137c754e70fadc

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

require 'sinatra/base'
require 'toadhopper'

module Sinatra
  # The Toadhopper helper methods
  module ToadHopper
    VERSION = "0.10.1"
    # Reports the current sinatra error to Hoptoad
    def post_error_to_hoptoad!
      unless options.toadhopper && options.toadhopper[:api_key]
        STDERR.puts "ToadHopper api key not set, e.g. set :toadhopper, :api_key => 'my api key'"
        return
      end
      toadhopper = ToadHopper(options.toadhopper[:api_key])
      toadhopper.filters = options.toadhopper[:filters] if options.toadhopper[:filters]
      toadhopper.post!(
        env['sinatra.error'],
        {
          :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' => notifier_name}
      )
    end
  end
  helpers ToadHopper
end

Version data entries

1 entries across 1 versions & 1 rubygems

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