lib/kontena/util.rb in kontena-cli-1.4.0.pre6 vs lib/kontena/util.rb in kontena-cli-1.4.0.pre7
- old
+ new
@@ -26,9 +26,33 @@
end
obj
end
module_function :symbolize_keys!
+ def stringify_keys(obj)
+ case obj
+ when Hash
+ obj.map { |k,v| [k.to_s, stringify_keys(v)] }.to_h
+ when Array
+ obj.map { |v| stringify_keys(v) }
+ else
+ obj
+ end
+ end
+ module_function :stringify_keys
+
+ def stringify_keys!(obj)
+ case obj
+ when Hash
+ obj.keys.each { |k| obj[k.to_s] = stringify_keys!(obj.delete(k)) }
+ when Array
+ obj.map! { |v| stringify_keys!(v) }
+ else
+ end
+ obj
+ end
+ module_function :stringify_keys!
+
# @param [String] cmd
def which(cmd)
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
exts.each { |ext|