cascading-configuration-hash 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (20) hide show
  1. data/README.md +365 -0
  2. data/README.rdoc +14 -100
  3. data/lib/cascading-configuration-hash.rb +18 -15
  4. data/lib/cascading-configuration-hash/CascadingConfiguration/{CascadingCompositeHash.rb → CompositingHash.rb} +3 -3
  5. data/lib/cascading-configuration-hash/CascadingConfiguration/{CascadingCompositeHash → CompositingHash}/Instance.rb +4 -2
  6. data/lib/cascading-configuration-hash/CascadingConfiguration/{CascadingCompositeHash → CompositingHash}/_private_/Instance.rb +1 -1
  7. data/lib/cascading-configuration-hash/CascadingConfiguration/Hash.rb +33 -0
  8. data/lib/cascading-configuration-hash/CascadingConfiguration/Hash/Accessors.rb +49 -0
  9. data/lib/cascading-configuration-hash/CascadingConfiguration/{ConfigurationSettingsHash → Hash}/ClassInstance.rb +3 -1
  10. data/lib/cascading-configuration-hash/CascadingConfiguration/{ConfigurationSettingsHash → Hash}/ModuleInstance.rb +7 -4
  11. data/lib/cascading-configuration-hash/CascadingConfiguration/{ConfigurationHash.rb → LocalConfigurationHash.rb} +2 -2
  12. data/lib/cascading-configuration-hash/CascadingConfiguration/_private_/{CascadingCompositeHash.rb → CompositingHash.rb} +1 -1
  13. data/lib/cascading-configuration-hash/CascadingConfiguration/_private_/{ConfigurationHash.rb → LocalConfigurationHash.rb} +3 -3
  14. data/spec/CascadingConfiguration/CascadingCompositeHash_spec.rb +57 -57
  15. data/spec/CascadingConfiguration/ConfigurationHash_spec.rb +8 -8
  16. data/spec/CascadingConfiguration/ConfigurationSettingsHash/Accessors_spec.rb +12 -12
  17. data/spec/CascadingConfiguration/ConfigurationSettingsHash_spec.rb +21 -21
  18. metadata +14 -13
  19. data/lib/cascading-configuration-hash/CascadingConfiguration/ConfigurationSettingsHash.rb +0 -21
  20. data/lib/cascading-configuration-hash/CascadingConfiguration/ConfigurationSettingsHash/Accessors.rb +0 -35
@@ -1,14 +1,14 @@
1
1
 
2
2
  require_relative '../../lib/cascading-configuration-hash.rb'
3
3
 
4
- describe CascadingConfiguration::ConfigurationHash do
4
+ describe CascadingConfiguration::LocalConfigurationHash do
5
5
 
6
6
  #########
7
7
  # []= #
8
8
  #########
9
9
 
10
10
  it 'can add elements' do
11
- hash_instance = ::CascadingConfiguration::ConfigurationHash.new
11
+ hash_instance = ::CascadingConfiguration::LocalConfigurationHash.new
12
12
  hash_instance[ :some_setting ] = :some_value
13
13
  hash_instance.should == { :some_setting => :some_value }
14
14
  hash_instance.exclude_array.include?( :some_setting ).should == false
@@ -23,7 +23,7 @@ describe CascadingConfiguration::ConfigurationHash do
23
23
  ###########
24
24
 
25
25
  it 'can add elements' do
26
- hash_instance = ::CascadingConfiguration::ConfigurationHash.new
26
+ hash_instance = ::CascadingConfiguration::LocalConfigurationHash.new
27
27
  hash_instance.store( :some_setting, :some_value )
28
28
  hash_instance.should == { :some_setting => :some_value }
29
29
  hash_instance.exclude_array.include?( :some_setting ).should == false
@@ -38,7 +38,7 @@ describe CascadingConfiguration::ConfigurationHash do
38
38
  ############
39
39
 
40
40
  it 'can exclude elements' do
41
- hash_instance = ::CascadingConfiguration::ConfigurationHash.new
41
+ hash_instance = ::CascadingConfiguration::LocalConfigurationHash.new
42
42
  hash_instance[ :some_setting ] = :some_value
43
43
  hash_instance.delete( :some_setting ).should == :some_value
44
44
  hash_instance.should == {}
@@ -50,7 +50,7 @@ describe CascadingConfiguration::ConfigurationHash do
50
50
  ############
51
51
 
52
52
  it 'can merge from another hash' do
