This shard provides environment detection. The selected environment is configured using CRYSTAL_ENV
environment variable.
Add this to your application's shard.yml
:
dependencies:
env:
github: crystal-lang/crystal-env
- Add the following require in the application code.
The default environment will be
development
.
require "env"
- In the
spec/spec_helper.cr
requireenv/spec
before your app code. When runningcrystal spec
the default environment will betest
.
require "spec"
require "env/spec"
require "../your-app"
-
Use the following methods to detect the environment
Crystal.env.development?
Crystal.env.production?
Crystal.env.test?
-
Set
CRYSTAL_ENV
todevelopment
,production
ortest