rollbar 2.20.0 → 2.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/.travis.yml +42 -16
- data/Gemfile +19 -13
- data/data/rollbar.snippet.js +1 -1
- data/gemfiles/rails30.gemfile +1 -10
- data/gemfiles/rails31.gemfile +1 -9
- data/gemfiles/rails32.gemfile +1 -9
- data/gemfiles/rails40.gemfile +1 -9
- data/gemfiles/rails41.gemfile +1 -9
- data/gemfiles/rails42.gemfile +1 -11
- data/gemfiles/rails50.gemfile +1 -11
- data/gemfiles/rails51.gemfile +1 -11
- data/gemfiles/rails52.gemfile +1 -11
- data/gemfiles/rails60.gemfile +67 -0
- data/lib/rollbar/configuration.rb +35 -1
- data/lib/rollbar/item.rb +25 -7
- data/lib/rollbar/json.rb +2 -51
- data/lib/rollbar/language_support.rb +3 -19
- data/lib/rollbar/notifier.rb +4 -6
- data/lib/rollbar/plugins/basic_socket.rb +1 -1
- data/lib/rollbar/rake_tasks.rb +3 -147
- data/lib/rollbar/request_data_extractor.rb +1 -2
- data/lib/rollbar/rollbar_test.rb +147 -0
- data/lib/rollbar/scrubbers/url.rb +0 -1
- data/lib/rollbar/truncation.rb +7 -1
- data/lib/rollbar/truncation/min_body_strategy.rb +2 -3
- data/lib/rollbar/truncation/remove_any_key_strategy.rb +123 -0
- data/lib/rollbar/truncation/remove_extra_strategy.rb +35 -0
- data/lib/rollbar/truncation/remove_request_strategy.rb +21 -0
- data/lib/rollbar/truncation/strings_strategy.rb +3 -4
- data/lib/rollbar/util.rb +2 -2
- data/lib/rollbar/util/hash.rb +15 -0
- data/lib/rollbar/version.rb +1 -1
- data/rollbar.gemspec +0 -2
- metadata +8 -20
- data/gemfiles/ruby_1_8_and_1_9_2.gemfile +0 -51
- data/lib/rollbar/json/default.rb +0 -11
- data/lib/rollbar/json/oj.rb +0 -16
| @@ -68,6 +68,7 @@ module Rollbar | |
| 68 68 | 
             
                attr_accessor :log_payload
         | 
| 69 69 |  | 
| 70 70 | 
             
                attr_reader :project_gem_paths
         | 
| 71 | 
            +
                attr_accessor :configured_options
         | 
| 71 72 |  | 
| 72 73 | 
             
                alias safely? safely
         | 
| 73 74 |  | 
| @@ -114,7 +115,7 @@ module Rollbar | |
| 114 115 | 
             
                  @locals = {}
         | 
| 115 116 | 
             
                  @scrub_fields = [:passwd, :password, :password_confirmation, :secret,
         | 
| 116 117 | 
             
                                   :confirm_password, :password_confirmation, :secret_token,
         | 
| 117 | 
            -
                                   :api_key, :access_token, :session_id]
         | 
| 118 | 
            +
                                   :api_key, :access_token, :accessToken, :session_id]
         | 
| 118 119 | 
             
                  @scrub_user = true
         | 
| 119 120 | 
             
                  @scrub_password = true
         | 
| 120 121 | 
             
                  @randomize_scrub_length = true
         | 
| @@ -142,6 +143,8 @@ module Rollbar | |
| 142 143 | 
             
                    :on_error_response => nil, # params: response
         | 
| 143 144 | 
             
                    :on_report_internal_error => nil # params: exception
         | 
| 144 145 | 
             
                  }
         | 
| 146 | 
            +
             | 
| 147 | 
            +
                  @configured_options = ConfiguredOptions.new(self)
         | 
| 145 148 | 
             
                end
         | 
| 146 149 |  | 
| 147 150 | 
             
                def initialize_copy(orig)
         | 
| @@ -153,6 +156,15 @@ module Rollbar | |
| 153 156 | 
             
                  end
         | 
| 154 157 | 
             
                end
         | 
| 155 158 |  | 
| 159 | 
            +
                def wrapped_clone
         | 
| 160 | 
            +
                  original_clone.tap do |new_config|
         | 
