Module: RuboCop::ConfigLoaderResolver
- Included in:
- ConfigLoader
- Defined in:
- lib/rubocop/config_loader_resolver.rb
Overview
A mixin to break up ConfigLoader
Instance Method Summary collapse
- #resolve_inheritance(path, hash) ⇒ Object
- #resolve_inheritance_from_gems(hash, gems) ⇒ Object
- #resolve_requires(path, hash) ⇒ Object
Instance Method Details
#resolve_inheritance(path, hash) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/rubocop/config_loader_resolver.rb', line 21 def resolve_inheritance(path, hash) base_configs(path, hash['inherit_from']).reverse_each do |base_config| base_config.each do |k, v| hash[k] = hash.key?(k) ? merge(v, hash[k]) : v if v.is_a?(Hash) end end end |
#resolve_inheritance_from_gems(hash, gems) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rubocop/config_loader_resolver.rb', line 29 def resolve_inheritance_from_gems(hash, gems) (gems || {}).each_pair do |gem_name, config_path| if gem_name == 'rubocop' raise ArgumentError, "can't inherit configuration from the rubocop gem" end hash['inherit_from'] = Array(hash['inherit_from']) # Put gem configuration first so local configuration overrides it. hash['inherit_from'].unshift gem_config_path(gem_name, config_path) end end |
#resolve_requires(path, hash) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rubocop/config_loader_resolver.rb', line 10 def resolve_requires(path, hash) config_dir = File.dirname(path) Array(hash.delete('require')).each do |r| if r.start_with?('.') require(File.join(config_dir, r)) else require(r) end end end |