Sha256: a9b86479fdf309454f9a7ae13795e3dc0c6eb58787577ace43bf288862ffdf0d

Contents?: true

Size: 1.81 KB

Versions: 77

Compression:

Stored size: 1.81 KB

Contents

require "cc/config/checks_adapter"
require "cc/config/default_adapter"
require "cc/config/engine"
require "cc/config/engine_set"
require "cc/config/json_adapter"
require "cc/config/prepare"
require "cc/config/validation/hash_validations"
require "cc/config/validation/check_validator"
require "cc/config/validation/engine_validator"
require "cc/config/validation/fetch_validator"
require "cc/config/validation/file_validator"
require "cc/config/validation/json"
require "cc/config/validation/prepare_validator"
require "cc/config/validation/yaml"
require "cc/config/yaml_adapter"

module CC
  class Config
    attr_reader \
      :analysis_paths,
      :engines,
      :exclude_patterns,
      :prepare

    attr_writer \
      :development

    def self.load
      config =
        if File.exist?(JSONAdapter::DEFAULT_PATH)
          JSONAdapter.load.config
        elsif File.exist?(YAMLAdapter::DEFAULT_PATH)
          YAMLAdapter.load.config
        else
          {}
        end
      config = DefaultAdapter.new(config).config
      config = ChecksAdapter.new(config).config
      build(config)
    end

    def self.build(data)
      new(
        engines: EngineSet.new(data.fetch("plugins", {})).engines,
        exclude_patterns: data.fetch("exclude_patterns", DefaultAdapter::EXCLUDE_PATTERNS),
        prepare: Prepare.from_data(data["prepare"]),
      )
    end

    def initialize(analysis_paths: [], development: false, engines: [], exclude_patterns: [], prepare: Prepare.new)
      @analysis_paths = analysis_paths
      @development = development
      @engines = engines
      @exclude_patterns = exclude_patterns
      @prepare = prepare
    end

    def merge(other)
      Merge.new(self, other).run
    end

    def development?
      @development
    end

    def disable_plugins!
      @engines.delete_if(&:plugin?)
    end
  end
end

Version data entries

77 entries across 77 versions & 2 rubygems

Version Path
codeclimate-0.85.27 lib/cc/config.rb
codeclimate-0.85.26 lib/cc/config.rb
codeclimate-0.85.25 lib/cc/config.rb
codeclimate-0.85.24 lib/cc/config.rb
codeclimate-fede-0.85.54 lib/cc/config.rb
codeclimate-fede-0.85.53 lib/cc/config.rb
codeclimate-fede-0.85.52 lib/cc/config.rb
codeclimate-fede-0.85.51 lib/cc/config.rb
codeclimate-fede-0.85.50 lib/cc/config.rb
codeclimate-fede-0.85.49 lib/cc/config.rb
codeclimate-fede-0.85.48 lib/cc/config.rb
codeclimate-fede-0.85.47 lib/cc/config.rb
codeclimate-fede-0.85.46 lib/cc/config.rb
codeclimate-fede-0.85.45 lib/cc/config.rb
codeclimate-fede-0.85.44 lib/cc/config.rb
codeclimate-fede-0.85.43 lib/cc/config.rb
codeclimate-fede-0.85.42 lib/cc/config.rb
codeclimate-fede-0.85.41 lib/cc/config.rb
codeclimate-fede-0.85.40 lib/cc/config.rb
codeclimate-fede-0.85.39 lib/cc/config.rb