module KnifeUploader::Utils
Public Class Methods
json_with_sorted_keys(h)
click to toggle source
# File lib/chef/knife/uploader_base.rb, line 89 def json_with_sorted_keys(h) JSON.pretty_generate(recursive_sort_hash_keys(h)) + "\n" end
recursive_sort_hash_keys(obj)
click to toggle source
# File lib/chef/knife/uploader_base.rb, line 79 def recursive_sort_hash_keys(obj) if [Hash, Hashie::Mash, VariaModel::Attributes].include?(obj.class) Hash[*obj.sort.map {|k, v| [k, recursive_sort_hash_keys(v)] }.flatten(1)] elsif obj.instance_of?(Array) obj.map {|element| recursive_sort_hash_keys(element) } else obj end end
sort_hash_keys(h)
click to toggle source
# File lib/chef/knife/uploader_base.rb, line 75 def sort_hash_keys(h) Hash[*h.sort.flatten(1)] end