cascading-configuration-setting 2.1.6 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,46 @@
1
+ == 7/13/2011
2
+
3
+ Initial release.
4
+
5
+ == 7/14/2011
6
+
7
+ * CascadingConfiguration::ConfigurationSetting renamed to CascadingConfiguration::Setting
8
+
9
+ == 7/14/2011
10
+
11
+ Added Instance configuration in addition to Local.
12
+ Instance is only the instance being extended.
13
+ Local configuration is the instance being extended plus if a module, any including modules and instances of any including class, or if a class the class plus instances.
14
+
15
+ == 8/8/2011
16
+
17
+ Added :attr_object_configuration and :attr_instance_configuration and refined :attr_local_configuration.
18
+
19
+ == 1/16/2012
20
+
21
+ Major overhaul to internals.
22
+ Fixes for instances.
23
+ Fixes for inheritance.
24
+ Far cleaner, faster, smaller code.
25
+ Inheritance code is all integrated into cascading-configuration-variable, now, which offers an impressive use-case for module-cluster.
26
+
27
+ == 1/18/2012
28
+
29
+ Fixes for multiple configuration inheritance. Youngest definition wins.
30
+
31
+ == 2/3/2012
32
+
33
+ Slimmed down, internals fixes for convenience. Much faster.
34
+
35
+ == 3/4/2012
36
+
37
+ Significantly reduced redundant code.
38
+ Added accessor-utilities support, meaning now configurations can be named with ? at the end, which creates :method? and :method=".
39
+
40
+ == 3/18/2012
41
+
42
+ Method definition moved to ::CascadingConfiguration::Methods based on configuration method. Less source code to maintain, and easier to add further modules!
43
+
44
+ == 6/18/2012
45
+
46
+ Merged into cascading-configuration.
data/README.md CHANGED
@@ -4,200 +4,16 @@ http://rubygems.org/gems/cascading-configuration-setting
4
4
 
5
5
  # Description #
6
6
 
7
- Adds methods for cascading configuration settings. Support package for cascading-configuration.
7
+ Now just a thin wrapper for cascading-configuration.
8
8
 
9
9
  # Summary #
10
10
 
11
- Cascading configuration methods for settings, which returns the appropriate lowest accumulated value. Configuration inheritance can cascade through modules, classes, and to instances.
12
-
13
- This means that we can create configuration modules, optionally setting configuration defaults, and include those configuration modules in other modules or classes.
11
+ Deprecated.
14
12
 
15
13
  # Install #
16
14
 
17
15
  * sudo gem install cascading-configuration
18
16
 
19
- # Usage #
20
-
21
- Including the module will enable support for singleton and for instances.
22
-
23
- ```ruby
24
- module AnyModuleOrClass
25
- include CascadingConfiguration::Setting
26
- end
27
- ```
28
-
29
- Extending the module will enable support for singleton only.
30
-
31
- ```ruby
32
- module AnyModuleOrClass
33
- extend CascadingConfiguration::Setting
34
- end
35
- ```
36
-
37
- Including or extending CascadingConfiguration includes or extends:
38
-
39
- * CascadingConfiguration::Variable
40
-
41
- ## :attr_configuration ##
42
-
43
- :attr_configuration provides inheritable single-object configurations that cascades downward. The value lowest in the ancestor hierarchy will be returned.
44
-
45
- Define initial configuration in a module or class:
46
-
47
- ```ruby
48
- module SomeModule
49
-
50
- include CascadingConfiguration::Setting
51
-
52
- attr_configuration :some_setting
53
-
54
- some_setting # => nil
55
-
56
- # note: if we don't specify the receiver here (self) assignment creates local variable instead
57
- self.some_setting = :some_value
58
-
59
- some_setting # => :some_value
60
-
61
- end
62
- ```
63
-
64
- Include initial module in a module or class:
65
-
66
- ```ruby
67
- class SomeClass
68
-
69
- include SomeModule
70
-
71
- some_setting # => :some_value
72
-
73
- self.some_setting = :some_other_value
74
-
75
- some_setting # => :some_other_value
76
-
77
- SomeModule.some_setting # => :some_value
78
-
79
- end
80
- ```
81
-
82
- And it cascades to instances:
83
-
84
- ```ruby
85
- instance = SomeClass.new
86
-
87
- instance.some_setting.should == :some_value
88
-
89
- instance.some_setting = :another_value
90
-
91
- instance.some_setting.should == :another_value
92
- ```
93
-
94
- ### :attr_module_configuration, :attr_class_configuration ###
95
-
96
- :attr_class_configuration works like :attr_configuration but does not cascade to instances.
97
-
98
- Define initial configuration in a module or class:
99
-
100
- ```ruby
101
- module SomeModule
102
-
103
- include CascadingConfiguration::Setting
104
-
105
- attr_class_configuration :some_setting
106
-
107
- some_setting # => nil
108
-
109
- self.some_setting = :some_value
110
-
111
- some_setting # => :some_value
112
-
113
- end
114
- ```
115
-
116
- Include initial module in a module or class:
117
-
118
- ```ruby
119
- class SomeClass
120
-
121
- include SomeModule
122
-
123
- some_setting # => :some_value
124
-
125
- self.some_setting = :some_other_value
126
-
127
- some_setting # => :some_other_value
128
-
129
- SomeModule.some_setting # => :some_value
130
-
131
- end
132
- ```
133
-
134
- And it does not cascade to instances:
135
-
136
- ```ruby
137
- instance = SomeClass.new
138
-
139
- instance.respond_to?( :some_setting ).should == false
140
- ```
141
-
142
- ### :attr_local_configuration ###
143
-
144
- :attr_local_configuration works like :attr_configuration but does not cascade. This is primarily useful for creating local configurations maintained in parallel with cascading configurations (for instance, with the same variable prefixes), for overriding the local configuration method, and for hiding the configuration variable (coming soon).
145
-
146
- Define initial configuration in a module or class:
147
-
148
- ```ruby
149
- module SomeModule
150
-
151
- include CascadingConfiguration::Setting
152
-
153
- attr_local_configuration :some_setting
154
-
155
- some_setting # => nil
156
-
157
- self.some_setting = :some_value
158
-
159
- some_setting # => :some_value
160
-
161
- end
162
- ```
163
-
164
- Include initial module in a module or class:
165
-
166
- ```ruby
167
- class SomeClass
168
-
169
- include SomeModule
170
-
171
- respond_to?( :some_setting ).should == false
172
-
173
- end
174
- ```
175
-
176
- ## Additional Functionality ##
177
-
178
- Cascading-configuration also provides several other convenience functions.
179
-
180
- ### Method Redefinition ###
181
-
182
- Any declared configuration is defined in order to support locally redefining the method and accessing the original by calling super.
183
-
184
- ```ruby
185
- module SomeModule
186
-
187
- include CascadingConfiguration
188
-
189
- attr_configuration :some_array_setting
190
-
191
- def some_array_setting=( value )
192
- puts 'Replacing configuration array!'
193
- super
194
- end
195
-
196
- end
197
- ```
198
-
199
- Causes configuration variable to be stored in external context so that it is not included in instance variables.
200
-
201
17
  # License #
