lib/miam/client.rb in miam-0.2.2.beta4 vs lib/miam/client.rb in miam-0.2.2
- old
+ new
@@ -257,12 +257,12 @@
walk_policies(:role, role_name, expected_attrs[:policies], actual_attrs[:policies]) || updated
end
def walk_assume_role_policy(role_name, expected_assume_role_policy, actual_assume_role_policy)
updated = false
- expected_assume_role_policy = recursively_sort_arrays_and_hashes(expected_assume_role_policy)
- actual_assume_role_policy = recursively_sort_arrays_and_hashes(actual_assume_role_policy)
+ expected_assume_role_policy.sort_array!
+ actual_assume_role_policy.sort_array!
if expected_assume_role_policy != actual_assume_role_policy
@driver.update_assume_role_policy(role_name, expected_assume_role_policy, actual_assume_role_policy)
updated = true
end
@@ -467,20 +467,9 @@
def exec_by_format(proc_by_format)
format_proc = proc_by_format[@options[:format]]
raise "Invalid format: #{@options[:format]}" unless format_proc
format_proc.call
- end
-
- def recursively_sort_arrays_and_hashes(obj)
- case obj
- when Array
- obj.map!{|v| recursively_sort_arrays_and_hashes(v)}.sort_by!{|v| (v.to_s rescue nil) }
- when Hash
- obj = Hash[Hash[obj.map{|k,v| [recursively_sort_arrays_and_hashes(k),recursively_sort_arrays_and_hashes(v)]}].sort_by{|k,v| [(k.to_s rescue nil), (v.to_s rescue nil)]}]
- else
- obj
- end
end
def load_json(json)
json = JSON.load(json)
normalized = {}