class FileWithProgressBar
f = FileWithProgressBar.open(file, 'r') f.out = $stdout
Then pass f like any File object that invokes f.read
To upload with Fog: d = Storage.directories.create(key: 'drnic-test-upload') d.files.create(key: 'test.tgz', body: f) redis-2.8.12.: 100% |oooooooooooooo| 1.2MB 243.4KB/s Time: 00:00:04
Public Instance Methods
file_name()
click to toggle source
# File lib/bosh/gen/utils/file_with_progress_bar.rb, line 25 def file_name File.basename(self.path) end
out=(out)
click to toggle source
# File lib/bosh/gen/utils/file_with_progress_bar.rb, line 13 def out=(out) @out = out end
progress_bar()
click to toggle source
# File lib/bosh/gen/utils/file_with_progress_bar.rb, line 17 def progress_bar return @progress_bar if @progress_bar @out ||= StringIO.new @progress_bar = ProgressBar.new(file_name, size, @out) @progress_bar.file_transfer_mode @progress_bar end
read(*args)
click to toggle source
Calls superclass method
# File lib/bosh/gen/utils/file_with_progress_bar.rb, line 41 def read(*args) result = super(*args) if result && result.size > 0 progress_bar.inc(result.size) else progress_bar.finish end result end
size()
click to toggle source
# File lib/bosh/gen/utils/file_with_progress_bar.rb, line 33 def size @size || File.size(self.path) end
size=(size)
click to toggle source
# File lib/bosh/gen/utils/file_with_progress_bar.rb, line 37 def size=(size) @size=size end
stop_progress_bar()
click to toggle source
# File lib/bosh/gen/utils/file_with_progress_bar.rb, line 29 def stop_progress_bar progress_bar.halt unless progress_bar.finished? end
write(*args)
click to toggle source
Calls superclass method
# File lib/bosh/gen/utils/file_with_progress_bar.rb, line 53 def write(*args) count = super(*args) if count progress_bar.inc(count) else progress_bar.finish end count end