cascading-configuration-setting 2.0.0 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,20 +5,12 @@ else
5
5
  require 'cascading-configuration-variable'
6
6
  end
7
7
 
8
- module CascadingConfiguration
8
+ module ::CascadingConfiguration
9
9
  module Setting
10
- class CompositingHash < ::Hash
11
- class LocalConfigurationHash < ::Hash
12
- end
13
- end
14
10
  module Interface
15
- module GettersSetters
16
- end
17
11
  end
18
12
  end
19
13
  end
20
14
 
21
- require_relative 'cascading-configuration-setting/_private_/CascadingConfiguration/Setting/Interface/GettersSetters.rb'
22
-
23
15
  require_relative 'cascading-configuration-setting/CascadingConfiguration/Setting/Interface.rb'
24
16
  require_relative 'cascading-configuration-setting/CascadingConfiguration/Setting.rb'
@@ -1,5 +1,5 @@
1
1
 
2
- module CascadingConfiguration::Setting
2
+ module ::CascadingConfiguration::Setting
3
3
 
4
4
  # Configuration modules for storage of settings variables
5
5
  include ::CascadingConfiguration::Variable
@@ -1,9 +1,37 @@
1
1
 
2
- module CascadingConfiguration::Setting::Interface
2
+ module ::CascadingConfiguration::Setting::Interface
3
3
 
4
- # Support methods that define configuration setting methods
5
- include CascadingConfiguration::Setting::Interface::GettersSetters
4
+ ######################
5
+ # self.setter_proc #
6
+ ######################
6
7
 
8
+ def self.setter_proc( configuration_name )
9
+
10
+ return Proc.new do |value|
11
+
12
+ return ::CascadingConfiguration::Variable.set_configuration_variable( self,
13
+ configuration_name,
14
+ value )
15
+
16
+ end
17
+
18
+ end
19
+
20
+ ######################
21
+ # self.getter_proc #
22
+ ######################
23
+
24
+ def self.getter_proc( configuration_name )
25
+
26
+ return Proc.new do
27
+
28
+ return ::CascadingConfiguration::Variable.
29
+ get_configuration_searching_upward( self, configuration_name )
30
+
31
+ end
32
+
33
+ end
34
+
7
35
  ########################
8
36
  # attr_configuration #
9
37
  ########################
@@ -12,14 +40,10 @@ module CascadingConfiguration::Setting::Interface
12
40
  # configuration cascades downward to instance including all classes or modules in-between
13
41
  def attr_configuration( *configuration_names )
14
42
 
15
- configuration_names.each do |this_configuration_name|
16
- # define configuration setter
17
- define_cascading_setter( this_configuration_name )
18
- # define configuration getter
19
- define_cascading_getter( this_configuration_name )
20
- end
21
-
22
- return self
43
+ return ::CascadingConfiguration::Variable.
44
+ define_cascading_configuration( self,
45
+ ::CascadingConfiguration::Setting::Interface,
46
+ *configuration_names )
23
47
 
24
48
  end
25
49
 
@@ -31,14 +55,10 @@ module CascadingConfiguration::Setting::Interface
31
55
  # configuration cascades downward to last class or module
32
56
  def attr_module_configuration( *configuration_names )
33
57
 
34
- configuration_names.each do |this_configuration_name|
35
- # define configuration setter
36
- define_class_configuration_setter( this_configuration_name )
37
- # define configuration getter
38
- define_class_configuration_getter( this_configuration_name )
39
- end
40
-
41
- return self
58
+ return ::CascadingConfiguration::Variable.
59
+ define_module_configuration( self,
60
+ ::CascadingConfiguration::Setting::Interface,
61
+ *configuration_names )
42
62
 
43
63
  end
44
64
  alias_method :attr_class_configuration, :attr_module_configuration
@@ -53,16 +73,10 @@ module CascadingConfiguration::Setting::Interface
53
73
  # * first class to include module (inherited)
54
74
  def attr_local_configuration( *configuration_names )
55
75
 
56
- CascadingConfiguration::Variable.create_local_instance_configuration_support_module( self )
57
-
58
- configuration_names.each do |this_configuration_name|
59
- # define configuration setter
60
- define_local_configuration_setter( this_configuration_name )
61
- # define configuration getter
62
- define_local_configuration_getter( this_configuration_name )
63
- end
64
-
65
- return self
76
+ return ::CascadingConfiguration::Variable.
77
+ define_local_configuration( self,
78
+ ::CascadingConfiguration::Setting::Interface,
79
+ *configuration_names )
66
80
 
67
81
  end
68
82
 
@@ -74,16 +88,10 @@ module CascadingConfiguration::Setting::Interface
74
88
  # * only in the instance that declares it
75
89
  def attr_object_configuration( *configuration_names )
76
90
 
77
- CascadingConfiguration::Variable.create_local_instance_configuration_support_module( self )
78
-
79
- configuration_names.each do |this_configuration_name|
80
- # define configuration setter
81
- define_object_configuration_setter( this_configuration_name )
82
- # define configuration getter
83
- define_object_configuration_getter( this_configuration_name )
84
- end
85
-
86
- return self
91
+ return ::CascadingConfiguration::Variable.
92
+ define_object_configuration( self,
93
+ ::CascadingConfiguration::Setting::Interface,
94
+ *configuration_names )
87
95
 
88
96
  end
89
97
 
@@ -96,14 +104,10 @@ module CascadingConfiguration::Setting::Interface
96
104
  # * in instance if declared on non-class/non-module object instance
97
105
  def attr_instance_configuration( *configuration_names )
98
106
 
99
- configuration_names.each do |this_configuration_name|
100
- # define configuration setter
101
- define_instance_configuration_setter( this_configuration_name )
102
- # define configuration getter
103
- define_instance_configuration_getter( this_configuration_name )
104
- end
105
-
106
- return self
107
+ return ::CascadingConfiguration::Variable.
108
+ define_instance_configuration( self,
109
+ ::CascadingConfiguration::Setting::Interface,
110
+ *configuration_names )
107
111
 
108
112
  end
109
113
 
@@ -21,7 +21,7 @@ describe CascadingConfiguration::Setting do
21
21
 
22
22
  # possibilities:
23
23
  # * module extended with setting
24
- module CascadingConfiguration::Setting::ConfigurationMockExtended
24
+ module ::CascadingConfiguration::Setting::ConfigurationMockExtended
25
25
  extend CascadingConfiguration::Setting
26
26
  # => singleton gets attr_configuration and configurations
27
27
  respond_to?( :attr_configuration ).should == true
@@ -61,7 +61,7 @@ describe CascadingConfiguration::Setting do
61
61
  end
62
62
 
63
63
  # * module included with setting
64
- module CascadingConfiguration::Setting::ConfigurationMockIncluded
64
+ module ::CascadingConfiguration::Setting::ConfigurationMockIncluded
65
65
  include CascadingConfiguration::Setting
66
66
  # => singleton gets attr_configuration and configurations
67
67
  eigenclass = class << self ; self ; end
@@ -181,7 +181,7 @@ describe CascadingConfiguration::Setting do
181
181
 
182
182
  # possibilities:
183
183
  # * module extended with setting
184
- module CascadingConfiguration::Setting::ClassConfigurationMockExtended
184
+ module ::CascadingConfiguration::Setting::ClassConfigurationMockExtended
185
185
  extend CascadingConfiguration::Setting
186
186
  # => singleton gets attr_module_configuration and configurations
187
187
  respond_to?( :attr_module_configuration ).should == true
@@ -222,7 +222,7 @@ describe CascadingConfiguration::Setting do
222
222
  end
223
223
 
224
224
  # * module included with setting
225
- module CascadingConfiguration::Setting::ClassConfigurationMockIncluded
225
+ module ::CascadingConfiguration::Setting::ClassConfigurationMockIncluded
226
226
  include CascadingConfiguration::Setting
