This repository has been archived by the owner on Dec 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
README
47 lines (31 loc) · 1.45 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Confu
=====
Confu is a micro-mini (think wicked weasel sized) utility I extracted from a couple of projects. Influenced by
http://github.com/cjbottaro/app_config/tree/master
and
http://github.com/railsmonk/configuration-file-plugin/tree/master
The main thing I wanted to change is that files are separated not by environment, but by concern. Each file can use merging (described below) to avoid repeating, and accidentally miss adding new stuff (which I constantly do). And you can also use ignore + yml.sample approach for sensitive config.
Installation
============
Add it in your Gemfile
gem 'confu'
From your project's RAILS_ROOT, run:
rails generate confu:install
This will create sample config/site/app.yml file.
Then you put multiple yml files in the site folder. Each config file will result in {file_name}Config constant defined, loading the current environment's section values.
So if you have site.yml, containing
development:
home_page_entries: 3
production:
home_page_entries: 5
You will have SiteConfig defined, and SiteConfig.home_page_entries returning 3 and 5 in development and production, respectively.
YAML has some neat DRY stuff, actually - check this out:
http://www.yaml.org/refcard.html
One thing that comes in handy is merging keys from mapping - like this.
development: &default
home_page_entries: 3
admin_entries: 4
production:
<<: *default
home_page_entries: 5
Copyright (c) 2009 Petyo Ivanov, released under the MIT license