lib/bard/base.rb in bard-0.62.2 vs lib/bard/base.rb in bard-0.63.0

- old
+ new

@@ -30,12 +30,12 @@ def project_name @project_name ||= File.expand_path(".").split("/").last end - def ssh_command server, command, home: false - server = @config.servers[server.to_sym] + def ssh_command server_name, command, home: false + server = @config.servers.fetch(server_name.to_sym) uri = URI.parse("ssh://#{server.ssh}") ssh_key = server.ssh_key ? "-i #{server.ssh_key} " : "" command = "#{server.env} #{command}" if server.env command = "cd #{server.path} && #{command}" unless home command = "ssh -tt #{ssh_key}#{"-p#{uri.port} " if uri.port}#{uri.user}@#{uri.host} '#{command}'" @@ -44,12 +44,12 @@ command = "ssh -tt #{" -p#{uri.port} " if uri.port}#{uri.user}@#{uri.host} \"#{command}\"" end command end - def copy direction, server, path, verbose: false - server = @config.servers[server.to_sym] + def copy direction, server_name, path, verbose: false + server = @config.servers.fetch(server_name.to_sym) uri = URI.parse("ssh://#{server.gateway}") port = uri.port ? "-p#{uri.port}" : "" gateway = server.gateway ? "-oProxyCommand='ssh #{port} #{uri.user}@#{uri.host} -W %h:%p'" : "" @@ -63,13 +63,13 @@ command = "scp #{gateway} #{ssh_key} #{port} #{from_and_to.join(" ")}" run_crucial command, verbose: verbose end - def move from, to, path, verbose: false - from = @config.servers[from.to_sym] - to = @config.servers[to.to_sym] + def move from_name, to_name, path, verbose: false + from = @config.servers.fecth(from_name.to_sym) + to = @config.servers.fetch(to_name.to_sym) raise NotImplementedError if from.gateway || to.gateway || from.ssh_key || to.ssh_key from_uri = URI.parse("ssh://#{from.ssh}") from_str = "scp://#{from_uri.user}@#{from_uri.host}:#{from_uri.port || 22}/#{from.path}/#{path}" @@ -79,12 +79,12 @@ command = "scp -o ForwardAgent=yes #{from_str} #{to_str}" run_crucial command, verbose: verbose end - def rsync direction, server, path, verbose: false - server = @config.servers[server.to_sym] + def rsync direction, server_name, path, verbose: false + server = @config.servers.fetch(server_name.to_sym) uri = URI.parse("ssh://#{server.gateway}") port = uri.port ? "-p#{uri.port}" : "" gateway = server.gateway ? "-oProxyCommand=\"ssh #{port} #{uri.user}@#{uri.host} -W %h:%p\"" : "" @@ -102,12 +102,12 @@ command = "rsync #{ssh} --delete --info=progress2 -az #{from_and_to.join(" ")}" run_crucial command, verbose: verbose end - def rsync_remote from, to, path, verbose: false - from = @config.servers[from.to_sym] - to = @config.servers[to.to_sym] + def rsync_remote from_name, to_name, path, verbose: false + from = @config.servers.fetch(from_name.to_sym) + to = @config.servers.fetch(to_name.to_sym) raise NotImplementedError if from.gateway || to.gateway || from.ssh_key || to.ssh_key dest_path = path.dup dest_path = "./#{dest_path}"