Module: Kitchen::Util
- Defined in:
- lib/kitchen/binding/core_ext/util.rb
Overview
Stateless utility methods used in different contexts. Essentially a mini PassiveSupport library.
Class Method Summary collapse
-
.wrap_command(cmd) ⇒ String
Generates a command (or series of commands) wrapped so that it can be invoked on a remote instance or locally.
Class Method Details
.wrap_command(cmd) ⇒ String
Generates a command (or series of commands) wrapped so that it can be invoked on a remote instance or locally.
This method uses the Bourne shell (/bin/sh) to maximize the chance of cross platform portability on Unixlike systems.
110 111 112 113 114 115 116 |
# File 'lib/kitchen/binding/core_ext/util.rb', line 110 def self.wrap_command(cmd) cmd = "false" if cmd.nil? cmd = "true" if cmd.to_s.empty? cmd = cmd.sub(/\n\Z/, "") if cmd =~ /\n\Z/ "sh -c '\n#{cmd}\n'" end |