Sha256: c8cde5bd066d476580ce5d0d0a163af7530612b424a130a27daf36f8278e2f32

Contents?: true

Size: 975 Bytes

Versions: 20

Compression:

Stored size: 975 Bytes

Contents

module SlimLint
  class NoSuchLinter < StandardError; end

  # Stores all defined linters.
  module LinterRegistry
    @linters = []

    class << self
      # List of all registered linters.
      attr_reader :linters

      # Executed when a linter includes the {LinterRegistry} module.
      #
      # This results in the linter being registered with the registry.
      #
      # @param subclass [Class]
      def included(subclass)
        @linters << subclass
      end

      # Return a list of {SlimLint::Linter} {Class}es corresponding to the
      # specified list of names.
      #
      # @param linter_names [Array<String>]
      # @return [Array<Class>]
      def extract_linters_from(linter_names)
        linter_names.map do |linter_name|
          begin
            SlimLint::Linter.const_get(linter_name)
          rescue NameError
            raise NoSuchLinter, "Linter #{linter_name} does not exist"
          end
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
slim_lint-0.15.1 lib/slim_lint/linter_registry.rb
slim_lint-0.15.0 lib/slim_lint/linter_registry.rb
slim_lint-0.14.0 lib/slim_lint/linter_registry.rb
slim_lint-0.13.0 lib/slim_lint/linter_registry.rb
slim_lint-0.12.0 lib/slim_lint/linter_registry.rb
slim_lint-0.11.0 lib/slim_lint/linter_registry.rb
slim_lint-0.10.0 lib/slim_lint/linter_registry.rb
slim_lint-0.9.0 lib/slim_lint/linter_registry.rb
slim_lint-0.8.3 lib/slim_lint/linter_registry.rb
slim_lint-0.8.2 lib/slim_lint/linter_registry.rb
slim_lint-0.8.1 lib/slim_lint/linter_registry.rb
slim_lint-0.8.0 lib/slim_lint/linter_registry.rb
slim_lint-0.7.2 lib/slim_lint/linter_registry.rb
slim_lint-0.7.1 lib/slim_lint/linter_registry.rb
slim_lint-0.7.0 lib/slim_lint/linter_registry.rb
slim_lint-0.6.1 lib/slim_lint/linter_registry.rb
slim_lint-0.6.0 lib/slim_lint/linter_registry.rb
slim_lint-0.5.0 lib/slim_lint/linter_registry.rb
slim_lint-0.4.0 lib/slim_lint/linter_registry.rb
slim_lint-0.3.0 lib/slim_lint/linter_registry.rb