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-fede-0.85.38 lib/cc/config.rb
codeclimate-fede-0.85.37 lib/cc/config.rb
codeclimate-fede-0.85.36 lib/cc/config.rb
codeclimate-fede-0.85.35 lib/cc/config.rb
codeclimate-fede-0.85.33 lib/cc/config.rb
codeclimate-fede-0.85.32 lib/cc/config.rb
codeclimate-fede-0.85.31 lib/cc/config.rb
codeclimate-fede-0.85.30 lib/cc/config.rb
codeclimate-fede-0.85.21 lib/cc/config.rb
codeclimate-fede-0.85.24 lib/cc/config.rb
codeclimate-fede-0.85.23 lib/cc/config.rb
codeclimate-0.85.23 lib/cc/config.rb
codeclimate-0.85.22 lib/cc/config.rb
codeclimate-0.85.21 lib/cc/config.rb
codeclimate-0.85.19 lib/cc/config.rb
codeclimate-0.85.18 lib/cc/config.rb
codeclimate-0.85.17 lib/cc/config.rb
codeclimate-0.85.15 lib/cc/config.rb
codeclimate-0.85.14 lib/cc/config.rb
codeclimate-0.85.13 lib/cc/config.rb