super_stack 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -3
- data/lib/super_stack/layer_wrapper.rb +1 -1
- data/lib/super_stack/manager.rb +4 -2
- data/lib/super_stack/version.rb +1 -1
- data/spec/manager_spec.rb +13 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 252c5d3c0c7502cd8d199660fd2366328c1a0b62
|
4
|
+
data.tar.gz: e8f0846916ab97dce8071ceffe9b6bf692ae7c3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66082adea0c2facc15445c0bbef7e04bd42c66a80465e775456fb127b8f8a7c96c7f3c6bd31558e8966a177fb0883dd30dfe8401b07f3450cd351b1f41132955
|
7
|
+
data.tar.gz: 2f735111b2053ad0363fc775affc39f7ff3a267fdf207cffc463db46b199560e16f75d7df55b860a068d6fed80eb515e486056187a3e58219dbb7ad534b2a275
|
data/README.md
CHANGED
@@ -39,10 +39,20 @@ the result of the merge of all layers as a hash. It will be done according to th
|
|
39
39
|
policy chosen.
|
40
40
|
|
41
41
|
You can directly access to a particular key of the resulting merging by simply doing `manager[:your_key]` like you would
|
42
|
-
do with a
|
42
|
+
do with a regular `Hash`.
|
43
43
|
|
44
|
-
|
44
|
+
`SuperStack::Manager` itself has no `Hash` in its ancestors, whereas `SuperStack::Manager#[]` that you can access
|
45
|
+
through `manager[]` *is* actually the `Hash` resulting of the merge of the layers).
|
45
46
|
|
47
|
+
**None of the layers is modified by the manager**, although you can nevertheless access them with the
|
48
|
+
`SuperStack::Manager#layers` method.
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
manager = SuperStack::Manager.new
|
52
|
+
puts manager.class # => SuperStack::Manager
|
53
|
+
puts manager[].class # => Hash
|
54
|
+
puts manager.layers.class # => Hash
|
55
|
+
```
|
46
56
|
|
47
57
|
### Layers
|
48
58
|
|
@@ -90,7 +100,7 @@ manager.reload_layers
|
|
90
100
|
```
|
91
101
|
|
92
102
|
Layers can of course be:
|
93
|
-
*
|
103
|
+
* Removed (using the manager's `remove_layer(layer_or_layer_name)` method).
|
94
104
|
* Enabled or disabled (using the manager's `disable_layer(layer_or_layer_name)` and `enable_layer(layer_or_layer_name)`
|
95
105
|
methods).
|
96
106
|
|
@@ -61,7 +61,7 @@ module SuperStack
|
|
61
61
|
|
62
62
|
def load_from_yaml(file_name)
|
63
63
|
begin
|
64
|
-
self.replace Hash[YAML::load(File.open(file_name)).map { |k, v| [k.
|
64
|
+
self.replace Hash[YAML::load(File.open(file_name)).map { |k, v| [k.to_s, v] }]
|
65
65
|
|
66
66
|
rescue NoMethodError => e
|
67
67
|
# Empty file...
|
data/lib/super_stack/manager.rb
CHANGED
@@ -24,7 +24,7 @@ module SuperStack
|
|
24
24
|
|
25
25
|
def []=(key,value)
|
26
26
|
raise 'No write layer specified' if write_layer.nil?
|
27
|
-
write_layer[key] = value
|
27
|
+
write_layer[key.to_s] = value
|
28
28
|
end
|
29
29
|
|
30
30
|
def [](filter=nil)
|
@@ -44,7 +44,9 @@ module SuperStack
|
|
44
44
|
# Trick to return a bare hash
|
45
45
|
{}.merge res
|
46
46
|
else
|
47
|
-
res[filter]
|
47
|
+
value = res[filter]
|
48
|
+
value = res[filter.to_s] if filter.is_a? Symbol and value.nil?
|
49
|
+
value
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
data/lib/super_stack/version.rb
CHANGED
data/spec/manager_spec.rb
CHANGED
@@ -81,13 +81,13 @@ describe SuperStack::Manager do
|
|
81
81
|
subject << {bar: :foo}
|
82
82
|
subject.add_layer layer3
|
83
83
|
subject.add_layer layer4
|
84
|
-
expect(subject[:foo]
|
85
|
-
subject.layers['layer3'][
|
86
|
-
expect(subject[:foo]
|
87
|
-
expect(subject[:bar]
|
84
|
+
expect(subject[:foo]).not_to eq :bar
|
85
|
+
subject.layers['layer3']['foo'] = :bar
|
86
|
+
expect(subject[:foo]).to eq :bar
|
87
|
+
expect(subject[:bar]).to eq :foo
|
88
88
|
expect {subject.reload_layers}.not_to raise_error
|
89
|
-
expect(subject[:foo]
|
90
|
-
expect(subject[:bar]
|
89
|
+
expect(subject[:foo]).not_to eq :bar
|
90
|
+
expect(subject[:bar]).to eq :foo
|
91
91
|
end
|
92
92
|
|
93
93
|
it 'should not be possible to modify the manager if no write layer has been specified' do
|
@@ -111,8 +111,9 @@ describe SuperStack::Manager do
|
|
111
111
|
subject << layer1
|
112
112
|
subject.write_layer = override
|
113
113
|
expect {subject[:foo] = :bar}.not_to raise_error
|
114
|
-
expect(subject.layers['override'][
|
115
|
-
expect(subject[:foo]
|
114
|
+
expect(subject.layers['override']['foo']).to eq :bar
|
115
|
+
expect(subject[:foo]).to eq :bar
|
116
|
+
expect(subject['foo']).to eq :bar
|
116
117
|
end
|
117
118
|
|
118
119
|
|
@@ -206,11 +207,12 @@ describe SuperStack::Manager do
|
|
206
207
|
|
207
208
|
it 'should remain consistent regarding the write level' do
|
208
209
|
subject.write_layer = :layer3
|
209
|
-
expect(subject.write_layer
|
210
|
+
expect(subject.write_layer).to eq layer3
|
210
211
|
subject[:foo] = :bar
|
211
|
-
expect(layer3[
|
212
|
+
expect(layer3['foo']).to eq :bar
|
212
213
|
subject.remove_layer :layer3
|
213
|
-
expect(subject[:foo]
|
214
|
+
expect(subject[:foo]).not_to eq :bar
|
215
|
+
expect(subject['foo']).not_to eq :bar
|
214
216
|
expect(subject.write_layer).to be_nil
|
215
217
|
end
|
216
218
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: super_stack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Laurent B.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|