Sha256: d1f3518e783d4bffaac620562a985d7cf8ba44d0e5c7b060afc98a9c538a99d9

Contents?: true

Size: 1.01 KB

Versions: 10

Compression:

Stored size: 1.01 KB

Contents

module SCSSLint
  class Plugins
    # Load ruby files from linter plugin directories.
    class LinterDir
      attr_reader :config

      def initialize(dir)
        @dir = dir
      end

      def load
        ruby_files.each { |file| require file }
        @config = plugin_config
        self
      end

    private

      def ruby_files
        Dir.glob(File.expand_path(File.join(@dir, '**', '*.rb')))
      end

      # Returns the {SCSSLint::Config} for this directory.
      #
      # This is intended to be merged with the configuration that loaded this
      # plugin.
      #
      # @return [SCSSLint::Config]
      def plugin_config
        file = plugin_config_file

        if File.exist?(file)
          Config.load(file, merge_with_default: false)
        else
          Config.new({})
        end
      end

      # Path of the configuration file to attempt to load for this directory.
      #
      # @return [String]
      def plugin_config_file
        File.join(@dir, Config::FILE_NAME)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
scss_lint-0.60.0 lib/scss_lint/plugins/linter_dir.rb
scss_lint-0.59.0 lib/scss_lint/plugins/linter_dir.rb
scss_lint-0.58.0 lib/scss_lint/plugins/linter_dir.rb
scss_lint-0.57.1 lib/scss_lint/plugins/linter_dir.rb
scss_lint-0.57.0 lib/scss_lint/plugins/linter_dir.rb
scss_lint-0.56.0 lib/scss_lint/plugins/linter_dir.rb
scss_lint-0.55.0 lib/scss_lint/plugins/linter_dir.rb
scss_lint-0.54.0 lib/scss_lint/plugins/linter_dir.rb
scss_lint-0.53.0 lib/scss_lint/plugins/linter_dir.rb
scss_lint-0.52.0 lib/scss_lint/plugins/linter_dir.rb