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

Gracefully handle empty configuration files #97

Merged
merged 1 commit into from
May 25, 2016

Conversation

rjocoleman
Copy link
Contributor

@rjocoleman rjocoleman commented May 22, 2016

Currently if ~/.gemstash/config.yml (or ~/.gemstash/config.yml.erb) exists but has no yaml content the YAML.load_file method returns nil.

Failure/Error: @config = DEFAULTS.merge(@config)

TypeError:
  no implicit conversion of nil into Hash
# ./lib/gemstash/configuration.rb:36:in `merge'

This PR sets a default value of an empty hash, this is used in the case that the parsed config file is empty.
I also introduced a next test case for this.

I encountered this when using a dynamically generated config.yml that had no content (so defaults were expected).

I also made a small change to the method, removing the variable assignment as the values are returned. and assigned to that variable in the callers.

@smellsblue smellsblue merged commit 5282e4c into rubygems:master May 25, 2016
@smellsblue smellsblue added the bug label May 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants