Skip to content

Instantly share code, notes, and snippets.

@jelies
Created September 19, 2014 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jelies/4534be010f953046951d to your computer and use it in GitHub Desktop.
Save jelies/4534be010f953046951d to your computer and use it in GitHub Desktop.
Capistrano function to upload files displaying a progress percentage.
desc "Uploads a file displaying the progress"
def upload_progress(source, target)
upload(source, target, :via => :sftp) do |event, options, *others|
if event.to_s == "put"
print ("\r * " + (("#{others[1]}".to_f / "#{others[0].size}".to_f) * 100).round(2).to_s + "%").ljust(10, ' ')
elsif event.to_s == "close"
print "\r"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment