Skip to content

Instantly share code, notes, and snippets.

@sawanoboly
Created February 20, 2012 07:03
Show Gist options
  • Save sawanoboly/1868208 to your computer and use it in GitHub Desktop.
Save sawanoboly/1868208 to your computer and use it in GitHub Desktop.
config check for jenkins auto test.
def compare_yaml_hash(cf1, cf2, context = [])
case
when cf1.is_a?(Hash)
cf1.each do |key, value|
unless cf2.key?(key)
puts "Missing key : #{key} in path #{context.join(".")}"
raise "format error" #=> RuntimeError: format error
next
end
value2 = cf2[key]
if (value.class != value2.class)
puts "Key value type mismatch : #{key} in path #{context.join(".")}"
raise "yaml structure unmatched. Please edit for jenkins." #=> RuntimeError: format error
next
end
if value.is_a?(Hash)
compare_yaml_hash(value, cf2[key], (context << key))
next
end
end
when cf1.is_a?(Array)
cf1.each do |key|
if key.is_a?(Hash)
compare_yaml_hash(key, cf2[key], (context << key))
next
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment