https://github.com/crystal-lang/crystal-env
https://github.com/crystal-lang/crystal-env
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/crystal-lang/crystal-env
- Owner: crystal-lang
- License: mit
- Created: 2017-11-20T19:50:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-10-28T20:58:12.000Z (over 2 years ago)
- Last Synced: 2025-03-16T01:29:07.754Z (3 months ago)
- Language: Crystal
- Size: 9.77 KB
- Stars: 13
- Watchers: 9
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# crystal-env
[](https://github.com/crystal-lang/crystal-env/actions)
This shard provides environment detection. The selected environment is configured using `CRYSTAL_ENV` environment variable.
## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
crystal-env:
github: crystal-lang/crystal-env
```## Usage
* Add the following require in the application code.
The default environment will be `development`.```crystal
require "crystal-env"
```* In the `spec/spec_helper.cr` require `crystal-env/spec` **before** your app code.
When running `crystal spec` the default environment will be `test`.```crystal
require "spec"
require "crystal-env/spec"
require "../your-app"
```* Use the following methods to detect the environment
* `Crystal.env.development?`
* `Crystal.env.production?`
* `Crystal.env.test?`* Use the following method to get name the environment
* `Crystal.env.name`
* Set `CRYSTAL_ENV` to `development`, `production` or `test`
## Contributors
- [bcardiff](https://github.com/bcardiff) Brian J. Cardiff - creator, maintainer