Sha256: 9ecc11c3b224e3e231ff4da5cb150fa13ca1346e2deda2415aef2c0ea5ca88ec

Contents?: true

Size: 975 Bytes

Versions: 5

Compression:

Stored size: 975 Bytes

Contents

# frozen_string_literal: true

require "refinements/hashes"

module Git
  module Lint
    class Collector
      using ::Refinements::Hashes

      def initialize
        @collection = Hash.new { |default, missing_id| default[missing_id] = [] }
      end

      def add analyzer
        collection[analyzer.commit] << analyzer
        analyzer
      end

      def retrieve(id) = collection[id]

      def empty? = collection.empty?

      def warnings? = collection.values.flatten.any?(&:warning?)

      def errors? = collection.values.flatten.any?(&:error?)

      def issues? = collection.values.flatten.any?(&:invalid?)

      def total_warnings = collection.values.flatten.count(&:warning?)

      def total_errors = collection.values.flatten.count(&:error?)

      def total_issues = collection.values.flatten.count(&:invalid?)

      def total_commits = collection.keys.size

      def to_h = collection

      private

      attr_reader :collection
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
git-lint-2.4.0 lib/git/lint/collector.rb
git-lint-2.3.3 lib/git/lint/collector.rb
git-lint-2.3.2 lib/git/lint/collector.rb
git-lint-2.3.1 lib/git/lint/collector.rb
git-lint-2.3.0 lib/git/lint/collector.rb