Sha256: b4a5dedb23fe6a988d672ecb57c522dc171ec8a8e45b32214c0cbf4e6085b078

Contents?: true

Size: 1.3 KB

Versions: 7

Compression:

Stored size: 1.3 KB

Contents

module RailsPerformance
  module Gems
    class RakeExt
      def self.init
        ::Rake::Task.class_eval do
          def invoke_with_rails_performance(*args)
            now = Time.current
            status = "success"
            invoke_without_new_rails_performance(*args)
          rescue Exception => ex # rubocop:disable Lint/RescueException
            status = "error"
            raise(ex)
          ensure
            if !RailsPerformance.skipable_rake_tasks.include?(name)
              task_info = RailsPerformance::Gems::RakeExt.find_task_name(*args)
              task_info = [name] if task_info.empty?
              RailsPerformance::Models::RakeRecord.new(
                task: task_info,
                datetime: now.strftime(RailsPerformance::FORMAT),
                datetimei: now.to_i,
                duration: (Time.current - now) * 1000,
                status: status
              ).save
            end
          end

          alias_method :invoke_without_new_rails_performance, :invoke
          alias_method :invoke, :invoke_with_rails_performance

          def invoke(*args) # rubocop:disable Lint/DuplicateMethods
            invoke_with_rails_performance(*args)
          end
        end
      end

      def self.find_task_name(*args)
        (ARGV + args).compact
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rails_performance-1.4.0.alpha3 lib/rails_performance/gems/rake_ext.rb
rails_performance-1.4.0.alpha2 lib/rails_performance/gems/rake_ext.rb
rails_performance-1.4.0.alpha1 lib/rails_performance/gems/rake_ext.rb
rails_performance-1.3.3 lib/rails_performance/gems/rake_ext.rb
rails_performance-1.3.2 lib/rails_performance/gems/rake_ext.rb
rails_performance-1.3.1 lib/rails_performance/gems/rake_ext.rb
rails_performance-1.3.0 lib/rails_performance/gems/rake_ext.rb