https://github.com/apsislabs/src
Simple Rails Configurator
https://github.com/apsislabs/src
Last synced: 4 months ago
JSON representation
Simple Rails Configurator
- Host: GitHub
- URL: https://github.com/apsislabs/src
- Owner: apsislabs
- License: mit
- Created: 2023-02-03T15:52:39.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-23T15:09:16.000Z (over 2 years ago)
- Last Synced: 2025-03-04T05:12:35.179Z (10 months ago)
- Language: Ruby
- Size: 5.86 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Simple Rails Configurator
Easily load custom yml configuration files into the Rails environment.
Features:
- ERB support
- Supports per-environment configurations within loaded files
- Injects configurations directly into `Rails.application.config`
- Local overrides with `.override` files
- Recursive directory traversal
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'simple_rails_configurator'
```
And then execute:
$ bundle install
Or install it yourself as:
$ gem install simple_rails_configurator
## Usage
In `environment.rb`, `require` this gem and then add `SimpleRailsConfigurator::configure!('PATH_TO_CUSTOM_CONFIG_DIR')`. The path should be appropriately specified from the Rails root path. All YML/YAML files in the given directory (and subdirectories) will be injected into the Rails configuration object. If you don't pass an argument to `configure!`, the default path is `"#{Rails.root}/config/custom"`.
To create a local override (parsed only when `Rails.env == 'local' || Rails.env == 'development'`), for the file `foo_config.yml`, create `foo_config.yml.override` next to it. Any values set in this file will override those in `foo_config.yml`.
Access the imported configurations at `Rails.application.config.filename['config_var']`. Note that at the moment only the base filename is used, so if you have `config/custom/foo.yml` and `config/custom/bar/foo.yml`, only one of them will take effect.
## Development
After checking out the repo, run `bin/setup` to install dependencies.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).