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



117
118
119
# File 'lib/cleo_quality_review/configuration.rb', line 117

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

Instance Method Details

#loadConfiguration

Load merged configuration

Returns:



124
125
126
127
128
129
130
# File 'lib/cleo_quality_review/configuration.rb', line 124

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