rbsync 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rbsync.rb +50 -0
- data/rbsync.gemspec +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/lib/rbsync.rb
CHANGED
@@ -329,6 +329,56 @@ class RbSync
|
|
329
329
|
alias newer= updated_file_only=
|
330
330
|
end
|
331
331
|
|
332
|
+
# ==プログレスバーを表示する.
|
333
|
+
# prg= ProgressBar.new
|
334
|
+
# prg.show_percent = true
|
335
|
+
# prg.size = 60
|
336
|
+
# prg.start("downloading\n")
|
337
|
+
# 100.times{|i|
|
338
|
+
# prg.progress(i, "#{i}/100")
|
339
|
+
# sleep 0.015
|
340
|
+
# }
|
341
|
+
# prg.end("done")
|
342
|
+
class ProgressBar
|
343
|
+
attr_accessor :size, :out, :bar_char_undone, :bar_char_done, :show_percent
|
344
|
+
def initialize()
|
345
|
+
@out = $stdout
|
346
|
+
@size = 11
|
347
|
+
@bar_char_undone = "_"
|
348
|
+
@bar_char_done = "#"
|
349
|
+
@show_percent = true
|
350
|
+
@printend_max_size = @size
|
351
|
+
end
|
352
|
+
def start(message="")
|
353
|
+
out.print message
|
354
|
+
out.print bar_char_undone * size
|
355
|
+
out.flush
|
356
|
+
end
|
357
|
+
def end(message="")
|
358
|
+
progress(100)
|
359
|
+
out.print " " + message
|
360
|
+
out.puts ""
|
361
|
+
out.flush
|
362
|
+
end
|
363
|
+
def clear()
|
364
|
+
out.print "\r"
|
365
|
+
line_size = [@printend_max_size, @size].max
|
366
|
+
out.print " " * line_size
|
367
|
+
out.flush
|
368
|
+
end
|
369
|
+
def progress(percent,message=nil)
|
370
|
+
clear()
|
371
|
+
str =""
|
372
|
+
str << "\r"
|
373
|
+
str << bar_char_done * ((percent.to_f/100.to_f)*size).to_i
|
374
|
+
str << bar_char_undone * (size - ((percent.to_f/100.to_f)*size).to_i)
|
375
|
+
str << " " + percent.to_s + "%" if show_percent
|
376
|
+
str << " " + message if message
|
377
|
+
@printend_max_size = str.size if str.size > @printend_max_size
|
378
|
+
out.print str
|
379
|
+
out.flush
|
380
|
+
end
|
381
|
+
end
|
332
382
|
|
333
383
|
#require 'tmpdir'
|
334
384
|
#require 'find'
|
data/rbsync.gemspec
CHANGED
metadata
CHANGED