I\'ve been trying to write a small library using Thor to help assist me in quick creating new projects and sites. I wrote this small method:
def ssh(cmd)
Actually in the end, I did something very similar to Riba's suggestion (although his/her code is much better and smarter, I think)
def ssh(env, cmd, opts={})
Net::SSH.start( config[env]["ip"], config[env]["user"], :port => config[env]["port"]) do |session|
cmd = "sudo #{cmd}" if opts[:sudo]
print cmd
session.exec cmd
end
end