zen_config 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
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 :
@@ -1,3 +1,3 @@
1
1
  class ZenConfig
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/zen_config.rb CHANGED
@@ -82,7 +82,6 @@ class ZenConfig
82
82
  def load_hash hash
83
83
  if @allow_modifications
84
84
  hash.each do |key, value|
85
- puts key.to_s + " : " + value.to_s
86
85
  key = key.to_sym
87
86
 
88
87
  if value.is_a? Hash
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.2
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-10 00:00:00.000000000 Z
12
+ date: 2012-04-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec