Sha256: 1d8052c314726e798f878544162c1fa503b9cc611401374f16b6122523742c7d

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module Jiminy
  module Recording
    module ProsopiteExt
      require_relative "tmp_file_recorder"

      module SendNotificationsWithTmpFile
        def prepare_results_file!
          TmpFileRecorder.prepare_results_file!
        end

        def tmp_file=(value)
          @tmp_file = value
        end

        def tmp_file
          !!@tmp_file
        end

        def send_notifications
          super

          return unless Prosopite.tmp_file

          # https://github.com/charkost/prosopite/blob/main/lib/prosopite.rb#L157
          tc[:prosopite_notifications].each do |queries, backtrace|
            absolute_location = backtrace.detect { |path| path.exclude?(Bundler.bundle_path.to_s) }
            next unless absolute_location

            relative_location = absolute_location.gsub("#{Rails.root.realpath}/", "")
            tmp_file_recorder.record(location: relative_location, queries: queries)
          end
        end

        private

          def tmp_file_recorder
            @_tmp_file_recorder ||= TmpFileRecorder.new
          end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jiminy-0.4.0 lib/jiminy/recording/prosopite_ext/send_notifications_with_tmp_file.rb
jiminy-0.3.0 lib/jiminy/recording/prosopite_ext/send_notifications_with_tmp_file.rb
jiminy-0.2.0 lib/jiminy/recording/prosopite_ext/send_notifications_with_tmp_file.rb
jiminy-0.1.1 lib/jiminy/recording/prosopite_ext/send_notifications_with_tmp_file.rb
jiminy-0.1.0 lib/jiminy/recording/prosopite_ext/send_notifications_with_tmp_file.rb