Sha256: 2bdd277d2505233076749922874bfe2adab6d52626f042770767ee353aca3d2d

Contents?: true

Size: 918 Bytes

Versions: 4

Compression:

Stored size: 918 Bytes

Contents

Rake::TaskManager.record_task_metadata = true

module Bugsnag::Rake
  def self.included(base)
    base.extend ClassMethods
    base.class_eval do
      class << self
        alias_method :original_define_task, :define_task
        alias_method :define_task, :bugsnag_define_task
      end
    end
  end

  module ClassMethods
    def bugsnag_define_task(*args, &block)
      task = self.original_define_task *args do
        begin
          Bugsnag.before_notify_callbacks << lambda {|notif|
            notif.add_tab(:rake_task, {
              name: task.name,
              description: task.full_comment,
              arguments: task.arg_description
            })
            notif.context ||= task.name
          }

          yield
        rescue Exception => e
          Bugsnag.notify(e)
          raise
        end
      end
    end
  end
end

Rake::Task.send(:include, Bugsnag::Rake) if defined?(Rake::Task)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bugsnag-1.3.4 lib/bugsnag/rake.rb
bugsnag-1.3.3 lib/bugsnag/rake.rb
bugsnag-1.3.2 lib/bugsnag/rake.rb
bugsnag-1.3.1 lib/bugsnag/rake.rb