gma / nesta

File Based CMS and Static Site Generator
http://nestacms.com
MIT License
902 stars 121 forks source link

Let environment variables override settings in config.yml #134

Closed seanredmond closed 10 years ago

seanredmond commented 11 years ago

This is a fix for issue #133 and allows you to override individual configuration settings with environment variables without having to override them all. This allowed a simplification of the logic around checking for a config file and has a couple of side effects:

  1. Currently a missing config file causes a TypeError to be raised when nesta tries to use a nil value, expecting a string. The code in config.rb looks as if the intent was to pass the Errno::ENOENT that gets raised when YAML::load tries to open the non-existent file. Now the Errno::ENOENT is passed on.
  2. I happened to have a page where there was no blank line between the metadata and the #heading. This is an invalid format, and with these changes loading that file raises an error because no heading is found. Without these changes, however, the page loads, just with a blank heading. The code in models.rb looks as if the intent was in fact to raise an error.
gma commented 11 years ago

Cheers Sean. I'm going to sit on this for a bit while I try and remember why I was so explicit about never falling back to the Yaml for any required vars that weren't defined. I left myself a fairly big clue (in how I wrote the code and tests) that I did it that way on purpose. I suspect it'll have been something to do with hosting on services like Heroku (which is why env var support was added in the first place), but I'll see if it comes back to me…

gma commented 10 years ago

If other people flag this as being an issue in future we can look at it again, but right now there are more important things to do so I'm going to close this. I'm still not convinced there's a strong argument either way, so I'm afraid I'm taking the shortest path (the docs would need fixing too, for example) and I'm happy with the current behaviour.