53
- hash_instance = ::CascadingConfiguration::ConfigurationHash.new
53
+ hash_instance = ::CascadingConfiguration::LocalConfigurationHash.new
54
54
  hash_instance.merge!( { :some_setting => :some_value } )
55
55
  hash_instance.should == { :some_setting => :some_value }
56
56
  end
@@ -60,7 +60,7 @@ describe CascadingConfiguration::ConfigurationHash do
60
60
  #############
61
61
 
62
62
  it 'can replace existing elements with others' do
63
- hash_instance = ::CascadingConfiguration::ConfigurationHash.new
63
+ hash_instance = ::CascadingConfiguration::LocalConfigurationHash.new
64
64
  hash_instance.merge!( { :some_setting => :some_value } )
65
65
  hash_instance.should == { :some_setting => :some_value }
66
66
  hash_instance.replace( { :other_setting => :some_value } )
@@ -74,7 +74,7 @@ describe CascadingConfiguration::ConfigurationHash do
74
74
  ###########
75
75
 
76
76
  it 'can shift the first element' do
77
- hash_instance = ::CascadingConfiguration::ConfigurationHash.new
77
+ hash_instance = ::CascadingConfiguration::LocalConfigurationHash.new
78
78
  hash_instance.merge!( { :some_setting => :some_value } )
79
79
  hash_instance.shift.should == [ :some_setting, :some_value ]
80
80
  hash_instance.should == {}
@@ -85,7 +85,7 @@ describe CascadingConfiguration::ConfigurationHash do
85
85
  ###########
86
86
 
87
87
  it 'can clear, causing present elements to be excluded' do
88
- hash_instance = ::CascadingConfiguration::ConfigurationHash.new
88
+ hash_instance = ::CascadingConfiguration::LocalConfigurationHash.new
89
89
  hash_instance.merge!( { :some_setting => :some_value } )
90
90
  hash_instance.clear
91
91
  hash_instance.should == {}
@@ -1,7 +1,7 @@
1
1
 
2
2
  require_relative '../../../lib/cascading-configuration-hash.rb'
3
3
 
4
- describe CascadingConfiguration::ConfigurationSettingsHash::Accessors do
4
+ describe CascadingConfiguration::Hash::Accessors do
5
5
 
6
6
  ######################################
7
7
  # define_configuration_hash_setter #
@@ -9,20 +9,20 @@ describe CascadingConfiguration::ConfigurationSettingsHash::Accessors do
9
9
  ######################################
10
10
 
11
11
  it 'can define a method to get and modify the configuration hash' do
12
- class CascadingConfiguration::ConfigurationSettingsHash::Mock
13
- include CascadingConfiguration::ConfigurationVariable
14
- extend CascadingConfiguration::ConfigurationSettingsHash::Accessors
15
- include CascadingConfiguration::ConfigurationSettingsHash::ObjectInstance
16
- extend CascadingConfiguration::ConfigurationSettingsHash::ClassInstance
12
+ class CascadingConfiguration::Hash::Mock
13
+ include CascadingConfiguration::Variable
14
+ extend CascadingConfiguration::Hash::Accessors
15
+ include CascadingConfiguration::Hash::ObjectInstance
16
+ extend CascadingConfiguration::Hash::ClassInstance
17
17
  end
18
18
  # setter
19
- CascadingConfiguration::ConfigurationSettingsHash::Mock.define_configuration_hash_setter( :some_configuration )
20
- CascadingConfiguration::ConfigurationSettingsHash::Mock.methods.include?( :some_configuration= ).should == true
21
- CascadingConfiguration::ConfigurationSettingsHash::Mock.instance_methods.include?( :some_configuration= ).should == true
19
+ CascadingConfiguration::Hash::Mock.define_configuration_hash_setter( :some_configuration )
20
+ CascadingConfiguration::Hash::Mock.methods.include?( :some_configuration= ).should == true
21
+ CascadingConfiguration::Hash::Mock.instance_methods.include?( :some_configuration= ).should == true
22
22
  # getter
23
- CascadingConfiguration::ConfigurationSettingsHash::Mock.define_configuration_hash_getter( :some_configuration )
24
- CascadingConfiguration::ConfigurationSettingsHash::Mock.methods.include?( :some_configuration ).should == true
25
- CascadingConfiguration::ConfigurationSettingsHash::Mock.instance_methods.include?( :some_configuration ).should == true
23
+ CascadingConfiguration::Hash::Mock.define_configuration_hash_getter( :some_configuration )
24
+ CascadingConfiguration::Hash::Mock.methods.include?( :some_configuration ).should == true
25
+ CascadingConfiguration::Hash::Mock.instance_methods.include?( :some_configuration ).should == true
26
26
  end
27
27
 
28
28
  end
@@ -1,7 +1,7 @@
1
1
 
2
2
  require_relative '../../lib/cascading-configuration-hash.rb'
3
3
 
4
- describe CascadingConfiguration::ConfigurationSettingsHash do
4
+ describe CascadingConfiguration::Hash do
5
5
 
6
6
  #############################
7
7
  # attr_configuration_hash #
@@ -9,16 +9,16 @@ describe CascadingConfiguration::ConfigurationSettingsHash do
9
9
 
10
10
  it 'can define a configuration hash, which is the primary interface' do
11
11
 
12
- module CascadingConfiguration::ConfigurationSettingsHash::MockModule
13
- include CascadingConfiguration::ConfigurationSettingsHash
12
+ module CascadingConfiguration::Hash::MockModule
13
+ include CascadingConfiguration::Hash
14
14
  attr_configuration_hash :configuration_setting
15
15
  configuration_setting.should == {}
16
16
  self.configuration_setting[ :a_configuration ] = :some_value
17
17
  configuration_setting.should == { :a_configuration => :some_value }
18
18
  end
19
19
 
20
- module CascadingConfiguration::ConfigurationSettingsHash::MockModule2
21
- include CascadingConfiguration::ConfigurationSettingsHash::MockModule
20
+ module CascadingConfiguration::Hash::MockModule2
21
+ include CascadingConfiguration::Hash::MockModule
22
22
  configuration_setting.should == { :a_configuration => :some_value }
23
23
  configuration_setting[ :other_setting ] = :some_value
