cascading-configuration-hash 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +29 -308
- data/README.rdoc +27 -1
- data/lib/cascading-configuration/CascadingConfiguration.rb +16 -0
- data/lib/cascading-configuration.rb +15 -0
- data/spec/CascadingConfiguration_spec.rb +224 -0
- metadata +5 -16
- data/lib/cascading-configuration-hash/CascadingConfiguration/CompositingHash/Instance.rb +0 -39
- data/lib/cascading-configuration-hash/CascadingConfiguration/CompositingHash.rb +0 -136
- data/lib/cascading-configuration-hash/CascadingConfiguration/Hash/Accessors.rb +0 -33
- data/lib/cascading-configuration-hash/CascadingConfiguration/Hash/ClassInstance.rb +0 -24
- data/lib/cascading-configuration-hash/CascadingConfiguration/Hash/ModuleInstance.rb +0 -36
- data/lib/cascading-configuration-hash/CascadingConfiguration/Hash.rb +0 -24
- data/lib/cascading-configuration-hash/CascadingConfiguration/LocalConfigurationHash.rb +0 -83
- data/lib/cascading-configuration-hash/CascadingConfiguration/_private_/CompositingHash.rb +0 -79
- data/lib/cascading-configuration-hash/CascadingConfiguration/_private_/LocalConfigurationHash.rb +0 -31
- data/lib/cascading-configuration-hash.rb +0 -35
- data/spec/CascadingConfiguration/CascadingCompositeHash_spec.rb +0 -402
- data/spec/CascadingConfiguration/ConfigurationHash_spec.rb +0 -95
- data/spec/CascadingConfiguration/Hash/Accessors_spec.rb +0 -28
- data/spec/CascadingConfiguration/Hash_spec.rb +0 -144
@@ -1,144 +0,0 @@
|
|
1
|
-
|
2
|
-
require_relative '../../lib/cascading-configuration-hash.rb'
|
3
|
-
|
4
|
-
describe CascadingConfiguration::Hash do
|
5
|
-
|
6
|
-
#############################
|
7
|
-
# attr_configuration_hash #
|
8
|
-
#############################
|
9
|
-
|
10
|
-
it 'can define a configuration hash, which is the primary interface' do
|
11
|
-
module CascadingConfiguration::Hash::MockModule
|
12
|
-
include CascadingConfiguration::Hash
|
13
|
-
attr_configuration_hash :configuration_setting
|
14
|
-
configuration_setting.should == {}
|
15
|
-
self.configuration_setting[ :a_configuration ] = :some_value
|
16
|
-
configuration_setting.should == { :a_configuration => :some_value }
|
17
|
-
end
|
18
|
-
|
19
|
-
module CascadingConfiguration::Hash::MockModule2
|
20
|
-
include CascadingConfiguration::Hash::MockModule
|
21
|
-
configuration_setting.should == { :a_configuration => :some_value }
|
22
|
-
configuration_setting[ :other_setting ] = :some_value
|
23
|
-
configuration_setting.should == { :a_configuration => :some_value,
|
24
|
-
:other_setting => :some_value }
|
25
|
-
configuration_setting.delete( :other_setting ).should == :some_value
|
26
|
-
configuration_setting.should == { :a_configuration => :some_value }
|
27
|
-
end
|
28
|
-
|
29
|
-
module CascadingConfiguration::Hash::MockModule3
|
30
|
-
include CascadingConfiguration::Hash::MockModule2
|
31
|
-
end
|
32
|
-
|
33
|
-
class CascadingConfiguration::Hash::MockClass
|
34
|
-
include CascadingConfiguration::Hash::MockModule3
|
35
|
-
configuration_setting.should == { :a_configuration => :some_value }
|
36
|
-
configuration_setting[ :other_setting ] = :some_value
|
37
|
-
configuration_setting.should == { :a_configuration => :some_value,
|
38
|
-
:other_setting => :some_value }
|
39
|
-
configuration_setting.delete( :other_setting ).should == :some_value
|
40
|
-
configuration_setting.should == { :a_configuration => :some_value }
|
41
|
-
end
|
42
|
-
|
43
|
-
object_instance_one = CascadingConfiguration::Hash::MockClass.new
|
44
|
-
object_instance_one.configuration_setting.should == { :a_configuration => :some_value }
|
45
|
-
object_instance_one.configuration_setting[ :some_other_configuration ] = :some_value
|
46
|
-
object_instance_one.configuration_setting.should == { :a_configuration => :some_value,
|
47
|
-
:some_other_configuration => :some_value }
|
48
|
-
|
49
|
-
class CascadingConfiguration::Hash::MockClassSub1 < CascadingConfiguration::Hash::MockClass
|
50
|
-
configuration_setting.should == { :a_configuration => :some_value }
|
51
|
-
self.configuration_setting[ :another_configuration ] = :some_value
|
52
|
-
configuration_setting.should == { :a_configuration => :some_value,
|
53
|
-
:another_configuration => :some_value }
|
54
|
-
end
|
55
|
-
|
56
|
-
CascadingConfiguration::Hash::MockClassSub1.new.configuration_setting.should == { :a_configuration => :some_value,
|
57
|
-
:another_configuration => :some_value }
|
58
|
-
|
59
|
-
object_instance_two = CascadingConfiguration::Hash::MockClassSub1.new
|
60
|
-
object_instance_two.configuration_setting.should == { :a_configuration => :some_value,
|
61
|
-
:another_configuration => :some_value }
|
62
|
-
object_instance_two.configuration_setting[ :some_other_configuration ] = :some_value
|
63
|
-
object_instance_two.configuration_setting.should == { :a_configuration => :some_value,
|
64
|
-
:another_configuration => :some_value,
|
65
|
-
:some_other_configuration => :some_value }
|
66
|
-
|
67
|
-
# change ancestor setting
|
68
|
-
CascadingConfiguration::Hash::MockClass.configuration_setting[ :a_yet_unused_configuration ] = :some_value
|
69
|
-
CascadingConfiguration::Hash::MockClass.configuration_setting.should == { :a_configuration => :some_value,
|
70
|
-
:a_yet_unused_configuration => :some_value }
|
71
|
-
object_instance_one.configuration_setting.should == { :a_configuration => :some_value,
|
72
|
-
:a_yet_unused_configuration => :some_value,
|
73
|
-
:some_other_configuration => :some_value }
|
74
|
-
CascadingConfiguration::Hash::MockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
|
75
|
-
:a_yet_unused_configuration => :some_value,
|
76
|
-
:another_configuration => :some_value }
|
77
|
-
object_instance_two.configuration_setting.should == { :a_configuration => :some_value,
|
78
|
-
:a_yet_unused_configuration => :some_value,
|
79
|
-
:another_configuration => :some_value,
|
80
|
-
:some_other_configuration => :some_value }
|
81
|
-
|
82
|
-
# freeze ancestor setting
|
83
|
-
object_instance_one.configuration_setting.freeze!
|
84
|
-
object_instance_one.configuration_setting.should == { :a_configuration => :some_value,
|
85
|
-
:a_yet_unused_configuration => :some_value,
|
86
|
-
:some_other_configuration => :some_value }
|
87
|
-
CascadingConfiguration::Hash::MockClassSub1.configuration_setting.freeze!
|
88
|
-
CascadingConfiguration::Hash::MockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
|
89
|
-
:a_yet_unused_configuration => :some_value,
|
90
|
-
:another_configuration => :some_value }
|
91
|
-
CascadingConfiguration::Hash::MockClass.configuration_setting[ :non_cascading_configuration ] = :some_value
|
92
|
-
CascadingConfiguration::Hash::MockClass.configuration_setting.should == { :a_configuration => :some_value,
|
93
|
-
:a_yet_unused_configuration => :some_value,
|
94
|
-
:non_cascading_configuration => :some_value }
|
95
|
-
object_instance_one.configuration_setting.should == { :a_configuration => :some_value,
|
96
|
-
:a_yet_unused_configuration => :some_value,
|
97
|
-
:some_other_configuration => :some_value }
|
98
|
-
CascadingConfiguration::Hash::MockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
|
99
|
-
:a_yet_unused_configuration => :some_value,
|
100
|
-
:another_configuration => :some_value }
|
101
|
-
object_instance_two.configuration_setting.should == { :a_configuration => :some_value,
|
102
|
-
:a_yet_unused_configuration => :some_value,
|
103
|
-
:another_configuration => :some_value,
|
104
|
-
:some_other_configuration => :some_value }
|
105
|
-
|
106
|
-
module CascadingConfiguration::Hash::MockModule
|
107
|
-
attr_configuration_hash :some_hash do |parent_hash, composite_hash|
|
108
|
-
parent_hash.each do |this_key, this_data|
|
109
|
-
if existing_value = composite_hash[ this_key ]
|
110
|
-
composite_hash[ this_key ] = this_data - existing_value
|
111
|
-
else
|
112
|
-
composite_hash[ this_key ] = this_data
|
113
|
-
end
|
114
|
-
end
|
115
|
-
composite_hash
|
116
|
-
end
|
117
|
-
self.some_hash = { :one => 1, :two => 2 }
|
118
|
-
self.some_hash.should == { :one => 1, :two => 2 }
|
119
|
-
end
|
120
|
-
|
121
|
-
module CascadingConfiguration::Hash::MockModule2
|
122
|
-
self.some_hash.should == { :one => 1, :two => 2 }
|
123
|
-
self.some_hash.replace( { :one => 1, :two => 2 } )
|
124
|
-
self.some_hash.should == { :one => 0, :two => 0 }
|
125
|
-
end
|
126
|
-
|
127
|
-
# test two
|
128
|
-
|
129
|
-
module CascadingConfiguration::Hash::MockModuleExtended
|
130
|
-
include CascadingConfiguration::Hash
|
131
|
-
attr_configuration_hash :configuration_setting
|
132
|
-
configuration_setting.should == {}
|
133
|
-
configuration_setting[ :a_configuration ] = :some_value
|
134
|
-
configuration_setting.should == { :a_configuration => :some_value }
|
135
|
-
end
|
136
|
-
|
137
|
-
class CascadingConfiguration::Hash::MockClassExtended
|
138
|
-
extend CascadingConfiguration::Hash::MockModuleExtended
|
139
|
-
configuration_setting.should == { :a_configuration => :some_value }
|
140
|
-
end
|
141
|
-
|
142
|
-
end
|
143
|
-
|
144
|
-
end
|