Sha256: 5bb51547d5aab8144f80e05649e69128a5a9b55f9af3de74c04e94a1c6e8c252
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
require "net/ssh" require "yaml" module Yads class ConfigNotFound < Errno::ENOENT; end class Deployer def initialize(logger = STDOUT) @logger = logger end def deploy begin config = YAML.load(File.open("config/deploy.yml")) rescue Errno::ENOENT raise Yads::ConfigNotFound, "config/deploy.yml not found" end Net::SSH.start(config["host"], config["user"], :forward_agent => config["forward_agent"]) do |ssh| check_path(ssh, config["path"], config["commands"].delete("clone")) commands = config["commands"].values.unshift("cd #{config['path']}").join(" && ") @logger.puts "> #{commands}" @logger.puts ssh.exec(commands) do |ch, stream, data| print data end ssh.loop end end def check_path(ssh, path, clone) @logger.puts "> cd #{path}/.git" ssh.exec("cd #{path}/.git") do |ch, stream, data| if stream == :stderr @logger.puts "> cd #{path}" ssh.exec("cd #{path}") do |ch1, stream1, data1| @logger.puts "> #{clone}" ssh.exec(clone) do |ch1, stream1, data1| abort data1 if stream1 == :stderr @logger.puts "> cd #{path}" ssh.exec("cd #{path}") end end end end ssh.loop end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yads-0.0.3.pre | lib/yads.rb |