| 161 | 
            +
                    new_config.configured_options = ConfiguredOptions.new(new_config)
         | 
| 162 | 
            +
                    new_config.configured_options.configured = configured_options.configured
         | 
| 163 | 
            +
                  end
         | 
| 164 | 
            +
                end
         | 
| 165 | 
            +
                alias original_clone clone
         | 
| 166 | 
            +
                alias clone wrapped_clone
         | 
| 167 | 
            +
             | 
| 156 168 | 
             
                def merge(options)
         | 
| 157 169 | 
             
                  new_configuration = clone
         | 
| 158 170 | 
             
                  new_configuration.merge!(options)
         | 
| @@ -303,4 +315,26 @@ module Rollbar | |
| 303 315 | 
             
                  hook(symbol).call(*args) if hook(symbol).is_a?(Proc)
         | 
| 304 316 | 
             
                end
         | 
| 305 317 | 
             
              end
         | 
| 318 | 
            +
             | 
| 319 | 
            +
              class ConfiguredOptions
         | 
| 320 | 
            +
                attr_accessor :configuration, :configured
         | 
| 321 | 
            +
             | 
| 322 | 
            +
                def initialize(configuration)
         | 
| 323 | 
            +
                  @configuration = configuration
         | 
| 324 | 
            +
                  @configured = {}
         | 
| 325 | 
            +
                end
         | 
| 326 | 
            +
             | 
| 327 | 
            +
                def method_missing(method, *args, &block)
         | 
| 328 | 
            +
                  return super unless configuration.respond_to?(method)
         | 
| 329 | 
            +
             | 
| 330 | 
            +
                  method_string = method.to_s
         | 
| 331 | 
            +
                  configured[method_string.chomp('=').to_sym] = args.first if method_string.end_with?('=')
         | 
| 332 | 
            +
             | 
| 333 | 
            +
                  configuration.send(method, *args, &block)
         | 
| 334 | 
            +
                end
         | 
| 335 | 
            +
             | 
| 336 | 
            +
                def respond_to_missing?(method)
         | 
| 337 | 
            +
                  configuration.respond_to?(method) || super
         | 
| 338 | 
            +
                end
         | 
| 339 | 
            +
              end
         | 
| 306 340 | 
             
            end
         | 
    
        data/lib/rollbar/item.rb
    CHANGED
    
    | @@ -84,7 +84,8 @@ module Rollbar | |
| 84 84 | 
             
                    :server => server_data,
         | 
| 85 85 | 
             
                    :notifier => {
         | 
| 86 86 | 
             
                      :name => 'rollbar-gem',
         | 
| 87 | 
            -
                      :version => VERSION
         | 
| 87 | 
            +
                      :version => VERSION,
         | 
| 88 | 
            +
                      :configured_options => configured_options
         | 
| 88 89 | 
             
                    },
         | 
| 89 90 | 
             
                    :body => build_body
         | 
| 90 91 | 
             
                  }
         | 
| @@ -102,6 +103,26 @@ module Rollbar | |
| 102 103 | 
             
                  data
         | 
| 103 104 | 
             
                end
         | 
| 104 105 |  | 
| 106 | 
            +
                def configured_options
         | 
| 107 | 
            +
                  if Gem.loaded_specs['activesupport'] && Gem.loaded_specs['activesupport'].version < Gem::Version.new('4.1')
         | 
| 108 | 
            +
                    # There are too many types that crash ActiveSupport JSON serialization, and not worth
         | 
| 109 | 
            +
                    # the risk just to send this diagnostic object. In versions < 4.1, ActiveSupport hooks
         | 
| 110 | 
            +
                    # Ruby's JSON.generate so deeply there's no workaround.
         | 
| 111 | 
            +
                    'not serialized in ActiveSupport < 4.1'
         | 
| 112 | 
            +
                  elsif configuration.use_async
         | 
| 113 | 
            +
                    # Currently serialization is performed by each handler, and this invariably
         | 
| 114 | 
            +
                    # means it is actually performed by ActiveSupport.
         | 
| 115 | 
            +
                    #
         | 
| 116 | 
            +
                    # TODO: Since serialization must be done prior to scheduling the job,
         | 
| 117 | 
            +
                    # it should at least be done by rollbar-gem itself. Much work has been done
         | 
| 118 | 
            +
                    # to avoid the bugs in ActiveSupport JSON. The async handlers are currently
         | 
| 119 | 
            +
                    # still subject to all those knnown issues.
         | 
| 120 | 
            +
                    'not serialized for async/delayed handlers'
         | 
| 121 | 
            +
                  else
         | 
| 122 | 
            +
                    scrub(configuration.configured_options.configured)
         | 
| 123 | 
            +
                  end
         | 
| 124 | 
            +
                end
         | 
| 125 | 
            +
             | 
| 105 126 | 
             
                def dump
         | 
| 106 127 | 
             
                  # Ensure all keys are strings since we can receive the payload inline or
         | 
| 107 128 | 
             
                  # from an async handler job, which can be serialized.
         | 
| @@ -121,7 +142,7 @@ module Rollbar | |
| 121 142 | 
             
                  host = stringified_payload['data'].fetch('server', {})['host']
         | 
| 122 143 |  | 
| 123 144 | 
             
                  notifier.send_failsafe(
         | 
| 124 | 
            -
                    too_large_payload_string( | 
| 145 | 
            +
                    too_large_payload_string(attempts),
         | 
| 125 146 | 
             
                    nil,
         | 
| 126 147 | 
             
                    uuid,
         | 
| 127 148 | 
             
                    host
         | 
| @@ -129,12 +150,9 @@ module Rollbar | |
| 129 150 | 
             
                  logger.error("[Rollbar] Payload too large to be sent for UUID #{uuid}: #{Rollbar::JSON.dump(payload)}")
         | 
| 130 151 | 
             
                end
         | 
| 131 152 |  | 
| 132 | 
            -
                def too_large_payload_string( | 
| 133 | 
            -
                  original_size = Rollbar::JSON.dump(stringified_payload).bytesize
         | 
| 134 | 
            -
                  final_size = final_payload.bytesize
         | 
| 135 | 
            -
             | 
| 153 | 
            +
                def too_large_payload_string(attempts)
         | 
| 136 154 | 
             
                  'Could not send payload due to it being too large after truncating attempts. ' \
         | 
| 137 | 
            -
                    "Original size: #{ | 
| 155 | 
            +
                    "Original size: #{attempts.first} Attempts: #{attempts.join(', ')} Final size: #{attempts.last}"
         | 
| 138 156 | 
             
                end
         | 
| 139 157 |  | 
| 140 158 | 
             
                def ignored?
         | 
    
        data/lib/rollbar/json.rb
    CHANGED
    
    | @@ -1,13 +1,5 @@ | |
| 1 | 
            -
            require 'multi_json'
         | 
| 2 | 
            -
            require 'rollbar/json/oj'
         | 
| 3 | 
            -
            require 'rollbar/json/default'
         | 
| 4 1 | 
             
            require 'rollbar/language_support'
         | 
| 5 2 |  | 
| 6 | 
            -
            begin
         | 
| 7 | 
            -
              require 'oj'
         | 
| 8 | 
            -
            rescue LoadError
         | 
| 9 | 
            -
            end
         | 
| 10 | 
            -
             | 
| 11 3 | 
             
            module Rollbar
         | 
| 12 4 | 
             
              module JSON # :nodoc:
         | 
| 13 5 | 
             
                extend self
         | 
| @@ -15,54 +7,13 @@ module Rollbar | |
| 15 7 | 
             
                attr_writer :options_module
         | 
| 16 8 |  | 
| 17 9 | 
             
                def dump(object)
         | 
| 18 | 
            -
                  # `basic_socket` plugin addresses the following issue: https://github.com/rollbar/rollbar-gem/issues/845
         | 
| 19 10 | 
             
                  Rollbar.plugins.get('basic_socket').load_scoped!(true) do
         | 
| 20 | 
            -
                     | 
| 11 | 
            +
                    ::JSON.generate(object)
         | 
| 21 12 | 
             
                  end
         | 
| 22 13 | 
             
                end
         | 
| 23 14 |  | 
| 24 15 | 
             
                def load(string)
         | 
| 25 | 
            -
                   | 
| 26 | 
            -
                end
         | 
| 27 | 
            -
             | 
| 28 | 
            -
                def with_adapter(&block)
         | 
| 29 | 
            -
                  MultiJson.with_adapter(detect_multi_json_adapter, &block)
         | 
| 30 | 
            -
                end
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                def detect_multi_json_adapter
         | 
| 33 | 
            -
                  options = {}
         | 
| 34 | 
            -
                  options[:adapter] = :oj if defined?(::Oj)
         | 
| 35 | 
            -
             | 
| 36 | 
            -
                  MultiJson.current_adapter(options)
         | 
| 37 | 
            -
                end
         | 
| 38 | 
            -
             | 
| 39 | 
            -
                def adapter_options
         | 
| 40 | 
            -
                  options_module.options
         | 
| 41 | 
            -
                end
         | 
| 42 | 
            -
             | 
| 43 | 
            -
                def options_module
         | 
| 44 | 
            -
                  @options_module ||= find_options_module
         | 
| 45 | 
            -
                end
         | 
| 46 | 
            -
             | 
| 47 | 
            -
                def find_options_module
         | 
| 48 | 
            -
                  module_name = multi_json_adapter_module_name
         | 
| 49 | 
            -
             | 
| 50 | 
            -
                  if LanguageSupport.const_defined?(Rollbar::JSON, module_name, false)
         | 
| 51 | 
            -
                    LanguageSupport.const_get(Rollbar::JSON, module_name, false)
         | 
| 52 | 
            -
                  else
         | 
| 53 | 
            -
                    Default
         | 
| 54 | 
            -
                  end
         | 
| 55 | 
            -
                end
         | 
| 56 | 
            -
             | 
| 57 | 
            -
                # MultiJson adapters have this name structure:
         | 
| 58 | 
            -
                # "MultiJson::Adapters::{AdapterModule}"
         | 
| 59 | 
            -
                #
         | 
| 60 | 
            -
                # Ex: MultiJson::Adapters::Oj
         | 
| 61 | 
            -
                # Ex: MultiJson::Adapters::JsonGem
         | 
| 62 | 
            -
                #
         | 
| 63 | 
            -
                # In this method we just get the last module name.
         | 
| 64 | 
            -
                def multi_json_adapter_module_name
         | 
| 65 | 
            -
                  detect_multi_json_adapter.name[/^MultiJson::Adapters::(.*)$/, 1]
         | 
| 16 | 
            +
                  ::JSON.parse(string)
         | 
| 66 17 | 
             
                end
         | 
| 67 18 | 
             
              end
         | 
| 68 19 | 
             
            end
         | 
| @@ -3,27 +3,11 @@ module Rollbar | |
| 3 3 | 
             
                module_function
         | 
| 4 4 |  | 
| 5 5 | 
             
                def const_defined?(mod, target, inherit = true)
         | 
| 6 | 
            -
                   | 
| 7 | 
            -
                    mod.const_defined?(target)
         | 
| 8 | 
            -
                  else
         | 
| 9 | 
            -
                    mod.const_defined?(target, inherit)
         | 
| 10 | 
            -
                  end
         | 
| 6 | 
            +
                  mod.const_defined?(target, inherit)
         | 
| 11 7 | 
             
                end
         | 
| 12 8 |  | 
| 13 9 | 
             
                def const_get(mod, target, inherit = true)
         | 
| 14 | 
            -
                   | 
| 15 | 
            -
                    mod.const_get(target)
         | 
| 16 | 
            -
                  else
         | 
| 17 | 
            -
                    mod.const_get(target, inherit)
         | 
| 18 | 
            -
                  end
         | 
| 19 | 
            -
                end
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                def can_scrub_url?
         | 
| 22 | 
            -
                  !version?('1.8')
         | 
| 23 | 
            -
                end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                def ruby_18?
         | 
| 26 | 
            -
                  version?('1.8')
         | 
| 10 | 
            +
                  mod.const_get(target, inherit)
         | 
| 27 11 | 
             
                end
         | 
| 28 12 |  | 
| 29 13 | 
             
                def ruby_19?
         | 
| @@ -37,7 +21,7 @@ module Rollbar | |
| 37 21 | 
             
                end
         | 
| 38 22 |  | 
| 39 23 | 
             
                def timeout_exceptions
         | 
| 40 | 
            -
                  return [] if  | 
| 24 | 
            +
                  return [] if ruby_19?
         | 
| 41 25 |  | 
| 42 26 | 
             
                  [Net::ReadTimeout, Net::OpenTimeout]
         | 
| 43 27 | 
             
                end
         | 
    
        data/lib/rollbar/notifier.rb
    CHANGED
    
    | @@ -42,21 +42,21 @@ module Rollbar | |
| 42 42 | 
             
                # Similar to configure below, but used only internally within the gem
         | 
| 43 43 | 
             
                # to configure it without initializing any of the third party hooks
         | 
| 44 44 | 
             
                def preconfigure
         | 
| 45 | 
            -
                  yield(configuration)
         | 
| 45 | 
            +
                  yield(configuration.configured_options)
         | 
| 46 46 | 
             
                end
         | 
| 47 47 |  | 
| 48 48 | 
             
                # Configures the notifier instance
         | 
| 49 49 | 
             
                def configure
         | 
| 50 50 | 
             
                  configuration.enabled = true if configuration.enabled.nil?
         | 
| 51 51 |  | 
| 52 | 
            -
                  yield(configuration)
         | 
| 52 | 
            +
                  yield(configuration.configured_options)
         | 
| 53 53 | 
             
                end
         | 
| 54 54 |  | 
| 55 55 | 
             
                def reconfigure
         | 
| 56 56 | 
             
                  self.configuration = Configuration.new
         | 
| 57 57 | 
             
                  configuration.enabled = true
         | 
| 58 58 |  | 
| 59 | 
            -
                  yield(configuration)
         | 
| 59 | 
            +
                  yield(configuration.configured_options)
         | 
| 60 60 | 
             
                end
         | 
| 61 61 |  | 
| 62 62 | 
             
                def unconfigure
         | 
| @@ -557,8 +557,6 @@ module Rollbar | |
| 557 557 |  | 
| 558 558 | 
             
                  if uri.scheme == 'https'
         | 
| 559 559 | 
             
                    http.use_ssl = true
         | 
| 560 | 
            -
                    # This is needed to have 1.8.7 passing tests
         | 
| 561 | 
            -
                    http.ca_file = ENV['ROLLBAR_SSL_CERT_FILE'] if ENV.key?('ROLLBAR_SSL_CERT_FILE')
         | 
| 562 560 | 
             
                    http.verify_mode = ssl_verify_mode
         | 
| 563 561 | 
             
                  end
         | 
| 564 562 |  | 
| @@ -639,7 +637,7 @@ module Rollbar | |
| 639 637 | 
             
                end
         | 
| 640 638 |  | 
| 641 639 | 
             
                def skip_retries?
         | 
| 642 | 
            -
                  Rollbar::LanguageSupport. | 
| 640 | 
            +
                  Rollbar::LanguageSupport.ruby_19?
         | 
| 643 641 | 
             
                end
         | 
| 644 642 |  | 
| 645 643 | 
             
                def handle_response(response)
         | 
| @@ -6,7 +6,7 @@ Rollbar.plugins.define('basic_socket') do | |
| 6 6 | 
             
              # Needed to avoid active_support (< 4.1.0) bug serializing JSONs
         | 
| 7 7 | 
             
              dependency do
         | 
| 8 8 | 
             
                defined?(ActiveSupport::VERSION::STRING) &&
         | 
| 9 | 
            -
                  Gem::Version.new(ActiveSupport::VERSION::STRING) < Gem::Version.new(' | 
| 9 | 
            +
                  Gem::Version.new(ActiveSupport::VERSION::STRING) < Gem::Version.new('4.1.0')
         | 
| 10 10 | 
             
              end
         | 
| 11 11 |  | 
| 12 12 | 
             
              execute do
         | 
    
        data/lib/rollbar/rake_tasks.rb
    CHANGED
    
    | @@ -1,154 +1,10 @@ | |
| 1 | 
            -
            require 'rollbar'
         | 
| 2 | 
            -
            begin
         | 
| 3 | 
            -
              require 'rack/mock'
         | 
| 4 | 
            -
            rescue LoadError
         | 
| 5 | 
            -
              puts 'Cannot load rack/mock'
         | 
| 6 | 
            -
            end
         | 
| 7 | 
            -
            require 'logger'
         | 
| 8 1 |  | 
| 9 2 | 
             
            namespace :rollbar do
         | 
| 10 3 | 
             
              desc 'Verify your gem installation by sending a test exception to Rollbar'
         | 
| 11 4 | 
             
              task :test => [:environment] do
         | 
| 12 | 
            -
                 | 
| 13 | 
            -
             | 
| 14 | 
            -
            end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
            # Module to inject into the Rails controllers or rack apps
         | 
| 17 | 
            -
            module RollbarTest # :nodoc:
         | 
| 18 | 
            -
              def test_rollbar
         | 
| 19 | 
            -
                puts 'Raising RollbarTestingException to simulate app failure.'
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                raise RollbarTestingException.new, ::RollbarTest.success_message
         | 
| 22 | 
            -
              end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
              def self.run
         | 
| 25 | 
            -
                return unless confirmed_token?
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                configure_rails if defined?(Rails)
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                puts 'Testing manual report...'
         | 
| 30 | 
            -
                Rollbar.error('Test error from rollbar:test')
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                return unless defined?(Rack::MockRequest)
         | 
| 33 | 
            -
             | 
| 34 | 
            -
                protocol, app = setup_app
         | 
| 35 | 
            -
             | 
| 36 | 
            -
                puts 'Processing...'
         | 
| 37 | 
            -
                env = Rack::MockRequest.env_for("#{protocol}://www.example.com/verify", 'REMOTE_ADDR' => '127.0.0.1')
         | 
| 38 | 
            -
                status, = app.call(env)
         | 
| 39 | 
            -
             | 
| 40 | 
            -
                puts error_message unless status.to_i == 500
         | 
| 41 | 
            -
              end
         | 
| 42 | 
            -
             | 
| 43 | 
            -
              def self.configure_rails
         | 
| 44 | 
            -
                Rails.logger = if defined?(ActiveSupport::TaggedLogging)
         | 
| 45 | 
            -
                                 ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
         | 
| 46 | 
            -
                               else
         | 
| 47 | 
            -
                                 Logger.new(STDOUT)
         | 
| 48 | 
            -
                               end
         | 
| 49 | 
            -
             | 
| 50 | 
            -
                Rails.logger.level = Logger::DEBUG
         | 
| 51 | 
            -
                Rollbar.preconfigure do |config|
         | 
| 52 | 
            -
                  config.logger = Rails.logger
         | 
| 53 | 
            -
                end
         | 
| 54 | 
            -
              end
         | 
| 55 | 
            -
             | 
| 56 | 
            -
              def self.confirmed_token?
         | 
| 57 | 
            -
                return true if Rollbar.configuration.access_token
         | 
| 58 | 
            -
             | 
| 59 | 
            -
                puts token_error_message
         | 
| 60 | 
            -
             | 
| 61 | 
            -
                false
         | 
| 62 | 
            -
              end
         | 
| 63 | 
            -
             | 
| 64 | 
            -
              def self.authlogic_config
         | 
| 65 | 
            -
                # from http://stackoverflow.com/questions/5270835/authlogic-activation-problems
         | 
| 66 | 
            -
                return unless defined?(Authlogic)
         | 
| 67 | 
            -
             | 
| 68 | 
            -
                Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(self)
         | 
| 69 | 
            -
              end
         | 
| 70 | 
            -
             | 
| 71 | 
            -
              def self.setup_app
         | 
| 72 | 
            -
                puts 'Setting up the test app.'
         | 
| 73 | 
            -
             | 
| 74 | 
            -
                if defined?(Rails)
         | 
| 75 | 
            -
                  app = rails_app
         | 
| 5 | 
            +
                rollbar_dir = Gem.loaded_specs['rollbar'].full_gem_path
         | 
| 6 | 
            +
                require "#{rollbar_dir}/lib/rollbar/rollbar_test"
         | 
| 76 7 |  | 
| 77 | 
            -
             | 
| 78 | 
            -
             | 
| 79 | 
            -
                  authlogic_config
         | 
| 80 | 
            -
             | 
| 81 | 
            -
                  [rails_protocol(app), app]
         | 
| 82 | 
            -
                else
         | 
| 83 | 
            -
                  ['http', rack_app]
         | 
| 84 | 
            -
                end
         | 
| 85 | 
            -
              end
         | 
| 86 | 
            -
             | 
| 87 | 
            -
              def self.rails_app
         | 
| 88 | 
            -
                # The setup below is needed for Rails 5.x, but not for Rails 4.x and below.
         | 
| 89 | 
            -
                # (And fails on Rails 4.x in various ways depending on the exact version.)
         | 
| 90 | 
            -
                return Rails.application if Rails.version < '5.0.0'
         | 
| 91 | 
            -
             | 
| 92 | 
            -
                # Spring now runs by default in development on all new Rails installs. This causes
         | 
| 93 | 
            -
                # the new `/verify` route to not get picked up if `config.cache_classes == false`
         | 
| 94 | 
            -
                # which is also a default in development env.
         | 
| 95 | 
            -
                #
         | 
| 96 | 
            -
                # `config.cache_classes` needs to be set, but the only possible time is at app load,
         | 
| 97 | 
            -
                # so here we clone the default app with an updated config.
         | 
| 98 | 
            -
                #
         | 
| 99 | 
            -
                config = Rails.application.config
         | 
| 100 | 
            -
                config.cache_classes = true
         | 
| 101 | 
            -
             | 
| 102 | 
            -
                # Make a copy of the app, so the config can be updated.
         | 
| 103 | 
            -
                Rails.application.class.name.constantize.new(:config => config)
         | 
| 104 | 
            -
              end
         | 
| 105 | 
            -
             | 
| 106 | 
            -
              def self.draw_rails_route(app)
         | 
| 107 | 
            -
                app.routes_reloader.execute_if_updated
         | 
| 108 | 
            -
                app.routes.draw do
         | 
| 109 | 
            -
                  get 'verify' => 'rollbar_test#verify', :as => 'verify'
         | 
| 110 | 
            -
                end
         | 
| 111 | 
            -
              end
         | 
| 112 | 
            -
             | 
| 113 | 
            -
              def self.rails_protocol(app)
         | 
| 114 | 
            -
                defined?(app.config.force_ssl && app.config.force_ssl) ? 'https' : 'http'
         | 
| 115 | 
            -
              end
         | 
| 116 | 
            -
             | 
| 117 | 
            -
              def self.rack_app
         | 
| 118 | 
            -
                Class.new do
         | 
| 119 | 
            -
                  include RollbarTest
         | 
| 120 | 
            -
             | 
| 121 | 
            -
                  def self.call(_env)
         | 
| 122 | 
            -
                    new.test_rollbar
         | 
| 123 | 
            -
                  end
         | 
| 124 | 
            -
                end
         | 
| 125 | 
            -
              end
         | 
| 126 | 
            -
             | 
| 127 | 
            -
              def self.token_error_message
         | 
| 128 | 
            -
                'Rollbar needs an access token configured. Check the README for instructions.'
         | 
| 129 | 
            -
              end
         | 
| 130 | 
            -
             | 
| 131 | 
            -
              def self.error_message
         | 
| 132 | 
            -
                'Test failed! You may have a configuration issue, or you could be using a gem that\'s blocking the test. Contact support@rollbar.com if you need help troubleshooting.'
         | 
| 133 | 
            -
              end
         | 
| 134 | 
            -
             | 
| 135 | 
            -
              def self.success_message
         | 
| 136 | 
            -
                'Testing rollbar with "rake rollbar:test". If you can see this, it works.'
         | 
| 137 | 
            -
              end
         | 
| 138 | 
            -
            end
         | 
| 139 | 
            -
             | 
| 140 | 
            -
            class RollbarTestingException < RuntimeError; end
         | 
| 141 | 
            -
             | 
| 142 | 
            -
            if defined?(Rails)
         | 
| 143 | 
            -
              class RollbarTestController < ActionController::Base # :nodoc:
         | 
| 144 | 
            -
                include RollbarTest
         | 
| 145 | 
            -
             | 
| 146 | 
            -
                def verify
         | 
| 147 | 
            -
                  test_rollbar
         | 
| 148 | 
            -
                end
         | 
| 149 | 
            -
             | 
| 150 | 
            -
                def logger
         | 
| 151 | 
            -
                  nil
         | 
| 152 | 
            -
                end
         | 
| 8 | 
            +
                RollbarTest.run
         | 
| 153 9 | 
             
              end
         | 
| 154 10 | 
             
            end
         |