227
227
  # => singleton gets attr_module_configuration and configurations
228
228
  respond_to?( :attr_module_configuration ).should == true
@@ -320,7 +320,7 @@ describe CascadingConfiguration::Setting do
320
320
 
321
321
  # possibilities:
322
322
  # * module extended with setting
323
- module CascadingConfiguration::Setting::LocalConfigurationMockExtended
323
+ module ::CascadingConfiguration::Setting::LocalConfigurationMockExtended
324
324
  extend CascadingConfiguration::Setting
325
325
  # => singleton gets attr_configuration and configurations
326
326
  respond_to?( :attr_local_configuration ).should == true
@@ -360,7 +360,7 @@ describe CascadingConfiguration::Setting do
360
360
  end
361
361
 
362
362
  # * module included with setting
363
- module CascadingConfiguration::Setting::LocalConfigurationMockIncluded
363
+ module ::CascadingConfiguration::Setting::LocalConfigurationMockIncluded
364
364
  include CascadingConfiguration::Setting
365
365
  # => singleton gets attr_configuration and configurations
366
366
  respond_to?( :attr_local_configuration ).should == true
@@ -475,7 +475,7 @@ describe CascadingConfiguration::Setting do
475
475
 
476
476
  # possibilities:
477
477
  # * module extended with setting
478
- module CascadingConfiguration::Setting::InstanceConfigurationMockExtended
478
+ module ::CascadingConfiguration::Setting::InstanceConfigurationMockExtended
479
479
  extend CascadingConfiguration::Setting
480
480
  # => singleton gets attr_configuration and configurations
481
481
  respond_to?( :attr_instance_configuration ).should == true
@@ -511,10 +511,11 @@ describe CascadingConfiguration::Setting do
511
511
  end
512
512
 
513
513
  # * module included with setting
514
- module CascadingConfiguration::Setting::InstanceConfigurationMockIncluded
514
+ module ::CascadingConfiguration::Setting::InstanceConfigurationMockIncluded
515
515
  include CascadingConfiguration::Setting
516
516
  # => singleton gets attr_configuration and configurations
517
517
  respond_to?( :attr_instance_configuration ).should == true
518
+ respond_to?( :some_configuration ).should == false
518
519
  attr_instance_configuration :some_configuration
519
520
  respond_to?( :some_configuration ).should == false
520
521
  instance_methods.include?( :some_configuration ).should == true
@@ -584,7 +585,7 @@ describe CascadingConfiguration::Setting do
584
585
 
585
586
  # possibilities:
586
587
  # * module extended with setting
587
- module CascadingConfiguration::Setting::ObjectConfigurationMockExtended
588
+ module ::CascadingConfiguration::Setting::ObjectConfigurationMockExtended
588
589
  extend CascadingConfiguration::Setting
589
590
  # => singleton gets attr_configuration and configurations
590
591
  respond_to?( :attr_object_configuration ).should == true
@@ -624,7 +625,7 @@ describe CascadingConfiguration::Setting do
624
625
  end
625
626
 
626
627
  # * module included with setting
627
- module CascadingConfiguration::Setting::ObjectConfigurationMockIncluded
628
+ module ::CascadingConfiguration::Setting::ObjectConfigurationMockIncluded
628
629
  include CascadingConfiguration::Setting
629
630
  # => singleton gets attr_configuration and configurations
630
631
  respond_to?( :attr_object_configuration ).should == true
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.0.0
4
+ version: 2.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-29 00:00:00.000000000 Z
12
+ date: 2012-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: module-cluster
16
- requirement: &70340659285960 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: *70340659285960
25
14
  - !ruby/object:Gem::Dependency
26
15
  name: cascading-configuration-variable
27
- requirement: &70340659285020 !ruby/object:Gem::Requirement
16
+ requirement: &70097372985640 !ruby/object:Gem::Requirement
28
17
  none: false
29
18
  requirements:
