squire 1.2.5 → 1.2.6
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.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NWY4ODFlMTY4YzIzYjlkNmVlNTIyYWQ2ODJkYzQ1M2UxYmU4ZjNlOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NTZjNmZiM2JjNTY1ZjhjNmI2ZGE2YWRjZDllMjQyMjlhYzlmM2QwMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDE2ZTNlYWQwMmU2OTdjMTg1MGE5ZGI5OTJkYTcxNWRmNDcxNmJkN2UzMTdj
|
10
|
+
YTRkNjZkMTViZTQ3YWIyMzYxYzk4MmEzNGUwZTFhMTE3Y2MzNmUzOGQwYWYy
|
11
|
+
YzNmZmE2Zjc3NDU5ZDU4ZjQ4YTBhMTczOTQ5M2ZmNGJmNWZiYWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MGQ4Nzg3Yjc3Yjc4MjFjOTBmZTg0ZTM2ZTVhZjk1NzkxNWE3NGM0NGM2Y2Zk
|
14
|
+
MGMzMGMxMjg5Y2UwM2U5NmQ0NTQ2YzZkNjkzMjM2Nzk2ZTVhMDA1NThlNTI4
|
15
|
+
OTlhNWNkYzA1YjBmNGUyNzRiZjcxNDUzNzM5OTdlOThlZDM2ODY=
|
data/CHANGELOG.md
CHANGED
data/lib/squire/configuration.rb
CHANGED
@@ -76,7 +76,7 @@ module Squire
|
|
76
76
|
if base_namespace
|
77
77
|
hash.except(base_namespace).each do |key, values|
|
78
78
|
# favours value from namespace over value from defaults
|
79
|
-
|
79
|
+
hash[key] = hash[base_namespace].deep_merge(values) { |_, default, value| value.nil? ? default : value }
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
@@ -19,10 +19,11 @@ class Hash
|
|
19
19
|
def deep_merge!(other_hash, &block)
|
20
20
|
other_hash.each_pair do |k,v|
|
21
21
|
tv = self[k]
|
22
|
+
|
22
23
|
if tv.is_a?(Hash) && v.is_a?(Hash)
|
23
24
|
self[k] = tv.deep_merge(v, &block)
|
24
25
|
else
|
25
|
-
self[k] = block
|
26
|
+
self[k] = block ? block.call(k, tv, v) : v
|
26
27
|
end
|
27
28
|
end
|
28
29
|
self
|
data/lib/squire/version.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Squire::Configuration do
|
4
|
-
subject { described_class.new }
|
5
|
-
|
6
4
|
let(:hash) {
|
7
5
|
{
|
8
6
|
defaults: {
|
9
7
|
nested: {
|
10
8
|
b: 3,
|
11
|
-
|
12
|
-
|
9
|
+
d: true,
|
10
|
+
c: 4
|
13
11
|
}
|
14
12
|
},
|
15
13
|
development: {
|
@@ -20,7 +18,10 @@ describe Squire::Configuration do
|
|
20
18
|
}
|
21
19
|
},
|
22
20
|
production: {
|
23
|
-
a: 3
|
21
|
+
a: 3,
|
22
|
+
nested: {
|
23
|
+
b: 4
|
24
|
+
}
|
24
25
|
}
|
25
26
|
}
|
26
27
|
}
|
@@ -70,6 +71,13 @@ describe Squire::Configuration do
|
|
70
71
|
subject.settings.nested.b.should eql(2) # from development.nested.b
|
71
72
|
subject.settings.nested.d.should be_false # from development.nested.d
|
72
73
|
subject.settings.nested.c.should eql(4) # from defaults.nested.c
|
74
|
+
|
75
|
+
subject.source hash
|
76
|
+
subject.namespace :production, base: :defaults
|
77
|
+
|
78
|
+
subject.settings.a.should eql(3)
|
79
|
+
subject.settings.nested.b.should eql(4) # from development.nested.b
|
80
|
+
subject.settings.nested.d.should be_true # from development.nested.d
|
73
81
|
end
|
74
82
|
end
|
75
83
|
|
@@ -12,7 +12,7 @@ describe Hash do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'should merge hashes deeply with block' do
|
15
|
-
merge = { a: [:a, 1, 1], b: 2, c: [:c, 3, 3], d: 4, nested: { a: [:a, 1, 2], b: 3 }}
|
15
|
+
merge = { a: [:a, 1, 1], b: 2, c: [:c, 3, 3], d: [:d, nil, 4], nested: { a: [:a, 1, 2], b: [:b, nil, 3] }}
|
16
16
|
|
17
17
|
(a.deep_merge(b) { |key, old, new| [key, old, new] }).should eql(merge)
|
18
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: squire
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Molnar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09
|
11
|
+
date: 2013-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|