202
18
 
203
19
  (The MIT License)
data/README.rdoc CHANGED
@@ -4,30 +4,16 @@ http://rubygems.org/gems/cascading-configuration-setting
4
4
 
5
5
  == Description
6
6
 
7
- Adds methods for cascading configuration settings. Support package for cascading-configuration.
7
+ Now just a thin wrapper for cascading-configuration.
8
8
 
9
9
  == Summary
10
10
 
11
- Cascading configuration methods for settings, which returns the appropriate lowest accumulated value. Configuration inheritance can cascade through modules, classes, and to instances.
12
-
13
- This means that we can create configuration modules, optionally setting configuration defaults, and include those configuration modules in other modules or classes.
14
-
15
- == :attr_configuration
16
-
17
- :attr_configuration provides inheritable single-object configurations that cascades downward. The value lowest in the ancestor hierarchy will be returned.
18
-
19
- :attr_class_configuration works like :attr_configuration but does not cascade to instances.
20
-
21
- :attr_local_configuration works like :attr_configuration but does not cascade. This is primarily useful for creating local configurations maintained in parallel with cascading configurations (for instance, with the same variable prefixes), for overriding the local configuration method, and for hiding the configuration variable (coming soon).
11
+ Deprecated.
22
12
 
23
13
  == Install
24
14
 
25
15
  * sudo gem install cascading-configuration
26
16
 
27
- == Usage
28
-
29
- See README.md
30
-
31
17
  == License
32
18
 
33
19
  (The MIT License)
@@ -1,13 +1,2 @@
1
1
 
2
- if $__cascading_configuration__spec__development
3
- require_relative '../../definition/lib/cascading-configuration-definition.rb'
4
- else
5
- require 'cascading-configuration-definition'
6
- end
7
-
8
- module ::CascadingConfiguration
9
- module Setting
10
- end
11
- end
12
-
13
- require_relative 'cascading-configuration-setting/CascadingConfiguration/Setting.rb'
2
+ require 'cascading-configuration'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cascading-configuration-setting
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.6
4
+ version: 3.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-23 00:00:00.000000000 Z
12
+ date: 2012-06-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: cascading-configuration-definition
16
- requirement: &70321139171620 !ruby/object:Gem::Requirement
15
+ name: cascading-configuration
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,19 +21,23 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70321139171620
25
- description: Provides :attr_configuration.
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: Now just a thin wrapper for cascading-configuration.
26
31
  email: asher@ridiculouspower.com
27
32
  executables: []
28
33
  extensions: []
29
34
  extra_rdoc_files: []
30
35
  files:
31
- - lib/cascading-configuration-setting/CascadingConfiguration/Setting.rb
32
36
  - lib/cascading-configuration-setting.rb
33
- - spec/CascadingConfiguration/Setting_spec.rb
34
37
  - README.md
35
38
  - README.rdoc
36
- homepage: http://rubygems.org/gems/cascading-configuration-setting
39
+ - CHANGELOG.rdoc
40
+ homepage: http://rubygems.org/gems/cascading-configuration
37
41
  licenses: []
38
42
  post_install_message:
39
43
  rdoc_options: []
@@ -53,8 +57,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
53
57
  version: '0'
54
58
  requirements: []
55
59
  rubyforge_project: cascading-configuration-setting
56
- rubygems_version: 1.8.11
60
+ rubygems_version: 1.8.23
57
61
  signing_key:
58
62
  specification_version: 3
59
- summary: Support package for cascading-configuration.
63
+ summary: Deprecated.
60
64
  test_files: []
