Sha256: 19994370245f5d4268687a2c5b63576972457f7268d1d9af5992bc4baf4e7e5d

Contents?: true

Size: 1.17 KB

Versions: 34

Compression:

Stored size: 1.17 KB

Contents

module CC
  module CLI
    class Config
      delegate :to_yaml, to: :config

      def initialize(config = {})
        @config = default_config.merge(config)
      end

      def add_engine(engine_name, engine_config)
        config["engines"][engine_name] = { "enabled" => true }

        if engine_config["default_config"].present?
          config["engines"][engine_name]["config"] = engine_config["default_config"]
        end

        # we may not want this code in the general case.
        # for now, we need it to test one of our own Maintainability engines
        # which is in the 'beta' channel
        if engine_config.key?("channels") && !engine_config["channels"].include?("stable")
          config["engines"][engine_name]["channel"] = engine_config["channels"].first.first
        end

        config["ratings"]["paths"] |= engine_config["default_ratings_paths"]
      end

      def add_exclude_paths(paths)
        config["exclude_paths"] ||= []
        config["exclude_paths"] |= paths
      end

      private

      attr_reader :config

      def default_config
        {
          "engines" => {},
          "ratings" => { "paths" => [] },
        }
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
codeclimate-0.69.0 lib/cc/cli/config.rb
codeclimate-0.68.0 lib/cc/cli/config.rb
codeclimate-0.67.0 lib/cc/cli/config.rb
codeclimate-0.66.0 lib/cc/cli/config.rb
codeclimate-0.65.0 lib/cc/cli/config.rb
codeclimate-0.64.0 lib/cc/cli/config.rb
codeclimate-0.63.7 lib/cc/cli/config.rb
codeclimate-0.63.6 lib/cc/cli/config.rb
codeclimate-0.63.5 lib/cc/cli/config.rb
codeclimate-0.63.4 lib/cc/cli/config.rb
codeclimate-0.63.3 lib/cc/cli/config.rb
codeclimate-0.63.2 lib/cc/cli/config.rb
codeclimate-0.63.1 lib/cc/cli/config.rb
codeclimate-0.63.0 lib/cc/cli/config.rb
codeclimate-0.62.0 lib/cc/cli/config.rb
codeclimate-0.61.1 lib/cc/cli/config.rb
codeclimate-0.61.0 lib/cc/cli/config.rb
codeclimate-0.60.1 lib/cc/cli/config.rb
codeclimate-0.60.0 lib/cc/cli/config.rb
codeclimate-0.59.1 lib/cc/cli/config.rb