https://github.com/veelenga/any_setting
Load your settings with ease
https://github.com/veelenga/any_setting
Last synced: about 2 months ago
JSON representation
Load your settings with ease
- Host: GitHub
- URL: https://github.com/veelenga/any_setting
- Owner: veelenga
- License: mit
- Created: 2017-07-18T07:06:30.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-07-18T17:24:14.000Z (almost 8 years ago)
- Last Synced: 2025-02-07T19:29:06.220Z (4 months ago)
- Language: Crystal
- Size: 260 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Any Setting
[](https://travis-ci.org/veelenga/any_setting)Load your settings with ease.
* [x] yaml files
* [ ] json files
* [ ] toml files
* [ ] ini files## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
any_setting:
github: veelenga/any_setting
```## Usage
Settings file `config/site.yml`:
```yml
default: &default
title: My Super Site
description: It just so cool and powerful.
made_by: John Doe
year: 2017development:
<<: *default
url: http://localhost:3000production:
<<: *default
url: https://example.com
```Your loader:
```crystal
require "any_setting"class SiteSettings < AnySetting
source "config/site.yml"
namespace "production"mapping(
title: String,
description: String,
url: String,
year: Int32,
author: {
type: String,
key: "made_by",
nillable: true,
}
)
endsite = SiteSettings.load
site.title #=> My Super Site
site.description #=> It just so cool and powerful.
site.made_by #=> John Doe
site.year #=> 2017
site.url #=> https://example.com```
## Contributing
1. Fork it ( https://github.com/veelenga/any_setting/fork )
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create a new Pull Request