subhash 0.1.0 → 0.1.1

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4438f0e738721e6c962927ac4ca4c9d532bd1257
4
- data.tar.gz: c70b1bb50ed69081842f8e27ec5f0589b0544d50
3
+ metadata.gz: 0b00b318ad28238acbf3a521efdc9bce58da2b91
4
+ data.tar.gz: 1602939ab1e875dc439ac412d5e00aebb4150a3c
5
5
  SHA512:
6
- metadata.gz: 0a6d52b5a2a87cc274534d49a5b53bcd9a834512ef3b6b25861eb660536e06614c84ad72c448b6ea237f913b1d9aa6d17e9fa985a2198f7f5bf398721bbdb172
7
- data.tar.gz: 04c7cad6557626bcb02e479ae44bf155e9f810c843f80b7e2769c3f8cc99fd4062e3891eec8890dea383eb0a590115a6b43f6758180479e80d77938bf9cec72b
6
+ metadata.gz: 68ca39aa5a95e8aa9d2f763811233e123dd988d793f2fea28273b82d326ce0a1b8597be70ff07e4a47244aaf90e5bf6d7d77568558ad0f5895a6468dcb67af3b
7
+ data.tar.gz: 82d78c72c71aef00db56185adbb943c05253edc272eb7b03988f496722f8074ea21814052fe3ceef832d0fe8af8cfeff831041bd32a09301fd7eff360bbddfc0
@@ -1,4 +1,5 @@
1
1
  # Recursive Hash
2
2
  module SubHash
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
+ DATE = '2015-05-11'
4
5
  end
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 rh_remove_control(result)
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| rh_remove_control(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| rh_remove_control(result[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
- rh_remove_control(result[key]) if result.key?(key)
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
- rh_remove_control(result[0]) # Remove all control elements in tree of arrays
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
@@ -6,6 +6,7 @@ require 'subhash/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'subhash'
8
8
  spec.version = SubHash::VERSION
9
+ spec.date = SubHash::DATE
9
10
  spec.authors = ['Christophe Larsonneur']
10
11
  spec.email = ['clarsonneur@gmail.com']
11
12
 
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.0
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-04-17 00:00:00.000000000 Z
11
+ date: 2015-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler