Sha256: b737b2dd664c840a60261bbbed387a0c5f3c03bb68abaf2e4834e7add1d6903c

Contents?: true

Size: 1.04 KB

Versions: 23

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module SlimLint
  # Abstract lint reporter. Subclass and override {#display_report} to
  # implement a custom lint reporter.
  #
  # @abstract
  class Reporter
    # Creates the reporter that will display the given report.
    #
    # @param logger [SlimLint::Logger]
    def initialize(logger)
      @log = logger
    end

    # Implemented by subclasses to display lints from a {SlimLint::Report}.
    #
    # @param report [SlimLint::Report]
    def display_report(report)
      raise NotImplementedError,
            "Implement `display_report` to display #{report}"
    end

    # Keep tracking all the descendants of this class for the list of available
    # reporters.
    #
    # @return [Array<Class>]
    def self.descendants
      @descendants ||= []
    end

    # Executed when this class is subclassed.
    #
    # @param descendant [Class]
    def self.inherited(descendant)
      descendants << descendant
    end

    private

    # @return [SlimLint::Logger] logger to send output to
    attr_reader :log
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
slim_lint-0.31.1 lib/slim_lint/reporter.rb
slim_lint-0.31.0 lib/slim_lint/reporter.rb
slim_lint-0.30.0 lib/slim_lint/reporter.rb
slim_lint-0.29.0 lib/slim_lint/reporter.rb
slim_lint-0.28.0 lib/slim_lint/reporter.rb
slim_lint-0.27.0 lib/slim_lint/reporter.rb
slim_lint-0.26.0 lib/slim_lint/reporter.rb
slim_lint-0.25.0 lib/slim_lint/reporter.rb
slim_lint-0.24.0 lib/slim_lint/reporter.rb
slim_lint-0.23.0 lib/slim_lint/reporter.rb
slim_lint-0.22.1 lib/slim_lint/reporter.rb
slim_lint-0.22.0 lib/slim_lint/reporter.rb
slim_lint-0.21.1 lib/slim_lint/reporter.rb
slim_lint-0.21.0 lib/slim_lint/reporter.rb
slim_lint-0.20.2 lib/slim_lint/reporter.rb
slim_lint-0.20.1 lib/slim_lint/reporter.rb
slim_lint-0.20.0 lib/slim_lint/reporter.rb
slim_lint-0.19.0 lib/slim_lint/reporter.rb
slim_lint-0.18.0 lib/slim_lint/reporter.rb
slim_lint-0.17.1 lib/slim_lint/reporter.rb