subhash 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/subhash/version.rb +2 -1
- data/lib/subhash.rb +17 -7
- data/subhash.gemspec +1 -0
- 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: 0b00b318ad28238acbf3a521efdc9bce58da2b91
|
4
|
+
data.tar.gz: 1602939ab1e875dc439ac412d5e00aebb4150a3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68ca39aa5a95e8aa9d2f763811233e123dd988d793f2fea28273b82d326ce0a1b8597be70ff07e4a47244aaf90e5bf6d7d77568558ad0f5895a6468dcb67af3b
|
7
|
+
data.tar.gz: 82d78c72c71aef00db56185adbb943c05253edc272eb7b03988f496722f8074ea21814052fe3ceef832d0fe8af8cfeff831041bd32a09301fd7eff360bbddfc0
|
data/lib/subhash/version.rb
CHANGED
data/lib/subhash.rb
CHANGED
@@ -28,21 +28,30 @@ end
|
|
28
28
|
module Rh
|
29
29
|
public
|
30
30
|
|
31
|
+
def merge_cleanup!
|
32
|
+
_rh_remove_control(self)
|
33
|
+
end
|
34
|
+
|
35
|
+
def merge_cleanup
|
36
|
+
_rh_remove_control(rh_clone)
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
31
41
|
# Function which will parse arrays in hierarchie and will remove any control
|
32
42
|
# element (index 0)
|
33
|
-
def
|
43
|
+
def _rh_remove_control(result)
|
34
44
|
return unless [Hash, Array].include?(result.class)
|
35
45
|
|
36
46
|
if result.is_a?(Hash)
|
37
|
-
result.each { |elem|
|
47
|
+
result.each { |elem| _rh_remove_control(elem) }
|
38
48
|
else
|
39
49
|
result.delete_at(0) if result[0].is_a?(Hash) && result[0].key?(:__control)
|
40
|
-
result.each_index { |index|
|
50
|
+
result.each_index { |index| _rh_remove_control(result[index]) }
|
41
51
|
end
|
52
|
+
result
|
42
53
|
end
|
43
54
|
|
44
|
-
private
|
45
|
-
|
46
55
|
# Internal function to determine if result and data key contains both Hash or
|
47
56
|
# Array and if so, do the merge task on those sub Hash/Array
|
48
57
|
#
|
@@ -565,7 +574,7 @@ class Hash
|
|
565
574
|
_do_rh_merge(result, key, data, true) if data.key?(key)
|
566
575
|
|
567
576
|
# Remove all control element in arrays
|
568
|
-
|
577
|
+
_rh_remove_control(result[key]) if result.key?(key)
|
569
578
|
end
|
570
579
|
|
571
580
|
result
|
@@ -762,7 +771,8 @@ class Array
|
|
762
771
|
end
|
763
772
|
|
764
773
|
_rh_do_array_merge(result, 0, [data_control])
|
765
|
-
|
774
|
+
# Remove all control elements in tree of arrays
|
775
|
+
_rh_remove_control(result[0])
|
766
776
|
|
767
777
|
result
|
768
778
|
end
|
data/subhash.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: subhash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christophe Larsonneur
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|