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.59.0 lib/cc/cli/config.rb
codeclimate-0.58.0 lib/cc/cli/config.rb
codeclimate-0.57.0 lib/cc/cli/config.rb
codeclimate-0.56.0 lib/cc/cli/config.rb
codeclimate-0.55.0 lib/cc/cli/config.rb
codeclimate-0.54.0 lib/cc/cli/config.rb
codeclimate-0.53.0 lib/cc/cli/config.rb
codeclimate-0.52.0 lib/cc/cli/config.rb
codeclimate-0.51.3 lib/cc/cli/config.rb
codeclimate-0.51.2 lib/cc/cli/config.rb
codeclimate-0.51.1 lib/cc/cli/config.rb
codeclimate-0.51.0 lib/cc/cli/config.rb
codeclimate-0.50.0 lib/cc/cli/config.rb
codeclimate-0.49.0 lib/cc/cli/config.rb