Created
September 19, 2014 15:19
-
-
Save jelies/4534be010f953046951d to your computer and use it in GitHub Desktop.
Capistrano function to upload files displaying a progress percentage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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