Skip to content

Commit

Permalink
Merge branch 'feature/user@sever' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
catsby committed Jan 28, 2011
2 parents 22fb069 + 36a0622 commit 856e0a2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
12 changes: 10 additions & 2 deletions features/gt_scp_file.feature
Expand Up @@ -7,8 +7,16 @@ Feature: growl-down downloads a file via scp
And not have to watch or check the progress And not have to watch or check the progress


Scenario: Download file assuming ssh keyless authentication Scenario: Download file assuming ssh keyless authentication
Given I have an available server "ctshryock.com" Given I have ssh keyless auth setup on "ctshryock.com"
And "growl-down-test/unicorns.zip" as the file name And specify "growl-down-test/unicorns.zip" as the file name
When I run "download"
Then I should see "Finished!"
And TEST_DIR should contains "unicorns.zip" file

Scenario: Download file assuming ssh keyless auth, but specify a username
Given I have ssh keyless auth setup on "ctshryock.com"
And I specify "clint" as the username before the url
And specify "growl-down-test/unicorns.zip" as the file name
When I run "download" When I run "download"
Then I should see "Finished!" Then I should see "Finished!"
And TEST_DIR should contains "unicorns.zip" file And TEST_DIR should contains "unicorns.zip" file
Expand Down
8 changes: 6 additions & 2 deletions features/step_definitions/gt_scp_steps.rb
Expand Up @@ -25,15 +25,19 @@ def output
@output ||= Output.new @output ||= Output.new
end end


Given /^I have an available server "([^"]*)"$/ do |remote_host| Given /^I have ssh keyless auth setup on "([^"]*)"$/ do |remote_host|
@remote = [] @remote = []
@remote << remote_host @remote << remote_host
end end


When /^"([^"]*)" as the file name$/ do |remote_path| Given /^specify "([^"]*)" as the file name$/ do |remote_path|
@remote << remote_path @remote << remote_path
end end


Given /^I specify "([^"]*)" as the username before the url$/ do |arg1|
@remote[0] = 'clint' + '@' + @remote[0]
end

When /^I run "([^"]*)"$/ do |arg1| When /^I run "([^"]*)"$/ do |arg1|
gd_scp = GrowlTransfer::GTScp.new(output) gd_scp = GrowlTransfer::GTScp.new(output)
gd_scp.download(@remote.join(':'), TEST_DIR) gd_scp.download(@remote.join(':'), TEST_DIR)
Expand Down
11 changes: 10 additions & 1 deletion lib/growl-transfer/gt_scp.rb
Expand Up @@ -8,7 +8,16 @@ def download(remote, local_path)
@output.puts "Downloading #{remote}" @output.puts "Downloading #{remote}"
params = remote.split(":") params = remote.split(":")
file = params.last.split("/").last file = params.last.split("/").last
Net::SCP.start(params[0], ENV['USER']) do |scp|
if params[0].include? '@'
server = params[0].split('@').last
user = params[0].split('@').first
else
server = params[0]
user = ENV['USER']
end

Net::SCP.start(server, user) do |scp|
scp.download!(params[1], local_path, {:recursive => true, :verbose => true}) do |ch, name, sent, total| scp.download!(params[1], local_path, {:recursive => true, :verbose => true}) do |ch, name, sent, total|
# => progress? # => progress?
end end
Expand Down

0 comments on commit 856e0a2

Please sign in to comment.