lib/kontena/util.rb in kontena-cli-0.15.0 vs lib/kontena/util.rb in kontena-cli-0.15.1
- old
+ new
@@ -1,8 +1,7 @@
module Kontena
module Util
-
def self.included(base)
base.extend(ClassMethods)
end
# @param [String] cmd
@@ -14,15 +13,28 @@
return exe if File.executable?(exe) && !File.directory?(exe)
}
end
return nil
end
+
+ # Compatibility between ruby_dig and Ruby 2.3. Ruby_dig returns
+ # nil when trying to dig into a string, Ruby 2.3 dig raises
+ # TypeError.
+ #
+ # @param [Hash] source_hash
+ # @param [*keys] list_of_keys
+ def safe_dig(hash, *keys)
+ hash.dig(*keys)
+ rescue TypeError
+ nil
+ end
+
module_function(:which)
module ClassMethods
def experimental?
ENV.has_key?('KONTENA_EXPERIMENTAL')
- end
+ end
end
-
+
end
end