30
19
  - - ! '>='
@@ -32,14 +21,13 @@ dependencies:
32
21
  version: '0'
33
22
  type: :runtime
34
23
  prerelease: false
35
- version_requirements: *70340659285020
24
+ version_requirements: *70097372985640
36
25
  description: Provides :attr_configuration.
37
26
  email: asher@ridiculouspower.com
38
27
  executables: []
39
28
  extensions: []
40
29
  extra_rdoc_files: []
41
30
  files:
42
- - lib/cascading-configuration-setting/_private_/CascadingConfiguration/Setting/Interface/GettersSetters.rb
43
31
  - lib/cascading-configuration-setting/CascadingConfiguration/Setting/Interface.rb
44
32
  - lib/cascading-configuration-setting/CascadingConfiguration/Setting.rb
45
33
  - lib/cascading-configuration-setting.rb
@@ -1,193 +0,0 @@
1
-
2
- module CascadingConfiguration::Setting::Interface::GettersSetters
3
-
4
- #############################
5
- # define_cascading_setter #
6
- #############################
7
-
8
- def define_cascading_setter( configuration_name )
9
-
10
- configuration_setter_name = ( configuration_name.to_s + '=' ).to_s
11
-
12
- setter_proc = Proc.new do |value|
13
- ::CascadingConfiguration::Variable.set_configuration_variable( self, configuration_name, value )
14
- end
15
-
16
- ::CascadingConfiguration::Variable.define_module_method( self, configuration_setter_name, & setter_proc )
17
- ::CascadingConfiguration::Variable.define_instance_method_if_support_exists( self, configuration_setter_name, & setter_proc )
18
-
19
- end
20
-
21
- #############################
22
- # define_cascading_getter #
23
- #############################
24
-
25
- def define_cascading_getter( configuration_name )
26
-
27
- configuration_getter_name = configuration_name
28
-
29
- getter_proc = Proc.new do
30
- return ::CascadingConfiguration::Variable.get_configuration_searching_upward( self, configuration_name )
31
- end
32
-
33
- ::CascadingConfiguration::Variable.define_module_method( self, configuration_getter_name, & getter_proc )
34
- ::CascadingConfiguration::Variable.define_instance_method_if_support_exists( self, configuration_getter_name, & getter_proc )
35
-
36
- end
37
-
38
- #######################################
39
- # define_class_configuration_setter #
40
- #######################################
41
-
42
- def define_class_configuration_setter( configuration_name )
43
-
44
- configuration_setter_name = ( configuration_name.to_s + '=' ).to_s
45
-
46
- ::CascadingConfiguration::Variable.define_module_method( self, configuration_setter_name ) do |value|
47
-
48
- # configuration setter returns setting variable (variable from self), which is now the ID of value
49
- return ::CascadingConfiguration::Variable.set_configuration_variable( self,
50
- configuration_name,
51
- value )
52
-
53
- end
54
-
55
- end
56
-
57
- #######################################
58
- # define_class_configuration_getter #
59
- #######################################
60
-
61
- def define_class_configuration_getter( configuration_name )
62
-
63
- configuration_getter_name = configuration_name
64
-
65
- configuration_support_module = ::CascadingConfiguration::Variable.configuration_support_module( self )
66
-
67
- ::CascadingConfiguration::Variable.define_module_method( self, configuration_getter_name ) do
68
-
69
- # configuration getter returns current setting value (taken from first superclass with setting)
70
- # that means first variable that has been set
71
- return ::CascadingConfiguration::Variable.get_configuration_searching_upward( self,
72
- configuration_name )
73
-
74
- end
75
-
76
- end
77
-
78
- #######################################
79
- # define_local_configuration_setter #
80
- #######################################
81
-
82
- def define_local_configuration_setter( configuration_name )
83
-
84
- configuration_setter_name = ( configuration_name.to_s + '=' ).to_s
85
-
86
- local_setter_proc = Proc.new do |value|
87
-
88
- # configuration setter returns setting variable (variable from self), which is now the ID of value
89
- return ::CascadingConfiguration::Variable.set_configuration_variable( self, configuration_name, value )
90
-
91
- end
92
-
93
- ::CascadingConfiguration::Variable.define_local_instance_method( self, configuration_setter_name, & local_setter_proc )
94
- ::CascadingConfiguration::Variable.define_instance_method_if_support_exists( self, configuration_setter_name, & local_setter_proc )
95
-
96
- end
97
-
98
- #######################################
99
- # define_local_configuration_getter #
100
- #######################################
101
-
102
- def define_local_configuration_getter( configuration_name )
103
-
104
- configuration_getter_name = configuration_name
105
-
106
- local_getter_proc = Proc.new do
107
-
108
- # configuration getter returns current setting value (taken from first superclass with setting)
109
- # that means first variable that has been set
110
- return ::CascadingConfiguration::Variable.get_configuration_variable( self, configuration_name )
111
-
112
- end
113
-
114
- ::CascadingConfiguration::Variable.define_local_instance_method( self, configuration_getter_name, & local_getter_proc )
115
- ::CascadingConfiguration::Variable.define_instance_method_if_support_exists( self, configuration_getter_name, & local_getter_proc )
116
-
117
- end
118
-
119
- ##########################################
120
- # define_instance_configuration_setter #
121
- ##########################################
122
-
123
- def define_instance_configuration_setter( configuration_name )
124
-
125
- configuration_setter_name = ( configuration_name.to_s + '=' ).to_s
126
-
127
- ::CascadingConfiguration::Variable.define_instance_method( self, configuration_setter_name ) do |value|
128
-
129
- # configuration setter returns setting variable (variable from self), which is now the ID of value
130
- return ::CascadingConfiguration::Variable.set_configuration_variable( self, configuration_name, value )
131
-
132
- end
133
-
134
- end
135
-
136
- ##########################################
137
- # define_instance_configuration_getter #
138
- ##########################################
139
-
140
- def define_instance_configuration_getter( configuration_name )
141
-
142
- configuration_getter_name = configuration_name
143
-
144
- ::CascadingConfiguration::Variable.define_instance_method( self, configuration_getter_name ) do
145
-
146
- # configuration getter returns current setting value (taken from first superclass with setting)
147
- # that means first variable that has been set
148
- return ::CascadingConfiguration::Variable.get_configuration_variable( self, configuration_name )
149
-
150
- end
151
-
152
- end
153
-
154
- ########################################
155
- # define_object_configuration_setter #
156
- ########################################
157
-
158
- def define_object_configuration_setter( configuration_name )
159
-
160
- configuration_setter_name = ( configuration_name.to_s + '=' ).to_s
161
-
162
- local_instance_configuration_support_module = ::CascadingConfiguration::Variable.local_instance_configuration_support_module( self )
163
-
164
- ::CascadingConfiguration::Variable.define_local_instance_method( self, configuration_setter_name ) do |value|
165
-
166
- # configuration setter returns setting variable (variable from self), which is now the ID of value
167
- return ::CascadingConfiguration::Variable.set_configuration_variable( self, configuration_name, value )
168
-
169
- end
170
-
171
- end
172
-
173
- ########################################
174
- # define_object_configuration_getter #
175
- ########################################
176
-
177
- def define_object_configuration_getter( configuration_name )
178
-
179
- configuration_getter_name = configuration_name
180
-
181
- local_instance_configuration_support_module = ::CascadingConfiguration::Variable.local_instance_configuration_support_module( self )
182
-
183
- ::CascadingConfiguration::Variable.define_local_instance_method( self, configuration_getter_name ) do
184
-
185
- # configuration getter returns current setting value (taken from first superclass with setting)
186
- # that means first variable that has been set
187
- return ::CascadingConfiguration::Variable.get_configuration_variable( self, configuration_name )
188
-
189
- end
190
-
191
- end
192
-
193
- end