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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 54cbe4ddd3ce5e7164c09042f75841a327cd1a1c
4
- data.tar.gz: a01f72c6e8ab135e13cf12d0f9662e1bfa6c75fc
3
+ metadata.gz: 252c5d3c0c7502cd8d199660fd2366328c1a0b62
4
+ data.tar.gz: e8f0846916ab97dce8071ceffe9b6bf692ae7c3d
5
5
  SHA512:
6
- metadata.gz: 771fcfb537611679e55a5fc36c14755ee276f71f3261190245b9299e54ec1f7fa460676f1e5a80056aa673ae9fcc9e9ab438850dd8a02c88bd3fc3aa4f64a83f
7
- data.tar.gz: b9a855e2c8e20d9e15181ceb843da436c6b70175f96ed1deb8c0c088a67a65b6024e943e7eb265a96055ec86601195893bb262c13c68a0d81a7f5b1b66a7b64a
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 hash. (`manager` itself has no `Hash` in its ancestors, whereas `manager[]` *is* actually a `Hash`).
42
+ do with a regular `Hash`.
43
43
 
44
- **None of the layers is modified by the manager**.
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
- * removed (using the manager's `remove_layer(layer_or_layer_name)` method).
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.to_sym, v] }]
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...
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module SuperStack
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
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] == :bar).to be_falsey
85
- subject.layers['layer3'][:foo] = :bar
86
- expect(subject[:foo] == :bar).to be_truthy
87
- expect(subject[:bar] == :foo).to be_truthy
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] == :bar).to be_falsey
90
- expect(subject[:bar] == :foo).to be_truthy
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'][:foo] == :bar).to be_truthy
115
- expect(subject[:foo] == :bar).to be_truthy
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 == layer3).to be_truthy
210
+ expect(subject.write_layer).to eq layer3
210
211
  subject[:foo] = :bar
211
- expect(layer3[:foo] == :bar).to be_truthy
212
+ expect(layer3['foo']).to eq :bar
212
213
  subject.remove_layer :layer3
213
- expect(subject[:foo] == :bar).to be_falsey
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.3.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-18 00:00:00.000000000 Z
11
+ date: 2015-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler