diff options
author | jkeiser <jkeiser@opscode.com> | 2013-01-19 14:00:02 -0800 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2013-06-07 13:12:23 -0700 |
commit | 35fa7b8c09d97bf4bb141beca7e3ae537e79e08d (patch) | |
tree | 4f9421ccc8e2dad31d01a1e39f21bfdc13534352 /lib/chef/chef_fs/data_handler/data_handler_base.rb | |
parent | d2ffedf9306474909c46f79610d0e6036f5ccc17 (diff) | |
download | chef-35fa7b8c09d97bf4bb141beca7e3ae537e79e08d.tar.gz |
Make diff output friendlier by not printing defaults and printing in a specific order
Diffstat (limited to 'lib/chef/chef_fs/data_handler/data_handler_base.rb')
-rw-r--r-- | lib/chef/chef_fs/data_handler/data_handler_base.rb | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/chef/chef_fs/data_handler/data_handler_base.rb b/lib/chef/chef_fs/data_handler/data_handler_base.rb index 21a3735add..66c3d9dbdc 100644 --- a/lib/chef/chef_fs/data_handler/data_handler_base.rb +++ b/lib/chef/chef_fs/data_handler/data_handler_base.rb @@ -5,7 +5,7 @@ class Chef def minimize(object, *keys) default_object = default({}, *keys) object.each_pair do |key, value| - if default_object[key] == key + if default_object[key] == value object.delete(key) end end @@ -16,6 +16,18 @@ class Chef normalize({}, *keys) end + def normalize(object, defaults) + # Make a normalized result in the specified order for diffing + result = {} + defaults.each_pair do |key, default| + result[key] = object.has_key?(key) ? object[key] : default + end + object.each_pair do |key, value| + result[key] = value if !result.has_key?(key) + end + result + end + def normalize_run_list(run_list) run_list.map{|item| case item @@ -41,10 +53,6 @@ class Chef raise NotImplementedError end - def normalize(object, *keys) - raise NotImplementedError - end - def chef_class raise NotImplementedError end |