New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added parent_config_file support in configuration file #419
Added parent_config_file support in configuration file #419
Conversation
|
||
# Merge config with default config | ||
@config = DEFAULT_CONFIG.merge(@config) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This set of changes is quite long and should be extracted into its own method. A method that recursively loads config files should do the trick.
How about now? |
raise Nanoc::Errors::GenericTrivial, "Cycle detected. Could not use parent configuration file '#{parent_config_file}'" | ||
end | ||
parent_config = load_config(config_path) | ||
apply_parent_config(parent_config, config_paths << config_path).merge(config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config_paths + config_path
rather than <<
because the latter mutates.
YAML.load_file(config_path).symbolize_keys_recursively | ||
end | ||
|
||
def apply_parent_config(config, config_paths = []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’d prefer config_paths
to be a Set
rather than an array (there is no need to have it ordered).
A better name for this param would be seen_config_paths
.
Added parent_config_file support in configuration file
It’s fine! |
This replaces #414.