Skip to content

Commit

Permalink
Merge branch 'selective-env'
Browse files Browse the repository at this point in the history
For a long time now Nesta has prevented you from spreading your settings
between `config.yml` and the environment. If you set a single
`NESTA_...` environment variable, Nesta would expect all your
configuration to come from the environment.

This behaviour was added back in commit 4ffa508, on the "heroku" branch.

I have a sneaky suspicion that members of the community persuaded me
that having a config file on Heroku was just not the done thing. It
seems insane now, and the blog post where the idea was put forward (and
in whose comments the debate was held) no longer exists.

With the benefit of hindsight, this limitation seems insane!

As Glenn has pointed out, anybody who wants to use the environment to
configure their apps can use Erb tags within `config.yml` to read values
from `ENV`, and insert them at run time.

In the future, I'd like to remove all the code that reads the
environment variables directly, and just recommend that people who want
to use the environment do that.

Nice one, Mr Gillen. :-)
  • Loading branch information
gma committed Jan 20, 2015
2 parents 826043a + eefcf48 commit bac5097
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/nesta/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def self.yaml_exists?
private_class_method :yaml_exists?

def self.can_use_yaml?
ENV.keys.grep(/^NESTA/).empty? && yaml_exists?
yaml_exists?
end
private_class_method :can_use_yaml?

Expand Down
6 changes: 3 additions & 3 deletions spec/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
@title = "Title from ENV"
ENV["NESTA_TITLE"] = @title
end
it "should never try and access config.yml" do

it "should fallback to config.yml" do
stub_config_key("subtitle", "Subtitle in YAML file")
Nesta::Config.subtitle.should be_nil
Nesta::Config.subtitle.should == "Subtitle in YAML file"
end

it "should override config.yml" do
Expand Down

0 comments on commit bac5097

Please sign in to comment.