Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create send_directory backend command #283

Merged
merged 1 commit into from
Dec 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/specinfra/backend/exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def send_file(from, to)
FileUtils.cp(from, to)
end

def send_directory(from, to)
FileUtils.cp_r(from, to)
end

def build_command(cmd)
shell = Specinfra.configuration.shell || '/bin/sh'
cmd = cmd.shelljoin if cmd.is_a?(Array)
Expand Down
24 changes: 16 additions & 8 deletions lib/specinfra/backend/ssh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,11 @@ def run_command(cmd, opt={})
end

def send_file(from, to)
if Specinfra.configuration.scp.nil?
Specinfra.configuration.scp = create_scp
end
scp_upload!(from, to)
end

tmp = File.join('/tmp', File.basename(to))
scp = Specinfra.configuration.scp
scp.upload!(from, tmp)
run_command(Specinfra.command.get(:move_file, tmp, to))
def send_directory(from, to)
scp_upload!(from, to, :recursive => true)
end

def build_command(cmd)
Expand Down Expand Up @@ -84,7 +81,18 @@ def create_scp
end
Net::SCP.new(ssh)
end


def scp_upload!(from, to, opt={})
if Specinfra.configuration.scp.nil?
Specinfra.configuration.scp = create_scp
end

tmp = File.join('/tmp', File.basename(to))
scp = Specinfra.configuration.scp
scp.upload!(from, tmp, opt)
run_command(Specinfra.command.get(:move_file, tmp, to))
end

def ssh_exec!(command)
stdout_data = ''
stderr_data = ''
Expand Down