Sha256: 76fb3794edef76b35d70e6a90443ace335d5dc587ef40853cd125ae57da241f5

Contents?: true

Size: 1.06 KB

Versions: 106

Compression:

Stored size: 1.06 KB

Contents

module Standard
  module Plugin
    class StandardizesConfiguredPlugins
      DEFAULT_PLUGIN_CONFIG = {
        "enabled" => true,
        "require_path" => nil, # If not set, will be set to the plugin name
        "plugin_class_name" => nil # If not set, looks for gemspec `spec.metadata["default_lint_roller_plugin"]`
      }.freeze

      BUILT_INS = [
        {"standard-base" => {
          "require_path" => "standard/base",
          "plugin_class_name" => "Standard::Base::Plugin"
        }},
        "standard-custom",
        "standard-performance"
      ].freeze

      def call(plugins)
        normalize_config_shape(BUILT_INS + plugins)
      end

      private

      def normalize_config_shape(plugins)
        plugins.map { |plugin|
          if plugin.is_a?(Hash)
            plugin_name = plugin.keys.first
            [plugin_name, DEFAULT_PLUGIN_CONFIG.merge({"require_path" => plugin_name}, plugin.values.first)]
          else
            [plugin, DEFAULT_PLUGIN_CONFIG.merge("require_path" => plugin)]
          end
        }.to_h
      end
    end
  end
end

Version data entries

106 entries across 106 versions & 3 rubygems

Version Path
standard-1.44.0 lib/standard/plugin/standardizes_configured_plugins.rb
standard-1.43.0 lib/standard/plugin/standardizes_configured_plugins.rb
standard-1.42.1 lib/standard/plugin/standardizes_configured_plugins.rb
standard-1.42.0 lib/standard/plugin/standardizes_configured_plugins.rb
standard-1.41.1 lib/standard/plugin/standardizes_configured_plugins.rb
standard-1.41.0 lib/standard/plugin/standardizes_configured_plugins.rb
standard-1.40.1 lib/standard/plugin/standardizes_configured_plugins.rb
standard-1.40.0 lib/standard/plugin/standardizes_configured_plugins.rb
standard-1.39.2 lib/standard/plugin/standardizes_configured_plugins.rb
standard-1.39.1 lib/standard/plugin/standardizes_configured_plugins.rb
standard-1.39.0 lib/standard/plugin/standardizes_configured_plugins.rb
standard-1.38.0 lib/standard/plugin/standardizes_configured_plugins.rb
standard-1.37.0 lib/standard/plugin/standardizes_configured_plugins.rb
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/plugin/standardizes_configured_plugins.rb
standard-1.35.0.1 lib/standard/plugin/standardizes_configured_plugins.rb
standard-1.34.0.1 lib/standard/plugin/standardizes_configured_plugins.rb
standard-1.35.1 lib/standard/plugin/standardizes_configured_plugins.rb
standard-1.35.0 lib/standard/plugin/standardizes_configured_plugins.rb
standard-1.34.0 lib/standard/plugin/standardizes_configured_plugins.rb
harbr-0.2.10 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/plugin/standardizes_configured_plugins.rb