Sha256: f9ef5b51c6f29eda45470040ef3420dead40caef9c3ea160c271124612891e91

Contents?: true

Size: 881 Bytes

Versions: 5

Compression:

Stored size: 881 Bytes

Contents

require '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)
          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?
      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

Rollbar::Rake.patch!

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rollbar-1.3.2 lib/rollbar/rake.rb
rollbar-1.3.1 lib/rollbar/rake.rb
rollbar-1.3.0 lib/rollbar/rake.rb
rollbar-1.2.13 lib/rollbar/rake.rb
rollbar-1.2.12 lib/rollbar/rake.rb