Sha256: 5685fde8970b65a5999510f5b3a626bde4d61189e5dfa8820074175690795877

Contents?: true

Size: 1.47 KB

Versions: 24

Compression:

Stored size: 1.47 KB

Contents

# encoding: utf-8

module RuboCop
  # Handles caching of configurations and association of inspected
  # ruby files to configurations.
  class ConfigStore
    def initialize
      # @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 options_config=(options_config)
      loaded_config = ConfigLoader.load_file(options_config)
      @options_config = ConfigLoader.merge_with_default(loaded_config,
                                                        options_config)
    end

    def for(file_or_dir)
      return @options_config if @options_config

      dir = if File.directory?(file_or_dir)
              file_or_dir
            else
              File.dirname(file_or_dir)
            end
      @path_cache[dir] ||= ConfigLoader.configuration_file_for(dir)
      path = @path_cache[dir]
      @object_cache[path] ||= begin
                                print "For #{dir}: " if ConfigLoader.debug?
                                ConfigLoader.configuration_from_file(path)
                              end
    end
  end
end

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/lib/rubocop/config_store.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/lib/rubocop/config_store.rb
rubocop-0.35.1 lib/rubocop/config_store.rb
rubocop-0.35.0 lib/rubocop/config_store.rb
rubocop-0.34.2 lib/rubocop/config_store.rb
rubocop-0.34.1 lib/rubocop/config_store.rb
rubocop-0.34.0 lib/rubocop/config_store.rb
rubocop-0.33.0 lib/rubocop/config_store.rb
rubocop-0.32.1 lib/rubocop/config_store.rb
rubocop-0.32.0 lib/rubocop/config_store.rb
rubocop-0.31.0 lib/rubocop/config_store.rb
rubocop-0.30.1 lib/rubocop/config_store.rb
rubocop-0.30.0 lib/rubocop/config_store.rb
rubocop-0.29.1 lib/rubocop/config_store.rb
rubocop-0.29.0 lib/rubocop/config_store.rb
rubocop-0.28.0 lib/rubocop/config_store.rb
rubocop-0.27.1 lib/rubocop/config_store.rb
rubocop-0.27.0 lib/rubocop/config_store.rb
rubocop-0.26.1 lib/rubocop/config_store.rb
rubocop-0.26.0 lib/rubocop/config_store.rb