65
+ has_rdoc:
@@ -1,16 +0,0 @@
1
-
2
- module ::CascadingConfiguration::Setting
3
-
4
- include ::CascadingConfiguration::Variable
5
- include ::CascadingConfiguration::Inheritance
6
-
7
- def attr_configuration( *configuration_names ) ;; end
8
- def attr_module_configuration( *configuration_names ) ;; end
9
- def attr_class_configuration( *configuration_names ) ;; end
10
- def attr_local_configuration( *configuration_names ) ;; end
11
- def attr_object_configuration( *configuration_names ) ;; end
12
- def attr_instance_configuration( *configuration_names ) ;; end
13
-
14
- ::CascadingConfiguration::Definition.declare_cascading_configuration( self, nil )
15
-
16
- end
@@ -1,692 +0,0 @@
1
-
2
- if $__cascading_configuration__spec__development
3
- require_relative '../../lib/cascading-configuration-setting.rb'
4
- else
5
- require 'cascading-configuration-setting'
6
- end
7
-
8
- describe CascadingConfiguration::Setting do
9
-
10
- ########################
11
- # attr_configuration #
12
- ########################
13
-
14
- it 'can define a configuration setting, which is the primary interface' do
15
-
16
- # extending a module or class works like a finalizer for the cascading configuration
17
- # if the configuration is re-opened at a later point (including or extending a lower ancestor)
18
- # then the configuration will still cascade upward
19
- # this permits ancestors in the heirarchy to skip out on configurations
20
- # upward cascade can be frozen at any point using :freeze!, which will prevent further upward lookup
21
-
22
- # possibilities:
23
- # * module extended with setting
24
- module ::CascadingConfiguration::Setting::ConfigurationMockExtended
25
- extend CascadingConfiguration::Setting
26
- # => singleton gets attr_configuration and configurations
27
- respond_to?( :attr_configuration ).should == true
28
- attr_configuration :some_configuration
29
- respond_to?( :some_configuration ).should == true
30
- self.some_configuration = :our_setting_value
31
- some_configuration.should == :our_setting_value
32
- instance_methods.include?( :some_configuration ).should == false
33
- instance_variables.empty?.should == true
34
- # => including modules and classes get nothing
35
- module SubmoduleIncluding
36
- include CascadingConfiguration::Setting::ConfigurationMockExtended
37
- instance_methods.include?( :some_configuration ).should == false
38
- respond_to?( :some_configuration ).should == false
39
- instance_variables.empty?.should == true
40
- end
41
- # => extending modules and classes get nothing
42
- module SubmoduleExtending
43
- extend CascadingConfiguration::Setting::ConfigurationMockExtended
44
- instance_methods.include?( :some_configuration ).should == false
45
- respond_to?( :some_configuration ).should == false
46
- instance_variables.empty?.should == true
47
- end
48
- # => instances of including and extending classes get nothing
49
- class ClassIncluding
50
- include CascadingConfiguration::Setting::ConfigurationMockExtended
51
- instance_methods.include?( :some_configuration ).should == false
52
- respond_to?( :some_configuration ).should == false
53
- instance_variables.empty?.should == true
54
- end
55
- class ClassExtending
56
- extend CascadingConfiguration::Setting::ConfigurationMockExtended
57
- instance_methods.include?( :some_configuration ).should == false
58
- respond_to?( :some_configuration ).should == false
59
- instance_variables.empty?.should == true
60
- end
61
- end
62
-
63
- # * module included with setting
64
- module ::CascadingConfiguration::Setting::ConfigurationMockIncluded
65
- include CascadingConfiguration::Setting
66
- # => singleton gets attr_configuration and configurations
67
- eigenclass = class << self ; self ; end
68
- respond_to?( :attr_configuration ).should == true
69
- attr_configuration :some_configuration
70
- respond_to?( :some_configuration ).should == true
71
- self.some_configuration = :our_setting_value
72
- some_configuration.should == :our_setting_value
73
- instance_methods.include?( :some_configuration ).should == true
74
- instance_variables.empty?.should == true
75
- # => including modules and classes get attr_configuration and configurations
76
- module SubmoduleIncluding
77
- include CascadingConfiguration::Setting::ConfigurationMockIncluded
78
- instance_methods.include?( :some_configuration ).should == true
79
- respond_to?( :some_configuration ).should == true
80
- some_configuration.should == :our_setting_value
81
- self.some_configuration = :another_configuration
82
- some_configuration.should == :another_configuration
83
- instance_variables.empty?.should == true
84
- end
85
- # => extending modules and classes get attr_configuration and configurations
86
- module SubmoduleExtending
87
- extend CascadingConfiguration::Setting::ConfigurationMockIncluded
88
- # if we're extended then we want to use the eigenclass ancestor chain
89
- # - the first ancestor will be the extending module
90
- # - the rest of the ancestors will be the extending module's include chain
91
- respond_to?( :some_configuration ).should == true
92
- some_configuration.should == :our_setting_value
93
- self.some_configuration = :some_other_configuration
94
- some_configuration.should == :some_other_configuration
95
- instance_methods.include?( :some_configuration ).should == false
96
- instance_variables.empty?.should == true
97
- end
98
- # => instances of including classes get configurations
99
- class ClassIncluding
100
- include CascadingConfiguration::Setting::ConfigurationMockIncluded
101
- instance_methods.include?( :some_configuration ).should == true
102
- respond_to?( :some_configuration ).should == true
103
- some_configuration.should == :our_setting_value
104
- self.some_configuration = :another_configuration
105
- some_configuration.should == :another_configuration
106
- instance_variables.empty?.should == true
107
- end
108
- setting_class_including_instance = ClassIncluding.new
109
- setting_class_including_instance.respond_to?( :some_configuration ).should == true
110
- setting_class_including_instance.some_configuration.should == :another_configuration
111
- self.some_configuration = :our_setting_value
112
- some_configuration.should == :our_setting_value
113
- setting_class_including_instance.instance_variables.empty?.should == true
114
- # => instances of extending classes get nothing
115
- class ClassExtending
116
- extend CascadingConfiguration::Setting::ConfigurationMockIncluded
117
- respond_to?( :some_configuration ).should == true
118
- some_configuration.should == :our_setting_value
119
- self.some_configuration = :some_other_configuration
120
- some_configuration.should == :some_other_configuration
121
- instance_methods.include?( :some_configuration ).should == false
122
- instance_variables.empty?.should == true
123
- end
124
- setting_class_including_instance = ClassExtending.new
125
- setting_class_including_instance.respond_to?( :some_configuration ).should == false
126
- setting_class_including_instance.instance_variables.empty?.should == true
127
- end
128
-
129
- class CascadingConfiguration::Setting::ConfigurationMockClass
130
- include CascadingConfiguration::Setting::ConfigurationMockIncluded::SubmoduleIncluding
131
- respond_to?( :some_configuration ).should == true
132
- some_configuration.should == :another_configuration
133
- self.some_configuration = :our_setting_value
134
- some_configuration.should == :our_setting_value
135
- instance_variables.empty?.should == true
136
- end
137
- class CascadingConfiguration::Setting::ConfigurationMockClassSub1 < CascadingConfiguration::Setting::ConfigurationMockClass
138
- some_configuration.should == :our_setting_value
139
- self.some_configuration = :our_other_setting_value
140
- some_configuration.should == :our_other_setting_value
141
- instance_variables.empty?.should == true
142
- end
143
- class CascadingConfiguration::Setting::ConfigurationMockClassSub2 < CascadingConfiguration::Setting::ConfigurationMockClassSub1
144
- some_configuration.should == :our_other_setting_value
145
- self.some_configuration = :a_third_setting_value
146
- some_configuration.should == :a_third_setting_value
147
- instance_variables.empty?.should == true
148
- end
149
-
150
- module SomeModule
151
- include CascadingConfiguration::Setting
152
- attr_configuration :some_configuration
153
- self.some_configuration = :another_configuration
154
- end
155
- module OtherModule
156
- include SomeModule
157
- end
158
- Object.new.instance_eval do
159
- extend( OtherModule )
160
- respond_to?( :some_configuration ).should == true
161
- some_configuration.should == :another_configuration
162
- self.some_configuration = :our_setting_value
163
- some_configuration.should == :our_setting_value
164
- instance_variables.empty?.should == true
165
- end
166
-
167
- end
168
-
169
- ###############################
170
- # attr_module_configuration #
171
- # attr_class_configuration #
172
- ###############################
173
-
174
- it 'can define a class configuration setting, which will not cascade to instances' do
175
-
176
- # extending a module or class works like a finalizer for the cascading configuration
177
- # if the configuration is re-opened at a later point (including or extending a lower ancestor)
178
- # then the configuration will still cascade upward
179
- # this permits ancestors in the hierarchy to skip out on configurations
180
- # upward cascade can be frozen at any point using :freeze!, which will prevent further upward lookup
181
-
182
- # possibilities:
183
- # * module extended with setting
184
- module ::CascadingConfiguration::Setting::ClassConfigurationMockExtended
185
- extend CascadingConfiguration::Setting
186
- # => singleton gets attr_module_configuration and configurations
187
- respond_to?( :attr_module_configuration ).should == true
188
- method( :attr_module_configuration ).should == method( :attr_class_configuration )
189
- attr_module_configuration :some_configuration
190
- respond_to?( :attr_module_configuration ).should == true
191
- self.some_configuration = :our_setting_value
192
- some_configuration.should == :our_setting_value
193
- instance_methods.include?( :some_configuration ).should == false
194
- instance_variables.empty?.should == true
195
- # => including modules and classes get nothing
196
- module SubmoduleIncluding
197
- include CascadingConfiguration::Setting::ClassConfigurationMockExtended
198
- instance_methods.include?( :some_configuration ).should == false
199
- respond_to?( :some_configuration ).should == false
200
- instance_variables.empty?.should == true
201
- end
202
- # => extending modules and classes get nothing
203
- module SubmoduleExtending
204
- extend CascadingConfiguration::Setting::ClassConfigurationMockExtended
205
- instance_methods.include?( :some_configuration ).should == false
206
- respond_to?( :some_configuration ).should == false
207
- instance_variables.empty?.should == true
208
- end
209
- # => instances of including and extending classes get nothing
210
- class ClassIncluding
211
- include CascadingConfiguration::Setting::ClassConfigurationMockExtended
212
- instance_methods.include?( :some_configuration ).should == false
213
- respond_to?( :some_configuration ).should == false
214
- instance_variables.empty?.should == true
215
- end
216
- class ClassExtending
217
- extend CascadingConfiguration::Setting::ClassConfigurationMockExtended
218
- instance_methods.include?( :some_configuration ).should == false
219
- respond_to?( :some_configuration ).should == false
220
- instance_variables.empty?.should == true
221
- end
222
- end
223
-
224
- # * module included with setting
225
- module ::CascadingConfiguration::Setting::ClassConfigurationMockIncluded
226
- include CascadingConfiguration::Setting
227
- # => singleton gets attr_module_configuration and configurations
228
- respond_to?( :attr_module_configuration ).should == true
229
- attr_module_configuration :some_configuration
230
- respond_to?( :some_configuration ).should == true
231
- self.some_configuration = :our_setting_value
232
- some_configuration.should == :our_setting_value
233
- instance_methods.include?( :some_configuration ).should == false
234
- instance_variables.empty?.should == true
235
- # => including modules and classes get attr_module_configuration and configurations
236
- module SubmoduleIncluding
237
- include CascadingConfiguration::Setting::ClassConfigurationMockIncluded
238
- instance_methods.include?( :some_configuration ).should == false
239
- respond_to?( :some_configuration ).should == true
240
- some_configuration.should == :our_setting_value
241
- self.some_configuration = :another_configuration
242
- some_configuration.should == :another_configuration
243
- instance_variables.empty?.should == true
244
- end
245
- # => extending modules and classes get attr_module_configuration and configurations
246
- module SubmoduleExtending
247
- extend CascadingConfiguration::Setting::ClassConfigurationMockIncluded
248
- # if we're extended then we want to use the eigenclass ancestor chain
249
- # - the first ancestor will be the extending module
250
- # - the rest of the ancestors will be the extending module's include chain
251
- respond_to?( :some_configuration ).should == true
252
- some_configuration.should == :our_setting_value
253
- self.some_configuration = :some_other_configuration
254
- some_configuration.should == :some_other_configuration
255
- instance_methods.include?( :some_configuration ).should == false
256
- instance_variables.empty?.should == true
257
- end
258
- # => instances of including classes get configurations
259
- class ClassIncluding
260
- include CascadingConfiguration::Setting::ClassConfigurationMockIncluded
261
- instance_methods.include?( :some_configuration ).should == false
262
- respond_to?( :some_configuration ).should == true
263
- some_configuration.should == :our_setting_value
264
- self.some_configuration = :another_configuration
265
- some_configuration.should == :another_configuration
266
- instance_variables.empty?.should == true
267
- end
268
- setting_class_including_instance = ClassIncluding.new
269
- setting_class_including_instance.respond_to?( :some_configuration ).should == false
270
- setting_class_including_instance.instance_variables.empty?.should == true
271
- # => instances of extending classes get nothing
272
- class ClassExtending
273
- extend CascadingConfiguration::Setting::ClassConfigurationMockIncluded
274
- respond_to?( :some_configuration ).should == true
275
- some_configuration.should == :our_setting_value
276
- self.some_configuration = :some_other_configuration
277
- some_configuration.should == :some_other_configuration
278
- instance_methods.include?( :some_configuration ).should == false
279
- instance_variables.empty?.should == true
280
- end
281
- setting_class_including_instance = ClassExtending.new
282
- setting_class_including_instance.respond_to?( :some_configuration ).should == false
283
- setting_class_including_instance.instance_variables.empty?.should == true
284
- end
285
-
286
- class CascadingConfiguration::Setting::ClassConfigurationMockClass
287
- include CascadingConfiguration::Setting::ClassConfigurationMockIncluded::SubmoduleIncluding
288
- respond_to?( :some_configuration ).should == true
289
- some_configuration.should == :another_configuration
290
- self.some_configuration = :our_setting_value
291
- some_configuration.should == :our_setting_value
292
- instance_variables.empty?.should == true
293
- end
294
- class CascadingConfiguration::Setting::ClassConfigurationMockClassSub1 < CascadingConfiguration::Setting::ClassConfigurationMockClass
295
- some_configuration.should == :our_setting_value
296
- self.some_configuration = :our_other_setting_value
297
- some_configuration.should == :our_other_setting_value
298
- instance_variables.empty?.should == true
299
- end
300
- class CascadingConfiguration::Setting::ClassConfigurationMockClassSub2 < CascadingConfiguration::Setting::ClassConfigurationMockClassSub1
301
- some_configuration.should == :our_other_setting_value
302
- self.some_configuration = :a_third_setting_value
303
- some_configuration.should == :a_third_setting_value
304
- instance_variables.empty?.should == true
305
- end
306
-
307
- end
308
-
309
- ##############################
310
- # attr_local_configuration #
311
- ##############################
312
-
313
- it 'can define a local configuration setting, which cascades to the first class and instances' do
314
-
315
- # extending a module or class works like a finalizer for the cascading configuration
316
- # if the configuration is re-opened at a later point (including or extending a lower ancestor)
317
- # then the configuration will still cascade upward
318
- # this permits ancestors in the heirarchy to skip out on configurations
319
- # upward cascade can be frozen at any point using :freeze!, which will prevent further upward lookup
320
-
321
- # possibilities:
322
- # * module extended with setting
323
- module ::CascadingConfiguration::Setting::LocalConfigurationMockExtended
324
- extend CascadingConfiguration::Setting
325
- # => singleton gets attr_configuration and configurations
326
- respond_to?( :attr_local_configuration ).should == true
327
- attr_local_configuration :some_configuration
328
- respond_to?( :some_configuration ).should == true
329
- self.some_configuration = :our_setting_value
330
- some_configuration.should == :our_setting_value
331
- instance_methods.include?( :some_configuration ).should == false
332
- instance_variables.empty?.should == true
333
- # => including modules and classes get nothing
334
- module SubmoduleIncluding
335
- include CascadingConfiguration::Setting::LocalConfigurationMockExtended
336
- instance_methods.include?( :some_configuration ).should == false
337
- respond_to?( :some_configuration ).should == false
338
- instance_variables.empty?.should == true
339
- end
340
- # => extending modules and classes get nothing
341
- module SubmoduleExtending
342
- extend CascadingConfiguration::Setting::LocalConfigurationMockExtended
343
- instance_methods.include?( :some_configuration ).should == false
344
- respond_to?( :some_configuration ).should == false
345
- instance_variables.empty?.should == true
346
- end
347
- # => instances of including and extending classes get nothing
348
- class ClassIncluding
349
- include CascadingConfiguration::Setting::LocalConfigurationMockExtended
350
- instance_methods.include?( :some_configuration ).should == false
351
- respond_to?( :some_configuration ).should == false
352
- instance_variables.empty?.should == true
353
- end
354
- class ClassExtending
355
- extend CascadingConfiguration::Setting::LocalConfigurationMockExtended
356
- instance_methods.include?( :some_configuration ).should == false
357
- respond_to?( :some_configuration ).should == false
358
- instance_variables.empty?.should == true
359
- end
360
- end
361
-
362
- # * module included with setting
363
- module ::CascadingConfiguration::Setting::LocalConfigurationMockIncluded
364
- include CascadingConfiguration::Setting
365
- # => singleton gets attr_configuration and configurations
366
- respond_to?( :attr_local_configuration ).should == true
367
- attr_local_configuration :some_configuration
368
- respond_to?( :some_configuration ).should == true
369
- self.some_configuration = :our_setting_value
370
- some_configuration.should == :our_setting_value
371
- instance_methods.include?( :some_configuration ).should == true
372
- instance_variables.empty?.should == true
373
- # => including modules and classes get attr_configuration and configurations
374
- module SubmoduleIncluding
375
- include CascadingConfiguration::Setting::LocalConfigurationMockIncluded
376
- instance_methods.include?( :some_configuration ).should == true
377
- respond_to?( :some_configuration ).should == false
378
- instance_variables.empty?.should == true
379
- end
380
- module SubSubmoduleIncluding
381
- include CascadingConfiguration::Setting::LocalConfigurationMockIncluded::SubmoduleIncluding
382
- instance_methods.include?( :some_configuration ).should == true
383
- respond_to?( :some_configuration ).should == false
384
- instance_variables.empty?.should == true
385
- end
386
- # => extending modules and classes get attr_configuration and configurations
387
- module SubmoduleExtending
388
- extend CascadingConfiguration::Setting::LocalConfigurationMockIncluded
389
- # if we're extended then we want to use the eigenclass ancestor chain
390
- # - the first ancestor will be the extending module
391
- # - the rest of the ancestors will be the extending module's include chain
392
- respond_to?( :some_configuration ).should == true
393
- instance_methods.include?( :some_configuration ).should == false
394
- instance_variables.empty?.should == true
395
- end
396
- module SubSubmoduleExtending
397
- extend CascadingConfiguration::Setting::LocalConfigurationMockIncluded::SubmoduleExtending
398
- # if we're extended then we want to use the eigenclass ancestor chain
399
- # - the first ancestor will be the extending module
400
- # - the rest of the ancestors will be the extending module's include chain
401
- respond_to?( :some_configuration ).should == false
402
- instance_methods.include?( :some_configuration ).should == false
403
- instance_variables.empty?.should == true
404
- end
405
- # => instances of including classes get configurations
406
- class ClassIncluding
407
- include CascadingConfiguration::Setting::LocalConfigurationMockIncluded
408
- instance_methods.include?( :some_configuration ).should == true
409
- respond_to?( :some_configuration ).should == false
410
- instance_variables.empty?.should == true
411
- end
412
- setting_class_including_instance = ClassIncluding.new
413
- setting_class_including_instance.respond_to?( :some_configuration ).should == true
414
- setting_class_including_instance.instance_variables.empty?.should == true
415
- # => instances of extending classes get nothing
416
- class ClassExtending
417
- extend CascadingConfiguration::Setting::LocalConfigurationMockIncluded
418
- respond_to?( :some_configuration ).should == true
419
- instance_methods.include?( :some_configuration ).should == false
420
- instance_variables.empty?.should == true
421
- end
422
- setting_class_including_instance = ClassExtending.new
423
- setting_class_including_instance.respond_to?( :some_configuration ).should == false
424
- setting_class_including_instance.instance_variables.empty?.should == true
425
- class ClassSubSubmoduleIncludingIncluding
426
- include CascadingConfiguration::Setting::LocalConfigurationMockIncluded::SubSubmoduleIncluding
427
- respond_to?( :some_configuration ).should == false
428
- instance_methods.include?( :some_configuration ).should == true
429
- instance_variables.empty?.should == true
430
- end
431
- setting_class_including_instance = ClassSubSubmoduleIncludingIncluding.new
432
- setting_class_including_instance.respond_to?( :some_configuration ).should == true
433
- setting_class_including_instance.instance_variables.empty?.should == true
434
- class ClassSubSubmoduleIncludingExtending
435
- extend CascadingConfiguration::Setting::LocalConfigurationMockIncluded::SubSubmoduleIncluding
436
- respond_to?( :some_configuration ).should == true
437
- instance_methods.include?( :some_configuration ).should == false
438
- instance_variables.empty?.should == true
439
- end
440
- setting_class_including_instance = ClassSubSubmoduleIncludingExtending.new
441
- setting_class_including_instance.respond_to?( :some_configuration ).should == false
442
- setting_class_including_instance.instance_variables.empty?.should == true
443
- class ClassSubSubmoduleIncludingIncludingAndExtending
444
- include CascadingConfiguration::Setting::LocalConfigurationMockIncluded::SubSubmoduleIncluding
445
- extend CascadingConfiguration::Setting::LocalConfigurationMockIncluded::SubSubmoduleIncluding
446
- respond_to?( :some_configuration ).should == true
447
- instance_methods.include?( :some_configuration ).should == true
448
- instance_variables.empty?.should == true
449
- end
450
- setting_class_including_instance = ClassSubSubmoduleIncludingIncludingAndExtending.new
451
- setting_class_including_instance.respond_to?( :some_configuration ).should == true
452
- setting_class_including_instance.instance_variables.empty?.should == true
453
- end
454
-
455
- class CascadingConfiguration::Setting::LocalConfigurationMockClass
456
- include CascadingConfiguration::Setting::LocalConfigurationMockIncluded::SubmoduleIncluding
457
- respond_to?( :some_configuration ).should == false
458
- instance_variables.empty?.should == true
459
- end
460
- class CascadingConfiguration::Setting::LocalConfigurationMockClassSub1 < CascadingConfiguration::Setting::LocalConfigurationMockClass
461
- respond_to?( :some_configuration ).should == false
462
- instance_variables.empty?.should == true
463
- end
464
- class CascadingConfiguration::Setting::LocalConfigurationMockClassSub2 < CascadingConfiguration::Setting::LocalConfigurationMockClassSub1
465
- respond_to?( :some_configuration ).should == false
466
- instance_variables.empty?.should == true
467
- end
468
- end
469
-
470
- #################################
471
- # attr_instance_configuration #
472
- #################################
473
-
474
- it 'can define a configuration setting for the present instance, which will not cascade' do
475
-
476
- # possibilities:
477
- # * module extended with setting
478
- module ::CascadingConfiguration::Setting::InstanceConfigurationMockExtended
479
- extend CascadingConfiguration::Setting
480
- # => singleton gets attr_configuration and configurations
481
- respond_to?( :attr_instance_configuration ).should == true
482
- instance_methods.include?( :some_configuration ).should == false
483
- instance_variables.empty?.should == true
484
- # => including modules and classes get nothing
485
- module SubmoduleIncluding
486
- include CascadingConfiguration::Setting::InstanceConfigurationMockExtended
487
- instance_methods.include?( :some_configuration ).should == false
488
- respond_to?( :some_configuration ).should == false
489
- instance_variables.empty?.should == true
490
- end
491
- # => extending modules and classes get nothing
492
- module SubmoduleExtending
493
- extend CascadingConfiguration::Setting::InstanceConfigurationMockExtended
494
- instance_methods.include?( :some_configuration ).should == false
495
- respond_to?( :some_configuration ).should == false
496
- instance_variables.empty?.should == true
497
- end
498
- # => instances of including and extending classes get nothing
499
- class ClassIncluding
500
- include CascadingConfiguration::Setting::InstanceConfigurationMockExtended
501
- instance_methods.include?( :some_configuration ).should == false
502
- respond_to?( :some_configuration ).should == false
503
- instance_variables.empty?.should == true
504
- end
505
- class ClassExtending
506
- extend CascadingConfiguration::Setting::InstanceConfigurationMockExtended
507
- instance_methods.include?( :some_configuration ).should == false
508
- respond_to?( :some_configuration ).should == false
509
- instance_variables.empty?.should == true
510
- end
511
- end
512
-
513
- # * module included with setting
514
- module ::CascadingConfiguration::Setting::InstanceConfigurationMockIncluded
515
- include CascadingConfiguration::Setting
516
- # => singleton gets attr_configuration and configurations
517
- respond_to?( :attr_instance_configuration ).should == true
518
- respond_to?( :some_configuration ).should == false
519
- attr_instance_configuration :some_configuration
520
- respond_to?( :some_configuration ).should == false
521
- instance_methods.include?( :some_configuration ).should == true
522
- instance_variables.empty?.should == true
523
- # => including modules and classes get attr_configuration and configurations
524
- module SubmoduleIncluding
525
- include CascadingConfiguration::Setting::InstanceConfigurationMockIncluded
526
- instance_methods.include?( :some_configuration ).should == true
527
- respond_to?( :some_configuration ).should == false
528
- instance_variables.empty?.should == true
529
- end
530
- # => extending modules and classes get attr_configuration and configurations
531
- module SubmoduleExtending
532
- extend CascadingConfiguration::Setting::InstanceConfigurationMockIncluded
533
- # if we're extended then we want to use the eigenclass ancestor chain
534
- # - the first ancestor will be the extending module
535
- # - the rest of the ancestors will be the extending module's include chain
536
- respond_to?( :some_configuration ).should == true
537
- instance_methods.include?( :some_configuration ).should == false
538
- instance_variables.empty?.should == true
539
- end
540
- # => instances of including classes get configurations
541
- class ClassIncluding
542
- include CascadingConfiguration::Setting::InstanceConfigurationMockIncluded
543
- instance_methods.include?( :some_configuration ).should == true
544
- respond_to?( :some_configuration ).should == false
545
- instance_variables.empty?.should == true
546
- end
547
- setting_class_including_instance = ClassIncluding.new
548
- setting_class_including_instance.respond_to?( :some_configuration ).should == true
549
- setting_class_including_instance.instance_variables.empty?.should == true
550
- # => instances of extending classes get nothing
551
- class ClassExtending
552
- extend CascadingConfiguration::Setting::InstanceConfigurationMockIncluded
553
- respond_to?( :some_configuration ).should == true
554
- instance_methods.include?( :some_configuration ).should == false
555
- instance_variables.empty?.should == true
556
- end
557
- setting_class_including_instance = ClassExtending.new
558
- setting_class_including_instance.respond_to?( :some_configuration ).should == false
559
- setting_class_including_instance.instance_variables.empty?.should == true
560
- end
561
-
562
- class CascadingConfiguration::Setting::InstanceConfigurationMockClass
563
- include CascadingConfiguration::Setting::InstanceConfigurationMockIncluded::SubmoduleIncluding
564
- respond_to?( :some_configuration ).should == false
565
- instance_methods.include?( :some_configuration ).should == true
566
- instance_variables.empty?.should == true
567
- end
568
- class CascadingConfiguration::Setting::InstanceConfigurationMockClassSub1 < CascadingConfiguration::Setting::InstanceConfigurationMockClass
569
- respond_to?( :some_configuration ).should == false
570
- instance_methods.include?( :some_configuration ).should == true
571
- instance_variables.empty?.should == true
572
- end
573
- class CascadingConfiguration::Setting::InstanceConfigurationMockClassSub2 < CascadingConfiguration::Setting::InstanceConfigurationMockClassSub1
574
- respond_to?( :some_configuration ).should == false
575
- instance_methods.include?( :some_configuration ).should == true
576
- instance_variables.empty?.should == true
577
- end
578
- end
579
-
580
- ###############################
581
- # attr_object_configuration #
582
- ###############################
583
-
584
- it 'can define a configuration setting for the present instance, which will not cascade' do
585
-
586
- # possibilities:
587
- # * module extended with setting
588
- module ::CascadingConfiguration::Setting::ObjectConfigurationMockExtended
589
- extend CascadingConfiguration::Setting
590
- # => singleton gets attr_configuration and configurations
591
- respond_to?( :attr_object_configuration ).should == true
592
- attr_object_configuration :some_configuration
593
- respond_to?( :some_configuration ).should == true
594
- self.some_configuration = :our_setting_value
595
- some_configuration.should == :our_setting_value
596
- instance_methods.include?( :some_configuration ).should == false
597
- instance_variables.empty?.should == true
598
- # => including modules and classes get nothing
599
- module SubmoduleIncluding
600
- include CascadingConfiguration::Setting::ObjectConfigurationMockExtended
601
- instance_methods.include?( :some_configuration ).should == false
602
- respond_to?( :some_configuration ).should == false
603
- instance_variables.empty?.should == true
604
- end
605
- # => extending modules and classes get nothing
606
- module SubmoduleExtending
607
- extend CascadingConfiguration::Setting::ObjectConfigurationMockExtended
608
- instance_methods.include?( :some_configuration ).should == false
609
- respond_to?( :some_configuration ).should == false
610
- instance_variables.empty?.should == true
611
- end
612
- # => instances of including and extending classes get nothing
613
- class ClassIncluding
614
- include CascadingConfiguration::Setting::ObjectConfigurationMockExtended
615
- instance_methods.include?( :some_configuration ).should == false
616
- respond_to?( :some_configuration ).should == false
617
- instance_variables.empty?.should == true
618
- end
619
- class ClassExtending
620
- extend CascadingConfiguration::Setting::ObjectConfigurationMockExtended
621
- instance_methods.include?( :some_configuration ).should == false
622
- respond_to?( :some_configuration ).should == false
623
- instance_variables.empty?.should == true
624
- end
625
- end
626
-
627
- # * module included with setting
628
- module ::CascadingConfiguration::Setting::ObjectConfigurationMockIncluded
629
- include CascadingConfiguration::Setting
630
- # => singleton gets attr_configuration and configurations
631
- respond_to?( :attr_object_configuration ).should == true
632
- attr_object_configuration :some_configuration
633
- respond_to?( :some_configuration ).should == true
634
- self.some_configuration = :our_setting_value
635
- some_configuration.should == :our_setting_value
636
- instance_methods.include?( :some_configuration ).should == false
637
- instance_variables.empty?.should == true
638
- # => including modules and classes get attr_configuration and configurations
639
- module SubmoduleIncluding
640
- include CascadingConfiguration::Setting::ObjectConfigurationMockIncluded
641
- instance_methods.include?( :some_configuration ).should == false
642
- respond_to?( :some_configuration ).should == false
643
- instance_variables.empty?.should == true
644
- end
645
- # => extending modules and classes get attr_configuration and configurations
646
- module SubmoduleExtending
647
- extend CascadingConfiguration::Setting::ObjectConfigurationMockIncluded
648
- # if we're extended then we want to use the eigenclass ancestor chain
649
- # - the first ancestor will be the extending module
650
- # - the rest of the ancestors will be the extending module's include chain
651
- respond_to?( :some_configuration ).should == false
652
- instance_methods.include?( :some_configuration ).should == false
653
- instance_variables.empty?.should == true
654
- end
655
- # => instances of including classes get configurations
656
- class ClassIncluding
657
- include CascadingConfiguration::Setting::ObjectConfigurationMockIncluded
658
- instance_methods.include?( :some_configuration ).should == false
659
- respond_to?( :some_configuration ).should == false
660
- instance_variables.empty?.should == true
661
- end
662
- setting_class_including_instance = ClassIncluding.new
663
- setting_class_including_instance.respond_to?( :some_configuration ).should == false
664
- setting_class_including_instance.instance_variables.empty?.should == true
665
- # => instances of extending classes get nothing
666
- class ClassExtending
667
- extend CascadingConfiguration::Setting::ObjectConfigurationMockIncluded
668
- respond_to?( :some_configuration ).should == false
669
- instance_methods.include?( :some_configuration ).should == false
670
- instance_variables.empty?.should == true
671
- end
672
- setting_class_including_instance = ClassExtending.new
673
- setting_class_including_instance.respond_to?( :some_configuration ).should == false
674
- setting_class_including_instance.instance_variables.empty?.should == true
675
- end
676
-
677
- class CascadingConfiguration::Setting::ObjectConfigurationMockClass
678
- include CascadingConfiguration::Setting::ObjectConfigurationMockIncluded::SubmoduleIncluding
679
- respond_to?( :some_configuration ).should == false
680
- instance_variables.empty?.should == true
681
- end
682
- class CascadingConfiguration::Setting::ObjectConfigurationMockClassSub1 < CascadingConfiguration::Setting::ObjectConfigurationMockClass
683
- respond_to?( :some_configuration ).should == false
684
- instance_variables.empty?.should == true
685
- end
686
- class CascadingConfiguration::Setting::ObjectConfigurationMockClassSub2 < CascadingConfiguration::Setting::ObjectConfigurationMockClassSub1
687
- respond_to?( :some_configuration ).should == false
688
- instance_variables.empty?.should == true
689
- end
690
- end
691
-
692
- end