Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fnando/application_env
Detect application environments.
https://github.com/fnando/application_env
ruby rubygems
Last synced: 28 days ago
JSON representation
Detect application environments.
- Host: GitHub
- URL: https://github.com/fnando/application_env
- Owner: fnando
- License: mit
- Created: 2022-11-29T21:31:34.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-05T07:50:19.000Z (about 1 year ago)
- Last Synced: 2024-10-06T04:25:21.400Z (about 1 month ago)
- Topics: ruby, rubygems
- Language: Ruby
- Homepage:
- Size: 17.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# application_env
[![Tests](https://github.com/fnando/application_env/workflows/ruby-tests/badge.svg)](https://github.com/fnando/application_env)
[![Gem](https://img.shields.io/gem/v/application_env.svg)](https://rubygems.org/gems/application_env)
[![Gem](https://img.shields.io/gem/dt/application_env.svg)](https://rubygems.org/gems/application_env)
[![MIT License](https://img.shields.io/:License-MIT-blue.svg)](https://tldrlegal.com/license/mit-license)Detect application environments.
## Installation
```bash
gem install application_env
```Or add the following line to your project's Gemfile:
```ruby
gem "application_env"
```## Usage
The environment is inferred out of `ENV["APP_ENV"]`, `ENV["RACK_ENV"]`,
`ENV["RAILS_ENV"]`, defaulting to `development` in case no environment is set.```ruby
require "application_env"app_env = AppEnv.new
app_env.development?
app_env.test?
app_env.production?# runs block on production.
app_env.on(:production, &block)# runs block on any environment.
app_env.on(:any, &block)# pass in custom env vars
app_env = AppEnv.new({"APP_ENV" => "development"})# sets up custom accessors
app_env = AppEnv.new(ENV, accessors: %i[development test staging production])
app_env.staging?
```## Maintainer
- [Nando Vieira](https://github.com/fnando)
## Contributors
- https://github.com/fnando/application_env/contributors
## Contributing
For more details about how to contribute, please read
https://github.com/fnando/application_env/blob/main/CONTRIBUTING.md.## License
The gem is available as open source under the terms of the
[MIT License](https://opensource.org/licenses/MIT). A copy of the license can be
found at https://github.com/fnando/application_env/blob/main/LICENSE.md.## Code of Conduct
Everyone interacting in the application_env project's codebases, issue trackers,
chat rooms and mailing lists is expected to follow the
[code of conduct](https://github.com/fnando/application_env/blob/main/CODE_OF_CONDUCT.md).