Module: NodeSpec::BackendProxy::UnixshellUtility

Included in:
Exec, Ssh
Defined in:
lib/nodespec/backend_proxy/unixshell_utility.rb

Constant Summary collapse

SUDO_PREFIX =
'sudo'
TEMP_DIR =
'/tmp'

Instance Method Summary collapse

Instance Method Details

#cmd_create_directory(path) ⇒ Object



13
14
15
# File 'lib/nodespec/backend_proxy/unixshell_utility.rb', line 13

def cmd_create_directory(path)
  shellcmd("mkdir -p #{path.shellescape}")
end

#cmd_create_file(path, content) ⇒ Object



17
18
19
# File 'lib/nodespec/backend_proxy/unixshell_utility.rb', line 17

def cmd_create_file(path, content)
  shellcmd("cat > #{path.shellescape} << EOF\n#{content.strip.gsub('"', '\"')}\nEOF")
end

#run_as_sudo(cmd) ⇒ Object



9
10
11
# File 'lib/nodespec/backend_proxy/unixshell_utility.rb', line 9

def run_as_sudo(cmd)
  "#{SUDO_PREFIX} #{cmd}"
end

#temp_directoryObject



21
22
23
# File 'lib/nodespec/backend_proxy/unixshell_utility.rb', line 21

def temp_directory
  TEMP_DIR
end