Skip to content
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

Merged
merged 1 commit into from Apr 28, 2014

Conversation

gpakosz
Copy link
Member

@gpakosz gpakosz commented Apr 13, 2014

This replaces #414.


# Merge config with default config
@config = DEFAULT_CONFIG.merge(@config)

Copy link
Member

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.

@gpakosz
Copy link
Member Author

gpakosz commented Apr 16, 2014

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)
Copy link
Member

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 = [])
Copy link
Member

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.

denisdefreyne added a commit that referenced this pull request Apr 28, 2014
Added parent_config_file support in configuration file
@denisdefreyne denisdefreyne merged commit df88011 into nanoc:master Apr 28, 2014
@denisdefreyne
Copy link
Member

It’s fine!

@gpakosz gpakosz deleted the parent_config_file-support branch July 15, 2014 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants