Class: CleoQualityReview::Configuration::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/cleo_quality_review/configuration.rb

Overview

Loads and merges configuration files with inheritance support

Instance Method Summary collapse

Constructor Details

#initialize(root:) ⇒ Loader

Returns a new instance of Loader.

Parameters:

  • root (String)

    root directory for config file lookup



86
87
88
# File 'lib/cleo_quality_review/configuration.rb', line 86

def initialize(root:)
  @root = File.expand_path(root)
end

Instance Method Details

#loadConfiguration

Load merged configuration

Returns:



93
94
95
96
97
98
99
# File 'lib/cleo_quality_review/configuration.rb', line 93

def load
  data = load_file(DEFAULT_CONFIG_PATH)
  local_config_path = File.join(root, LOCAL_CONFIG_PATH)
  data = merge(data, load_file(local_config_path)) if File.file?(local_config_path)

  Configuration.new(data)
end