Sha256: c29429fe97313e4e45586fdd0be921d8192afd138b2c253fce10d5bf770cb284

Contents?: true

Size: 1.22 KB

Versions: 23

Compression:

Stored size: 1.22 KB

Contents

module Honeybadger
  module Init
    module Sinatra
      ::Sinatra::Base.class_eval do
        class << self
          def build_with_honeybadger(*args, &block)
            install_honeybadger
            build_without_honeybadger(*args, &block)
          end
          alias :build_without_honeybadger :build
          alias :build :build_with_honeybadger

          def honeybadger_config(app)
            {
              api_key: defined?(honeybadger_api_key) ? honeybadger_api_key : nil
            }
          end

          def install_honeybadger
            config = Honeybadger::Config.new(honeybadger_config(self))

            return unless config[:'sinatra.enabled']
            return unless Honeybadger.start(config)

            install_honeybadger_middleware(Honeybadger::Rack::ErrorNotifier, config) if config.feature?(:notices) && config[:'exceptions.enabled']
            install_honeybadger_middleware(Honeybadger::Rack::MetricsReporter, config) if config.feature?(:metrics) && config[:'metrics.enabled']
          end

          def install_honeybadger_middleware(klass, config)
            return if middleware.any? {|m| m[0] == klass }
            use(klass, config)
          end
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
honeybadger-2.6.1 lib/honeybadger/init/sinatra.rb
honeybadger-2.6.0 lib/honeybadger/init/sinatra.rb
honeybadger-2.5.3 lib/honeybadger/init/sinatra.rb
honeybadger-2.5.2 lib/honeybadger/init/sinatra.rb
honeybadger-2.5.1 lib/honeybadger/init/sinatra.rb
honeybadger-2.5.0 lib/honeybadger/init/sinatra.rb
honeybadger-2.4.1 lib/honeybadger/init/sinatra.rb
honeybadger-2.4.0 lib/honeybadger/init/sinatra.rb
honeybadger-2.3.3 lib/honeybadger/init/sinatra.rb
honeybadger-2.3.2 lib/honeybadger/init/sinatra.rb
honeybadger-2.3.2.beta.1 lib/honeybadger/init/sinatra.rb
honeybadger-2.3.1 lib/honeybadger/init/sinatra.rb
honeybadger-2.3.0 lib/honeybadger/init/sinatra.rb
honeybadger-2.2.0 lib/honeybadger/init/sinatra.rb
honeybadger-2.2.0.beta.1 lib/honeybadger/init/sinatra.rb
honeybadger-2.1.6.beta.1 lib/honeybadger/init/sinatra.rb
honeybadger-2.1.5 lib/honeybadger/init/sinatra.rb
honeybadger-2.1.4 lib/honeybadger/init/sinatra.rb
honeybadger-2.1.3 lib/honeybadger/init/sinatra.rb
honeybadger-2.1.1 lib/honeybadger/init/sinatra.rb