24
24
  configuration_setting.should == { :a_configuration => :some_value,
@@ -27,12 +27,12 @@ describe CascadingConfiguration::ConfigurationSettingsHash do
27
27
  configuration_setting.should == { :a_configuration => :some_value }
28
28
  end
29
29
 
30
- module CascadingConfiguration::ConfigurationSettingsHash::MockModule3
31
- include CascadingConfiguration::ConfigurationSettingsHash::MockModule2
30
+ module CascadingConfiguration::Hash::MockModule3
31
+ include CascadingConfiguration::Hash::MockModule2
32
32
  end
33
33
 
34
- class CascadingConfiguration::ConfigurationSettingsHash::MockClass
35
- include CascadingConfiguration::ConfigurationSettingsHash::MockModule3
34
+ class CascadingConfiguration::Hash::MockClass
35
+ include CascadingConfiguration::Hash::MockModule3
36
36
  configuration_setting.should == { :a_configuration => :some_value }
37
37
  configuration_setting[ :other_setting ] = :some_value
38
38
  configuration_setting.should == { :a_configuration => :some_value,
@@ -41,23 +41,23 @@ describe CascadingConfiguration::ConfigurationSettingsHash do
41
41
  configuration_setting.should == { :a_configuration => :some_value }
42
42
  end
43
43
 
44
- object_instance_one = CascadingConfiguration::ConfigurationSettingsHash::MockClass.new
44
+ object_instance_one = CascadingConfiguration::Hash::MockClass.new
45
45
  object_instance_one.configuration_setting.should == { :a_configuration => :some_value }
46
46
  object_instance_one.configuration_setting[ :some_other_configuration ] = :some_value
47
47
  object_instance_one.configuration_setting.should == { :a_configuration => :some_value,
48
48
  :some_other_configuration => :some_value }
49
49
 
50
- class CascadingConfiguration::ConfigurationSettingsHash::MockClassSub1 < CascadingConfiguration::ConfigurationSettingsHash::MockClass
50
+ class CascadingConfiguration::Hash::MockClassSub1 < CascadingConfiguration::Hash::MockClass
51
51
  configuration_setting.should == { :a_configuration => :some_value }
52
52
  self.configuration_setting[ :another_configuration ] = :some_value
53
53
  configuration_setting.should == { :a_configuration => :some_value,
54
54
  :another_configuration => :some_value }
55
55
  end
56
56
 
57
- CascadingConfiguration::ConfigurationSettingsHash::MockClassSub1.new.configuration_setting.should == { :a_configuration => :some_value,
57
+ CascadingConfiguration::Hash::MockClassSub1.new.configuration_setting.should == { :a_configuration => :some_value,
58
58
  :another_configuration => :some_value }
59
59
 
60
- object_instance_two = CascadingConfiguration::ConfigurationSettingsHash::MockClassSub1.new
60
+ object_instance_two = CascadingConfiguration::Hash::MockClassSub1.new
61
61
  object_instance_two.configuration_setting.should == { :a_configuration => :some_value,
62
62
  :another_configuration => :some_value }
63
63
  object_instance_two.configuration_setting[ :some_other_configuration ] = :some_value
@@ -66,13 +66,13 @@ describe CascadingConfiguration::ConfigurationSettingsHash do
66
66
  :some_other_configuration => :some_value }
67
67
 
68
68
  # change ancestor setting
69
- CascadingConfiguration::ConfigurationSettingsHash::MockClass.configuration_setting[ :a_yet_unused_configuration ] = :some_value
70
- CascadingConfiguration::ConfigurationSettingsHash::MockClass.configuration_setting.should == { :a_configuration => :some_value,
69
+ CascadingConfiguration::Hash::MockClass.configuration_setting[ :a_yet_unused_configuration ] = :some_value
70
+ CascadingConfiguration::Hash::MockClass.configuration_setting.should == { :a_configuration => :some_value,
71
71
  :a_yet_unused_configuration => :some_value }
72
72
  object_instance_one.configuration_setting.should == { :a_configuration => :some_value,
73
73
  :a_yet_unused_configuration => :some_value,
74
74
  :some_other_configuration => :some_value }
75
- CascadingConfiguration::ConfigurationSettingsHash::MockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
75
+ CascadingConfiguration::Hash::MockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
76
76
  :a_yet_unused_configuration => :some_value,
77
77
  :another_configuration => :some_value }
78
78
  object_instance_two.configuration_setting.should == { :a_configuration => :some_value,
@@ -85,18 +85,18 @@ describe CascadingConfiguration::ConfigurationSettingsHash do
85
85
  object_instance_one.configuration_setting.should == { :a_configuration => :some_value,
86
86
  :a_yet_unused_configuration => :some_value,
87
87
  :some_other_configuration => :some_value }
88
- CascadingConfiguration::ConfigurationSettingsHash::MockClassSub1.configuration_setting.freeze!
89
- CascadingConfiguration::ConfigurationSettingsHash::MockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
88
+ CascadingConfiguration::Hash::MockClassSub1.configuration_setting.freeze!
89
+ CascadingConfiguration::Hash::MockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
90
90
  :a_yet_unused_configuration => :some_value,
91
91
  :another_configuration => :some_value }
92
- CascadingConfiguration::ConfigurationSettingsHash::MockClass.configuration_setting[ :non_cascading_configuration ] = :some_value
93
- CascadingConfiguration::ConfigurationSettingsHash::MockClass.configuration_setting.should == { :a_configuration => :some_value,
92
+ CascadingConfiguration::Hash::MockClass.configuration_setting[ :non_cascading_configuration ] = :some_value
93
+ CascadingConfiguration::Hash::MockClass.configuration_setting.should == { :a_configuration => :some_value,
94
94
  :a_yet_unused_configuration => :some_value,
95
95
  :non_cascading_configuration => :some_value }
96
96
  object_instance_one.configuration_setting.should == { :a_configuration => :some_value,
97
97
  :a_yet_unused_configuration => :some_value,
98
98
  :some_other_configuration => :some_value }
99
- CascadingConfiguration::ConfigurationSettingsHash::MockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
99
+ CascadingConfiguration::Hash::MockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
100
100
  :a_yet_unused_configuration => :some_value,
101
101
  :another_configuration => :some_value }
102
102
  object_instance_two.configuration_setting.should == { :a_configuration => :some_value,
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
+ - 1
7
8
  - 0
8
- - 0
9
- version: 1.0.0
9
+ version: 1.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Asher
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-07-13 00:00:00 -04:00
17
+ date: 2011-07-14 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -39,21 +39,22 @@ extensions: []
39
39
  extra_rdoc_files: []
40
40
 
41
41
  files:
42
- - lib/cascading-configuration-hash/CascadingConfiguration/_private_/CascadingCompositeHash.rb
43
- - lib/cascading-configuration-hash/CascadingConfiguration/_private_/ConfigurationHash.rb
44
- - lib/cascading-configuration-hash/CascadingConfiguration/CascadingCompositeHash/_private_/Instance.rb
45
- - lib/cascading-configuration-hash/CascadingConfiguration/CascadingCompositeHash/Instance.rb
46
- - lib/cascading-configuration-hash/CascadingConfiguration/CascadingCompositeHash.rb
47
- - lib/cascading-configuration-hash/CascadingConfiguration/ConfigurationHash.rb
48
- - lib/cascading-configuration-hash/CascadingConfiguration/ConfigurationSettingsHash/Accessors.rb
49
- - lib/cascading-configuration-hash/CascadingConfiguration/ConfigurationSettingsHash/ClassInstance.rb
50
- - lib/cascading-configuration-hash/CascadingConfiguration/ConfigurationSettingsHash/ModuleInstance.rb
51
- - lib/cascading-configuration-hash/CascadingConfiguration/ConfigurationSettingsHash.rb
42
+ - lib/cascading-configuration-hash/CascadingConfiguration/_private_/CompositingHash.rb
43
+ - lib/cascading-configuration-hash/CascadingConfiguration/_private_/LocalConfigurationHash.rb
44
+ - lib/cascading-configuration-hash/CascadingConfiguration/CompositingHash/_private_/Instance.rb
45
+ - lib/cascading-configuration-hash/CascadingConfiguration/CompositingHash/Instance.rb
46
+ - lib/cascading-configuration-hash/CascadingConfiguration/CompositingHash.rb
47
+ - lib/cascading-configuration-hash/CascadingConfiguration/Hash/Accessors.rb
48
+ - lib/cascading-configuration-hash/CascadingConfiguration/Hash/ClassInstance.rb
49
+ - lib/cascading-configuration-hash/CascadingConfiguration/Hash/ModuleInstance.rb
50
+ - lib/cascading-configuration-hash/CascadingConfiguration/Hash.rb
51
+ - lib/cascading-configuration-hash/CascadingConfiguration/LocalConfigurationHash.rb
52
52
  - lib/cascading-configuration-hash.rb
53
53
  - spec/CascadingConfiguration/CascadingCompositeHash_spec.rb
54
54
  - spec/CascadingConfiguration/ConfigurationHash_spec.rb
55
55
  - spec/CascadingConfiguration/ConfigurationSettingsHash/Accessors_spec.rb
56
56
  - spec/CascadingConfiguration/ConfigurationSettingsHash_spec.rb
57
+ - README.md
57
58
  - README.rdoc
58
59
  has_rdoc: true
59
60
  homepage: http://rubygems.org/gems/cascading-configuration-hash
@@ -1,21 +0,0 @@
1
-
2
- module CascadingConfiguration::ConfigurationSettingsHash
3
-
4
- ###################
5
- # self.included #
6
- ###################
7
-
8
- def self.included( class_or_module )
9
- class_or_module.instance_eval do
10
- include CascadingConfiguration::ConfigurationVariable
11
- extend CascadingConfiguration::ConfigurationSettingsHash
12
- extend CascadingConfiguration::ConfigurationSettingsHash::Accessors
13
- extend CascadingConfiguration::ConfigurationSettingsHash::ClassInstance
14
- include CascadingConfiguration::CascadingCompositeHash::Instance
15
- unless class_or_module.is_a?( Class )
16
- extend CascadingConfiguration::ConfigurationSettingsHash::ModuleInstance
17
- end
18
- end
19
- end
20
-
21
- end
@@ -1,35 +0,0 @@
1
-
2
- module CascadingConfiguration::ConfigurationSettingsHash::Accessors
3
-
4
- ######################################
5
- # define_configuration_hash_setter #
6
- ######################################
7
-
8
- def define_configuration_hash_setter( configuration_name )
9
- [ self, eigenclass ].each do |klass_or_eigenclass|
10
- klass_or_eigenclass.class_eval do
11
- configuration_setter_name = ( configuration_name.to_s + '=' ).to_sym
12
- define_method( configuration_setter_name ) do |hash|
13
- # we want the hash to supplant existing config
14
- return composite_hash_for_cascading_configuration( configuration_name ).replace( hash )
15
- end
16
- end
17
- end
18
- end
19
-
20
- ######################################
21
- # define_configuration_hash_getter #
22
- ######################################
23
-
24
- def define_configuration_hash_getter( configuration_name )
25
- configuration_getter_name = configuration_name
26
- [ self, eigenclass ].each do |klass_or_eigenclass|
27
- klass_or_eigenclass.class_eval do
28
- define_method( configuration_getter_name ) do
29
- return composite_hash_for_cascading_configuration( configuration_name )
30
- end
31
- end
32
- end
33
- end
34
-
35
- end