nice_hash 1.16.0 → 1.16.1

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
  SHA256:
3
- metadata.gz: 4894f796091ce28510214b7758d52d40f40547a781c81b9d75a57b8e3c50bcfa
4
- data.tar.gz: a6656db5d796ad0366421036bd5bd7a1646bbe6226b3bd53500e2a214fd7d3c3
3
+ metadata.gz: dae5a843bb25c0195b0563c21e6751e7c71f8b860cec6ee81a88748f5048cd47
4
+ data.tar.gz: c63f13bc76844057b350037c605055e48ecf3895a622a93ae2eabf0cab6a6d76
5
5
  SHA512:
6
- metadata.gz: c75cefbfbabbe7d018c53ba333a5fe88b525c8ec4c094ae876edc9fd6bee94e593f5ccce4896407c25be009c427bf2af0f2ee2b86ce23720b3fe0766254a11fb
7
- data.tar.gz: f1e6b4ccfa0706728962c55d2e928bf16690dff926d512cc658729b57ae6e21b7c470019c96897eae3f39935353c9d9f2e1291578a92b898da8aa8ee37a60701
6
+ metadata.gz: 6252f5ffcd0346673e31475255c9b83585f952b76848f1921fa361a04a454e4851ba49740b28e787589b0c30398759676b754dd6556016169550f356611d4f16
7
+ data.tar.gz: 3fc29d8ae093782c16ef79c8bfcf2b29ffab3ef9de7c63c5d1b345df0c3b4260c321536aa18d39295043db153326931c6385fac702f89085f8a2257d8e8f5029
@@ -33,13 +33,14 @@ class NiceHash
33
33
  structure.each do |key, value|
34
34
  if patterns.key?(key) and replica.key?(key)
35
35
  unless (patterns[key].is_a?(Array) and replica[key].is_a?(Array) and replica[key].empty?) or
36
+ (compare_only_if_exist_key and replica.key?(key) and replica[key].nil?) or
36
37
  {key => patterns[key]}.validate({key => replica[key]}).empty?
37
38
  puts "NiceHash.compare_structure: key :#{key} not following pattern #{patterns[key]}. value: #{replica[key]}"
38
39
  success = false
39
40
  end
40
41
  end
41
42
 
42
- if compare_only_if_exist_key and replica.key?(key)
43
+ if compare_only_if_exist_key and replica.key?(key) and !replica[key].nil?
43
44
  unless compare_structure(value, replica[key], compare_only_if_exist_key, patterns)
44
45
  puts "NiceHash.compare_structure: key :#{key} different."
45
46
  success = false
@@ -147,7 +147,7 @@ class NiceHash
147
147
  end
148
148
  }
149
149
  unless array_pattern or results.include?(key)
150
- if value.size == 1 and values[key].size > 1
150
+ if value.size == 1 and values[key].is_a?(Array) and values[key].size > 1
151
151
  # for the case value == ['Ford|Newton|Seat'] and values == ['Ford', 'Newton', 'Ford']
152
152
  i = 0
153
153
  if values[key].class == value.class
@@ -174,10 +174,12 @@ class NiceHash
174
174
  value.each { |v|
175
175
  if v.is_a?(Hash)
176
176
  res = NiceHash.validate([v, select_hash_key], values[key][i], only_patterns: only_patterns)
177
- else
177
+ elsif v.is_a?(Array)
178
178
  # for the case {cars: ['Ford|Newton|Seat']}
179
179
  res = NiceHash.validate([{ key => v }, select_hash_key], { key => values[key][i] }, only_patterns: only_patterns)
180
180
  array_pattern = true
181
+ else
182
+ res = []
181
183
  end
182
184
  if res.size > 0
183
185
  results[key] = Array.new() if !results.keys.include?(key)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nice_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.16.0
4
+ version: 1.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Ruiz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-07 00:00:00.000000000 Z
11
+ date: 2020-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: string_pattern