Sha256: 507bf5a7112fd85a1be7edec710e3cbb4fe4ee26a8b40e2fbe82a54062e4010e

Contents?: true

Size: 917 Bytes

Versions: 1

Compression:

Stored size: 917 Bytes

Contents

# frozen_string_literal: true

module ActiveRecord
  module DataIntegrity
    # collects result info for rendering
    class Collector
      class << self
        def log(cop, message)
          data.push(cop: cop, message: message)
        end

        def progress(_cop, char)
          print char
        end

        def render
          group_data_by_cop_name.each do |cop_name, items|
            items.each do |item|
              puts "#{Rainbow(cop_name).red}:"\
                     " #{Rainbow(item[:cop].model.name).yellow}"\
                     " #{item[:message]}"
            end
          end
        end

        private

        def data
          @data ||= []
        end

        def group_data_by_cop_name
          data.each_with_object({}) do |item, hash|
            hash[item[:cop].name] ||= []
            hash[item[:cop].name] << item
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activerecord-data_integrity-0.1.0 lib/active_record/data_integrity/collector.rb