Sha256: 014badc25f87572c5338b5115fcf6c5e12c36f550751bb8821d2cfa6564ee57b

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require "refinements/strings"

module Git
  module Lint
    class Collector
      using Refinements::Strings

      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]
      end

      def empty?
        collection.empty?
      end

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

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

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

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

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

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

      def total_commits
        collection.keys.size
      end

      def to_h
        collection
      end

      private

      attr_reader :collection
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
git-lint-1.4.0 lib/git/lint/collector.rb
git-lint-1.3.0 lib/git/lint/collector.rb
git-lint-1.2.0 lib/git/lint/collector.rb
git-lint-1.1.1 lib/git/lint/collector.rb
git-lint-1.1.0 lib/git/lint/collector.rb
git-lint-1.0.1 lib/git/lint/collector.rb
git-lint-1.0.0 lib/git/lint/collector.rb