compare

How to compare keys in yaml files?

天大地大妈咪最大 提交于 2020-08-22 04:42:48
问题 There are two ruby on rails internationalization yaml files. One file is complete and another one is with missing keys. How can I compare two yaml files and see missing keys in second file? Are there any tools for doing that? 回答1: Assuming file1 is the proper version and file2 is the version with missing keys: def compare_yaml_hash(cf1, cf2, context = []) cf1.each do |key, value| unless cf2.key?(key) puts "Missing key : #{key} in path #{context.join(".")}" next end value2 = cf2[key] if (value