rails_config 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -94,7 +94,7 @@ Alternatively, you can also use the `[]` operator if you don't know which exact
94
94
  ```ruby
95
95
  # All the following are equivalent to Settings.my_section.some_entry
96
96
  Settings.my_section[:some_entry]
97
- Settings.my_section['some_entry]
97
+ Settings.my_section['some_entry']
98
98
  Settings[:my_section][:some_entry]
99
99
  ```
100
100
 
@@ -5,13 +5,13 @@ module RailsConfig
5
5
  class Railtie < Rails::Railtie
6
6
 
7
7
  # manually load the custom initializer before everything else
8
- initializer :load_custom_rails_config, :before => :load_environment_config do
8
+ initializer :load_custom_rails_config, :before => :load_environment_config, :group => :all do
9
9
  initializer = Rails.root.join("config", "initializers", "rails_config.rb")
10
10
  require initializer if File.exist?(initializer)
11
11
  end
12
12
 
13
13
  # Parse the settings before any of the initializers
14
- initializer :load_rails_config_settings, :after => :load_custom_rails_config, :before => :load_environment_config do
14
+ initializer :load_rails_config_settings, :after => :load_custom_rails_config, :before => :load_environment_config, :group => :all do
15
15
  RailsConfig.load_and_set_settings(
16
16
  Rails.root.join("config", "settings.yml").to_s,
17
17
  Rails.root.join("config", "settings", "#{Rails.env}.yml").to_s,
@@ -2,6 +2,8 @@ require 'ostruct'
2
2
  module RailsConfig
3
3
  class Options < OpenStruct
4
4
 
5
+ include Enumerable
6
+
5
7
  def empty?
6
8
  marshal_dump.empty?
7
9
  end
@@ -48,6 +50,10 @@ module RailsConfig
48
50
  result
49
51
  end
50
52
 
53
+ def each(*args, &block)
54
+ marshal_dump.each(*args, &block)
55
+ end
56
+
51
57
  def to_json(*args)
52
58
  require "json" unless defined?(JSON)
53
59
  to_hash.to_json(*args)
@@ -1,3 +1,3 @@
1
1
  module RailsConfig
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  end
data/rails_config.gemspec CHANGED
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
 
19
19
  s.add_runtime_dependency "activesupport", ">= 3.0"
20
20
  s.add_development_dependency "rake"
21
+ s.add_development_dependency "rdoc"
21
22
  s.add_development_dependency "rspec", "~> 2.0"
22
23
  s.add_development_dependency "autotest", ">= 0"
23
24
  s.add_development_dependency "growl-glue", ">= 0"
@@ -215,4 +215,27 @@ describe RailsConfig do
215
215
  config.section.foo.should eq 'bar'
216
216
  end
217
217
  end
218
- end
218
+
219
+ context "enumerable" do
220
+ let(:config) do
221
+ files = [setting_path("development.yml")]
222
+ RailsConfig.load_files(files)
223
+ end
224
+
225
+ it "should enumerate top level parameters" do
226
+ keys = []
227
+ config.each { |key, value| keys << key }
228
+ keys.should eq [:size, :section]
229
+ end
230
+
231
+ it "should enumerate inner parameters" do
232
+ keys = []
233
+ config.section.each { |key, value| keys << key }
234
+ keys.should eq [:size, :servers]
235
+ end
236
+
237
+ it "should have methods defined by Enumerable" do
238
+ config.map { |key, value| key }.should eq [:size, :section]
239
+ end
240
+ end
241
+ end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
5
4
  prerelease:
5
+ version: 0.3.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jacques Crocker
@@ -10,88 +10,104 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-07-06 00:00:00.000000000 Z
13
+ date: 2012-12-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ! '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '3.0'
21
+ none: false
22
+ prerelease: false
16
23
  name: activesupport
17
24
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
25
  requirements:
20
26
  - - ! '>='
21
27
  - !ruby/object:Gem::Version
22
28
  version: '3.0'
29
+ none: false
23
30
  type: :runtime
24
- prerelease: false
31
+ - !ruby/object:Gem::Dependency
25
32
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
33
  requirements:
28
34
  - - ! '>='
29
35
  - !ruby/object:Gem::Version
30
- version: '3.0'
31
- - !ruby/object:Gem::Dependency
36
+ version: '0'
37
+ none: false
38
+ prerelease: false
32
39
  name: rake
33
40
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
41
  requirements:
36
42
  - - ! '>='
37
43
  - !ruby/object:Gem::Version
38
44
  version: '0'
45
+ none: false
39
46
  type: :development
40
- prerelease: false
47
+ - !ruby/object:Gem::Dependency
41
48
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
49
  requirements:
44
50
  - - ! '>='
45
51
  - !ruby/object:Gem::Version
46
52
  version: '0'
47
- - !ruby/object:Gem::Dependency
48
- name: rspec
53
+ none: false
54
+ prerelease: false
55
+ name: rdoc
49
56
  requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
50
61
  none: false
62
+ type: :development
63
+ - !ruby/object:Gem::Dependency
64
+ version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - ~>
53
67
  - !ruby/object:Gem::Version
54
68
  version: '2.0'
55
- type: :development
56
- prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
58
69
  none: false
70
+ prerelease: false
71
+ name: rspec
72
+ requirement: !ruby/object:Gem::Requirement
59
73
  requirements:
60
74
  - - ~>
61
75
  - !ruby/object:Gem::Version
62
76
  version: '2.0'
63
- - !ruby/object:Gem::Dependency
64
- name: autotest
65
- requirement: !ruby/object:Gem::Requirement
66
77
  none: false
78
+ type: :development
79
+ - !ruby/object:Gem::Dependency
80
+ version_requirements: !ruby/object:Gem::Requirement
67
81
  requirements:
68
82
  - - ! '>='
69
83
  - !ruby/object:Gem::Version
70
84
  version: '0'
71
- type: :development
72
- prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
74
85
  none: false
86
+ prerelease: false
87
+ name: autotest
88
+ requirement: !ruby/object:Gem::Requirement
75
89
  requirements:
76
90
  - - ! '>='
77
91
  - !ruby/object:Gem::Version
78
92
  version: '0'
79
- - !ruby/object:Gem::Dependency
80
- name: growl-glue
81
- requirement: !ruby/object:Gem::Requirement
82
93
  none: false
94
+ type: :development
95
+ - !ruby/object:Gem::Dependency
96
+ version_requirements: !ruby/object:Gem::Requirement
83
97
  requirements:
84
98
  - - ! '>='
85
99
  - !ruby/object:Gem::Version
86
100
  version: '0'
87
- type: :development
88
- prerelease: false
89
- version_requirements: !ruby/object:Gem::Requirement
90
101
  none: false
102
+ prerelease: false
103
+ name: growl-glue
104
+ requirement: !ruby/object:Gem::Requirement
91
105
  requirements:
92
106
  - - ! '>='
93
107
  - !ruby/object:Gem::Version
94
108
  version: '0'
109
+ none: false
110
+ type: :development
95
111
  description: Easy to use Settings helper that loads its data in from config/settings.yml.
96
112
  Handles adding multiple sources, and easy reloading.
97
113
  email:
@@ -150,23 +166,23 @@ rdoc_options:
150
166
  require_paths:
151
167
  - lib
152
168
  required_ruby_version: !ruby/object:Gem::Requirement
153
- none: false
154
169
  requirements:
155
170
  - - ! '>='
156
171
  - !ruby/object:Gem::Version
157
172
  version: '0'
158
173
  segments:
159
174
  - 0
160
- hash: 128564019799295977
161
- required_rubygems_version: !ruby/object:Gem::Requirement
175
+ hash: -3137865863593940262
162
176
  none: false
177
+ required_rubygems_version: !ruby/object:Gem::Requirement
163
178
  requirements:
164
179
  - - ! '>='
165
180
  - !ruby/object:Gem::Version
166
181
  version: '0'
167
182
  segments:
168
183
  - 0
169
- hash: 128564019799295977
184
+ hash: -3137865863593940262
185
+ none: false
170
186
  requirements: []
171
187
  rubyforge_project:
172
188
  rubygems_version: 1.8.24