Sha256: 864383eb539986949d524f1b15cba05c1b41bed3b1c921ede09720b71201fad6

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 KB

Contents

Rollbar.plugins.define('rake') do
  dependency { !configuration.disable_monkey_patch }
  dependency { defined?(Rake) }

  module Rollbar
    module Rake
      def self.patch!
        skip_patch && return unless patch?

        ::Rake::Application.class_eval do
          alias_method :orig_display_error_message, :display_error_message

          def display_error_message(ex)
            Rollbar.error(ex, :use_exception_level_filters => true)
            orig_display_error_message(ex)
          end
        end
      end

      def self.skip_patch
        warn('[Rollbar] Rollbar is disabled for Rake tasks since your Rake version is under 0.9.x. Please upgrade to 0.9.x or higher.')
      end

      def self.patch?
        return false unless rake_version

        major, minor, = rake_version.split('.').map(&:to_i)

        major > 0 || major == 0 && minor > 8
      end

      def self.rake_version
        if Object.const_defined?('RAKEVERSION')
          return RAKEVERSION
        elsif ::Rake.const_defined?('VERSION')
          return ::Rake::VERSION
        end
      end
    end
  end

  execute do
    Rollbar::Rake.patch!
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rollbar-2.11.4 lib/rollbar/plugins/rake.rb
rollbar-2.11.3 lib/rollbar/plugins/rake.rb
rollbar-2.11.2 lib/rollbar/plugins/rake.rb
rollbar-2.11.1 lib/rollbar/plugins/rake.rb
rollbar-2.11.0 lib/rollbar/plugins/rake.rb