zen_config 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +30 -0
- data/lib/zen_config/version.rb +1 -1
- data/lib/zen_config.rb +0 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -18,6 +18,36 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
$ gem install zen_config
|
20
20
|
|
21
|
+
## App integration
|
22
|
+
|
23
|
+
Create your config file __config/config.yml__ :
|
24
|
+
|
25
|
+
defaults: &defaults
|
26
|
+
user:
|
27
|
+
name:
|
28
|
+
max_length: 64
|
29
|
+
post:
|
30
|
+
max_length: 140
|
31
|
+
development:
|
32
|
+
<<: defaults
|
33
|
+
production:
|
34
|
+
<<: defaults
|
35
|
+
|
36
|
+
Create a new initializer __config/initializers/config.rb__ :
|
37
|
+
|
38
|
+
APP_CONFIG = ZenConfig.new(YAML::load(File.open("#{Rails.root}/config/config.yml"))[Rails.env])
|
39
|
+
|
40
|
+
Restrict config scope in your classes :
|
41
|
+
|
42
|
+
class User
|
43
|
+
@config = APP_CONFIG.user
|
44
|
+
|
45
|
+
validates :name, :length => { :maximum => @config.name.max_length }
|
46
|
+
|
47
|
+
[...]
|
48
|
+
|
49
|
+
end
|
50
|
+
|
21
51
|
## Usage
|
22
52
|
|
23
53
|
Instantiate ZenConfig with a configuration hash :
|
data/lib/zen_config/version.rb
CHANGED
data/lib/zen_config.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zen_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|