progressbar 0.21.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/LICENSE.txt +19 -0
  5. data/README.md +38 -0
  6. data/Rakefile +2 -14
  7. data/lib/progressbar.rb +14 -284
  8. data/lib/ruby-progressbar/base.rb +161 -0
  9. data/lib/ruby-progressbar/calculators/length.rb +88 -0
  10. data/lib/ruby-progressbar/calculators/length_spec.rb +9 -0
  11. data/lib/ruby-progressbar/calculators/running_average.rb +9 -0
  12. data/lib/ruby-progressbar/components.rb +5 -0
  13. data/lib/ruby-progressbar/components/bar.rb +96 -0
  14. data/lib/ruby-progressbar/components/percentage.rb +29 -0
  15. data/lib/ruby-progressbar/components/rate.rb +43 -0
  16. data/lib/ruby-progressbar/components/time.rb +103 -0
  17. data/lib/ruby-progressbar/components/title.rb +13 -0
  18. data/lib/ruby-progressbar/errors/invalid_progress_error.rb +4 -0
  19. data/lib/ruby-progressbar/format.rb +3 -0
  20. data/lib/ruby-progressbar/format/formatter.rb +27 -0
  21. data/lib/ruby-progressbar/format/molecule.rb +58 -0
  22. data/lib/ruby-progressbar/format/string.rb +36 -0
  23. data/lib/ruby-progressbar/output.rb +61 -0
  24. data/lib/ruby-progressbar/outputs/non_tty.rb +47 -0
  25. data/lib/ruby-progressbar/outputs/tty.rb +32 -0
  26. data/lib/ruby-progressbar/progress.rb +114 -0
  27. data/lib/ruby-progressbar/throttle.rb +25 -0
  28. data/lib/ruby-progressbar/time.rb +30 -0
  29. data/lib/ruby-progressbar/timer.rb +72 -0
  30. data/lib/ruby-progressbar/version.rb +3 -0
  31. data/spec/fixtures/benchmark.rb +28 -0
  32. data/spec/ruby-progressbar/base_spec.rb +949 -0
  33. data/spec/ruby-progressbar/calculators/length_calculator_spec.rb +17 -0
  34. data/spec/ruby-progressbar/calculators/running_average_spec.rb +19 -0
  35. data/spec/ruby-progressbar/components/bar_spec.rb +234 -0
  36. data/spec/ruby-progressbar/components/percentage_spec.rb +9 -0
  37. data/spec/ruby-progressbar/components/rate_spec.rb +9 -0
  38. data/spec/ruby-progressbar/components/throttle_spec.rb +157 -0
  39. data/spec/ruby-progressbar/components/time_spec.rb +307 -0
  40. data/spec/ruby-progressbar/components/title_spec.rb +12 -0
  41. data/spec/ruby-progressbar/format/formatter_spec.rb +9 -0
  42. data/spec/ruby-progressbar/format/molecule_spec.rb +30 -0
  43. data/spec/ruby-progressbar/format/string_spec.rb +9 -0
  44. data/spec/ruby-progressbar/output_spec.rb +7 -0
  45. data/spec/ruby-progressbar/outputs/non_tty_spec.rb +9 -0
  46. data/spec/ruby-progressbar/outputs/tty_spec.rb +9 -0
  47. data/spec/ruby-progressbar/progress_spec.rb +156 -0
  48. data/spec/ruby-progressbar/time_spec.rb +45 -0
  49. data/spec/ruby-progressbar/timer_spec.rb +7 -0
  50. data/spec/spec_helper.rb +6 -0
  51. data/spec/support/time.rb +17 -0
  52. metadata +134 -69
  53. metadata.gz.sig +3 -0
  54. data/.gitignore +0 -23
  55. data/.ruby-version +0 -1
  56. data/.travis.yml +0 -6
  57. data/ChangeLog +0 -113
  58. data/Gemfile +0 -4
  59. data/Gemfile.lock +0 -27
  60. data/LICENSE +0 -1
  61. data/README.rdoc +0 -116
  62. data/progressbar.gemspec +0 -29
  63. data/test/test.rb +0 -125
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in ruby-duration.gemspec
4
- gemspec
data/Gemfile.lock DELETED
@@ -1,27 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- progressbar (0.21.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- bluecloth (2.1.0)
10
- minitest (2.2.2)
11
- rake (0.9.2)
12
- simplecov (0.4.2)
13
- simplecov-html (~> 0.4.4)
14
- simplecov-html (0.4.5)
15
- yard (0.7.1)
16
-
17
- PLATFORMS
18
- ruby
19
-
20
- DEPENDENCIES
21
- bluecloth (>= 0.3.5)
22
- bundler (>= 1.0.0)
23
- minitest
24
- progressbar!
25
- rake
26
- simplecov (>= 0.3.5)
27
- yard
data/LICENSE DELETED
@@ -1 +0,0 @@
1
- Ruby/ProgressBar is a free software with ABSOLUTELY NO WARRANTY under the terms of Ruby's license.
data/README.rdoc DELETED
@@ -1,116 +0,0 @@
1
- =begin
2
- index:Ej
3
-
4
- = Ruby/ProgressBar: A Text Progress Bar Library for Ruby
5
-
6
- Last Modified: 2005-05-22 00:28:04
7
-
8
- --
9
-
10
- Ruby/ProgressBar is a text progress bar library for Ruby.
11
- It can indicate progress with percentage, a progress bar,
12
- and estimated remaining time.
13
-
14
- The latest version of Ruby/ProgressBar is available at
15
- ((<URL:http://namazu.org/~satoru/ruby-progressbar/>))
16
- .
17
-
18
- == Examples
19
-
20
- % irb --simple-prompt -r progressbar
21
- >> pbar = ProgressBar.new("test", 100)
22
- => (ProgressBar: 0/100)
23
- >> 100.times {sleep(0.1); pbar.inc}; pbar.finish
24
- test: 100% |oooooooooooooooooooooooooooooooooooooooo| Time: 00:00:10
25
- => nil
26
-
27
- >> pbar = ProgressBar.new("test", 100)
28
- => (ProgressBar: 0/100)
29
- >> (1..100).each{|x| sleep(0.1); pbar.set(x)}; pbar.finish
30
- test: 67% |oooooooooooooooooooooooooo | ETA: 00:00:03
31
-
32
- >> ProgressBar.new("test", 100) do |pbar|
33
- >> 100.times { sleep(0.1); pbar.inc }
34
- >> end
35
- test: 100% |oooooooooooooooooooooooooooooooooooooooo| Time: 00:00:10
36
-
37
-
38
- == API
39
-
40
- --- ProgressBar#new (title, total, out = STDERR, &block)
41
- Display the initial progress bar and return a
42
- ProgressBar object. ((|title|)) specifies the title,
43
- and ((|total|)) specifies the total cost of processing.
44
- Optional parameter ((|out|)) specifies the output IO.
45
-
46
- The display of the progress bar is updated when one or
47
- more percent is proceeded or one or more seconds are
48
- elapsed from the previous display.
49
-
50
- It also accepts a block in case you prefer not needing
51
- to .finish the bar (see example above).
52
-
53
- --- ProgressBar#inc (step = 1)
54
- Increase the internal counter by ((|step|)) and update
55
- the display of the progress bar. Display the estimated
56
- remaining time on the right side of the bar. The counter
57
- does not go beyond the ((|total|)).
58
-
59
- --- ProgressBar#set (count)
60
- Set the internal counter to ((|count|)) and update the
61
- display of the progress bar. Display the estimated
62
- remaining time on the right side of the bar. Raise if
63
- ((|count|)) is a negative number or a number more than
64
- the ((|total|)).
65
-
66
- --- ProgressBar#finish
67
- Stop the progress bar and update the display of progress
68
- bar. Display the elapsed time on the right side of the bar.
69
- The progress bar always stops at 100 % by the method.
70
-
71
- --- ProgressBar#halt
72
- Stop the progress bar and update the display of progress
73
- bar. Display the elapsed time on the right side of the bar.
74
- The progress bar stops at the current percentage by the method.
75
-
76
- --- ProgressBar#format=
77
- Set the format for displaying a progress bar.
78
- Default: "%-14s %3d%% %s %s".
79
-
80
- --- ProgressBar#format_arguments=
81
- Set the methods for displaying a progress bar.
82
- Default: [:title, :percentage, :bar, :stat].
83
-
84
- --- ProgressBar#file_transfer_mode
85
- Use :stat_for_file_transfer instead of :stat to display
86
- transfered bytes and transfer rate.
87
-
88
- --- ProgressBar#long_running
89
- Use adaptative running average to compute ETA, more effective for
90
- long-running jobs or jobs whose speed may vary.
91
-
92
-
93
- ReverseProgressBar class is also available. The
94
- functionality is identical to ProgressBar but the direction
95
- of the progress bar is just opposite.
96
-
97
- == Limitations
98
-
99
- Since the progress is calculated by the proportion to the
100
- total cost of processing, Ruby/ProgressBar cannot be used if
101
- the total cost of processing is unknown in advance.
102
- Moreover, the estimation of remaining time cannot be
103
- accurately performed if the progress does not flow uniformly.
104
-
105
- == Download
106
-
107
- Ruby/ProgressBar is a free software with ABSOLUTELY NO WARRANTY
108
- under the terms of Ruby's license.
109
-
110
- * ((<URL:http://namazu.org/~satoru/ruby-progressbar/ruby-progressbar-0.9.tar.gz>))
111
- * ((<URL:http://cvs.namazu.org/ruby-progressbar/>))
112
-
113
- --
114
-
115
- - ((<Satoru Takabayashi|URL:http://namazu.org/~satoru/>)) -
116
- =end
data/progressbar.gemspec DELETED
@@ -1,29 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path("../lib/progressbar", __FILE__)
3
-
4
- Gem::Specification.new do |s|
5
- s.name = "progressbar"
6
- s.version = ProgressBar::VERSION
7
- s.platform = Gem::Platform::RUBY
8
- s.authors = ["Satoru Takabayashi", "Jose Peleteiro"]
9
- s.email = ["satoru@0xcc.net", "jose@peleteiro.net"]
10
- s.homepage = "http://github.com/peleteiro/progressbar"
11
- s.summary = "Ruby/ProgressBar is a text progress bar library for Ruby."
12
- s.description = "Ruby/ProgressBar is a text progress bar library for Ruby. It can indicate progress with percentage, a progress bar, and estimated remaining time."
13
- s.license = "Ruby"
14
-
15
- s.required_rubygems_version = ">= 1.3.6"
16
-
17
- s.add_development_dependency "bundler", ">= 1.0.0"
18
- s.add_development_dependency "minitest", ">= 0"
19
- s.add_development_dependency "yard", ">= 0"
20
- s.add_development_dependency "rake", ">= 0"
21
- s.add_development_dependency "simplecov", ">= 0.3.5"
22
- s.add_development_dependency "bluecloth", ">= 0.3.5"
23
-
24
- s.files = `git ls-files`.split("\n")
25
- s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
26
- s.require_path = 'lib'
27
-
28
- s.rdoc_options = ["--charset=UTF-8"]
29
- end
data/test/test.rb DELETED
@@ -1,125 +0,0 @@
1
- require 'test/unit'
2
- require 'progressbar'
3
-
4
- class ProgressBarTest < Test::Unit::TestCase
5
- SleepUnit = 0.01
6
-
7
- def do_make_progress_bar(title, total, &block)
8
- ProgressBar.new(title, total, &block)
9
- end
10
-
11
- def test_bytes
12
- total = 1024 * 1024
13
- pbar = do_make_progress_bar("test(bytes)", total)
14
- pbar.file_transfer_mode
15
- 0.step(total, 2**14) {|x|
16
- pbar.set(x)
17
- sleep(SleepUnit)
18
- }
19
- pbar.finish
20
- end
21
-
22
- def test_clear
23
- total = 100
24
- pbar = do_make_progress_bar("test(clear)", total)
25
- total.times {
26
- sleep(SleepUnit)
27
- pbar.inc
28
- }
29
- pbar.clear
30
- puts
31
- end
32
-
33
- def test_halt
34
- total = 100
35
- pbar = do_make_progress_bar("test(halt)", total)
36
- (total / 2).times {
37
- sleep(SleepUnit)
38
- pbar.inc
39
- }
40
- pbar.halt
41
- end
42
-
43
- def test_inc
44
- total = 100
45
- pbar = do_make_progress_bar("test(inc)", total)
46
- total.times {
47
- sleep(SleepUnit)
48
- pbar.inc
49
- }
50
- pbar.finish
51
- end
52
-
53
- def test_inc_x
54
- total = File.size("lib/progressbar.rb")
55
- pbar = do_make_progress_bar("test(inc(x))", total)
56
- File.new("lib/progressbar.rb").each {|line|
57
- sleep(SleepUnit)
58
- pbar.inc(line.length)
59
- }
60
- pbar.finish
61
- end
62
-
63
- def test_invalid_set
64
- total = 100
65
- pbar = do_make_progress_bar("test(invalid set)", total)
66
- begin
67
- pbar.set(200)
68
- rescue RuntimeError => e
69
- puts e.message
70
- end
71
- end
72
-
73
- def test_set
74
- total = 1000
75
- pbar = do_make_progress_bar("test(set)", total)
76
- (1..total).find_all {|x| x % 10 == 0}.each {|x|
77
- sleep(SleepUnit)
78
- pbar.set(x)
79
- }
80
- pbar.finish
81
- end
82
-
83
- def test_slow
84
- total = 100000
85
- pbar = do_make_progress_bar("test(slow)", total)
86
- 0.step(500, 1) {|x|
87
- pbar.set(x)
88
- sleep(SleepUnit)
89
- }
90
- pbar.halt
91
- end
92
-
93
- def test_total_zero
94
- total = 0
95
- pbar = do_make_progress_bar("test(total=0)", total)
96
- pbar.finish
97
- end
98
-
99
- def test_custom_bar_mark
100
- total = 100
101
- pbar = do_make_progress_bar("test(custom)", total)
102
- pbar.bar_mark = '='
103
- total.times {
104
- sleep(SleepUnit)
105
- pbar.inc
106
- }
107
- pbar.finish
108
- end
109
-
110
- def test_with_block
111
- total = 100
112
- do_make_progress_bar("test(block)", total) do |pbar|
113
- total.times {
114
- sleep(SleepUnit)
115
- pbar.inc
116
- }
117
- end
118
- end
119
- end
120
-
121
- class ReversedProgressBarTest < ProgressBarTest
122
- def do_make_progress_bar(title, total, &block)
123
- ReversedProgressBar.new(title, total, &block)
124
- end
125
- end