Class: HamlLint::ConfigurationLoader
- Inherits:
-
Object
- Object
- HamlLint::ConfigurationLoader
- Defined in:
- lib/haml_lint/configuration_loader.rb
Overview
Manages configuration file loading.
Constant Summary collapse
- DEFAULT_CONFIG_PATH =
File.join(HAML_LINT_HOME, 'config', 'default.yml')
- CONFIG_FILE_NAME =
'.haml-lint.yml'
Class Method Summary collapse
- .default_configuration ⇒ Object
- .load_applicable_config ⇒ Object
-
.load_file(file) ⇒ Object
Loads a configuration, ensuring it extends the default configuration.
- .load_hash(hash) ⇒ Object
Class Method Details
.default_configuration ⇒ Object
22 23 24 |
# File 'lib/haml_lint/configuration_loader.rb', line 22 def default_configuration @default_config ||= load_from_file(DEFAULT_CONFIG_PATH) end |
.load_applicable_config ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/haml_lint/configuration_loader.rb', line 11 def load_applicable_config directory = File.(Dir.pwd) config_file = possible_config_files(directory).find(&:file?) if config_file load_file(config_file.to_path) else default_configuration end end |
.load_file(file) ⇒ Object
Loads a configuration, ensuring it extends the default configuration.
27 28 29 30 31 32 33 34 35 |
# File 'lib/haml_lint/configuration_loader.rb', line 27 def load_file(file) config = load_from_file(file) default_configuration.merge(config) rescue => error raise HamlLint::Exceptions::ConfigurationError, "Unable to load configuration from '#{file}': #{error}", error.backtrace end |
.load_hash(hash) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/haml_lint/configuration_loader.rb', line 37 def load_hash(hash) config = HamlLint::Configuration.new(hash) default_configuration.merge(config) rescue => error raise HamlLint::Exceptions::ConfigurationError, "Unable to load configuration from '#{file}': #{error}", error.backtrace end |