22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/dorian/yaml/compare.rb', line 22
def self.compare(hash1, hash2, current: '')
if hash1.kind_of?(Array)
hash1.each.with_index do |_, i|
compare(hash1[i], hash2[i], current: current)
end
elsif hash1.kind_of?(String) || hash2.kind_of?(String)
if !hash1.kind_of?(String)
puts "key \"#{current}\" is a string in #{ARGV[1]}"
elsif !hash2.kind_of?(String)
puts "key \"#{current}\" is a string in #{ARGV[0]}"
end
else
(hash1.keys + hash2.keys).uniq.each do |key|
full_key = [current, key].reject(&:empty?).join(".")
if !hash1.key?(key)
puts "missing key \"#{full_key}\" from #{ARGV[0]}"
elsif !hash2.key?(key)
puts "missing key \"#{full_key}\" from #{ARGV[1]}"
else
compare(hash1[key], hash2[key], current: full_key)
end
end
end
end
|