Skip to content
This repository was archived by the owner on Jun 17, 2020. It is now read-only.

Commit 13d3a8b

Browse files
committed
Merge pull request #240 from monterail/feature/envied-defaults-guideline
Envied guideline on defaults
2 parents b001728 + 0f3529d commit 13d3a8b

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

‎rails.md‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,3 +398,30 @@ class Raven::Event
398398
end
399399
end
400400
```
401+
402+
## ENVied
403+
404+
ENVied ensure presence and type of app's ENV-variables. To make the bootstraping of the app a quick process, it allows to assign default values to them.
405+
406+
'Easily bootstrap' is quite the opposite of 'fail-fast when not all ENV-variables are present', hence it should be explicitly stated when defaults values are allowed:
407+
408+
```ruby
409+
# Envfile
410+
development_or_test = ->{ ENV.fetch("RACK_ENV", "development").match(/development|test/) }
411+
enable_defaults!(&development_or_test)
412+
413+
variable :HOST, :string, default: 'host.dev'
414+
variable :SENTRY_DSN, :string, default: ''
415+
416+
variable :SSL_ENABLED, :boolean, default: false
417+
418+
variable :API_KEY, :string, default: "api_key"
419+
variable :CONSUMER_KEY, :string, default: "consumer_key"
420+
421+
group :production do
422+
variable :FORCE_SSL, :boolean
423+
end
424+
```
425+
The config enables the defaults in development or test environments, but still fail-fast in any other stage if any required ENV-variable is not set up.
426+
427+
Without the fallback to `development` in `development_or_test` rake tasks won't work.

0 commit comments

Comments
 (0)