Module: Sapience::ConfigLoader
- Defined in:
- lib/sapience/config_loader.rb
Overview
This class represents the configuration of the RuboCop application and all its cops. A Config is associated with a YAML configuration file from which it was read. Several different Configs can be used during a run of the sapience program, if files in several directories are inspected.
Constant Summary collapse
- SAPIENCE_FILE =
"sapience.yml"
- SAPIENCE_HOME =
File.realpath(File.join(File.dirname(__FILE__), "..", ".."))
- DEFAULT_FILE =
File.join(SAPIENCE_HOME, "config", "default.yml")
Class Method Summary collapse
Class Method Details
.load_from_file ⇒ Object
18 19 20 21 22 |
# File 'lib/sapience/config_loader.rb', line 18 def self.load_from_file default_config = load_yaml_configuration(config_file_path) application_config = load_yaml_configuration(application_config_file) merge_configs(default_config, application_config) end |
.merge_configs(left_config = {}, right_config = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sapience/config_loader.rb', line 24 def self.merge_configs(left_config = {}, right_config = {}) left_config.each do |key, config = {}| right = right_config.fetch(key) { {} } config.merge!(right) end (right_config.keys - left_config.keys).each do |left_over_key| left_config[left_over_key] = right_config[left_over_key] end left_config end |