Crystal::Environment
require "crystal-environment"
Crystal.env.name # => "development"
Crystal.env.development? # => true
Crystal.env.production? # => false
Constants
DEFAULT = "development"
Default value used when ENV["CRYSTAL_ENV"]? is nil.
KEY = "CRYSTAL_ENV"
Environment variable name used to set the current environment #name.
VALUES = Set {"development", "test", "production"}
Default Set of environments.
VERSION = "0.1.0"
Instance methods
name=(name : String | Symbol | Nil) : String | Nil
Sets ENV["CRYSTAL_ENV"]? to the given name or unsets it, when passed nil.
Macros
setup(keys)
Appends given keys to the list of known environments. For every key, a query method will be created:
Crystal::Environment.setup %w(foo bar)
typeof(Crystal.env.foo?) # => Bool
typeof(Crystal.env.bar?) # => Bool
NOTE: development, test and production will always be defined.