module

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

development?

Returns true if #name equals "development", false otherwise.

Source
name

Returns value of ENV["CRYSTAL_ENV"]? if any, "development" otherwise.

Source
name=(name : String | Symbol | Nil) : String | Nil

Sets ENV["CRYSTAL_ENV"]? to the given name or unsets it, when passed nil.

Source
production?

Returns true if #name equals "production", false otherwise.

Source
test?

Returns true if #name equals "test", false otherwise.

Source

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.

Source