Sha256: c519eecdc1abf7bed62eaf6bc1e8e45f23d231513046a900c1780f308f1df6da

Contents?: true

Size: 1.1 KB

Versions: 7

Compression:

Stored size: 1.1 KB

Contents

# encoding: utf-8

module Rubocop
  module ConfigStore
    module_function

    def prepare
      # @options_config stores a config that is specified in the command line.
      # This takes precedence over configs located in any directories
      @options_config = nil

      # @path_cache maps directories to configuration paths. We search
      # for .rubocop.yml only if we haven't already found it for the
      # given directory.
      @path_cache = {}

      # @object_cache maps configuration file paths to
      # configuration objects so we only need to load them once.
      @object_cache = {}
    end

    def set_options_config(options_config)
      loaded_config = Config.load_file(options_config)
      @options_config = Config.merge_with_default(loaded_config,
                                                  options_config)
    end

    def for(file)
      return @options_config if @options_config

      dir = File.dirname(file)
      @path_cache[dir] ||= Config.configuration_file_for(dir)
      path = @path_cache[dir]
      @object_cache[path] ||= Config.configuration_from_file(path)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rubocop-0.8.3 lib/rubocop/config_store.rb
rubocop-0.8.2 lib/rubocop/config_store.rb
rubocop-0.8.1 lib/rubocop/config_store.rb
rubocop-0.8.0 lib/rubocop/config_store.rb
rubocop-0.7.2 lib/rubocop/config_store.rb
rubocop-0.7.1 lib/rubocop/config_store.rb
rubocop-0.7.0 lib/rubocop/config_store.rb