tty-progressbar 0.14.0 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +98 -21
  3. data/LICENSE.txt +1 -1
  4. data/README.md +511 -119
  5. data/lib/tty-progressbar.rb +2 -2
  6. data/lib/tty/progressbar.rb +216 -87
  7. data/lib/tty/progressbar/configuration.rb +124 -16
  8. data/lib/tty/progressbar/converter.rb +16 -19
  9. data/lib/tty/progressbar/formats.rb +120 -0
  10. data/lib/tty/progressbar/formatter.rb +33 -38
  11. data/lib/tty/progressbar/formatter/bar.rb +87 -29
  12. data/lib/tty/progressbar/formatter/byte_rate.rb +6 -20
  13. data/lib/tty/progressbar/formatter/current.rb +4 -19
  14. data/lib/tty/progressbar/formatter/current_byte.rb +9 -17
  15. data/lib/tty/progressbar/formatter/elapsed.rb +9 -18
  16. data/lib/tty/progressbar/formatter/estimated.rb +14 -18
  17. data/lib/tty/progressbar/formatter/estimated_time.rb +37 -0
  18. data/lib/tty/progressbar/formatter/mean_byte.rb +6 -20
  19. data/lib/tty/progressbar/formatter/mean_rate.rb +6 -20
  20. data/lib/tty/progressbar/formatter/percent.rb +10 -16
  21. data/lib/tty/progressbar/formatter/rate.rb +5 -19
  22. data/lib/tty/progressbar/formatter/total.rb +10 -16
  23. data/lib/tty/progressbar/formatter/total_byte.rb +14 -18
  24. data/lib/tty/progressbar/formatters.rb +53 -0
  25. data/lib/tty/progressbar/meter.rb +2 -2
  26. data/lib/tty/progressbar/multi.rb +69 -23
  27. data/lib/tty/progressbar/pipeline.rb +13 -6
  28. data/lib/tty/progressbar/timer.rb +89 -0
  29. data/lib/tty/progressbar/version.rb +3 -1
  30. metadata +65 -151
  31. data/.codeclimate.yml +0 -11
  32. data/.gitignore +0 -14
  33. data/.rspec +0 -3
  34. data/.travis.yml +0 -25
  35. data/CODE_OF_CONDUCT.md +0 -74
  36. data/Gemfile +0 -14
  37. data/Rakefile +0 -8
  38. data/appveyor.yml +0 -21
  39. data/examples/color.rb +0 -18
  40. data/examples/failure.rb +0 -12
  41. data/examples/iterator.rb +0 -5
  42. data/examples/lazy.rb +0 -6
  43. data/examples/multi/main_bar.rb +0 -13
  44. data/examples/multi/simple.rb +0 -13
  45. data/examples/simple.rb +0 -7
  46. data/examples/slow_process.rb +0 -29
  47. data/examples/speed.rb +0 -11
  48. data/examples/threaded.rb +0 -14
  49. data/examples/tokens.rb +0 -12
  50. data/spec/spec_helper.rb +0 -50
  51. data/spec/unit/advance_spec.rb +0 -25
  52. data/spec/unit/clear_spec.rb +0 -17
  53. data/spec/unit/complete_spec.rb +0 -16
  54. data/spec/unit/converter/to_bytes_spec.rb +0 -47
  55. data/spec/unit/converter/to_seconds_spec.rb +0 -15
  56. data/spec/unit/converter/to_time_spec.rb +0 -19
  57. data/spec/unit/custom_formatter_spec.rb +0 -26
  58. data/spec/unit/custom_token_spec.rb +0 -14
  59. data/spec/unit/events_spec.rb +0 -33
  60. data/spec/unit/finish_spec.rb +0 -15
  61. data/spec/unit/formatter/bar_spec.rb +0 -16
  62. data/spec/unit/formatter/byte_rate_spec.rb +0 -32
  63. data/spec/unit/formatter/current_byte_spec.rb +0 -16
  64. data/spec/unit/formatter/current_spec.rb +0 -14
  65. data/spec/unit/formatter/elapsed_spec.rb +0 -58
  66. data/spec/unit/formatter/estimated_spec.rb +0 -27
  67. data/spec/unit/formatter/mean_byte_spec.rb +0 -32
  68. data/spec/unit/formatter/mean_rate_spec.rb +0 -31
  69. data/spec/unit/formatter/percent_spec.rb +0 -16
  70. data/spec/unit/formatter/rate_spec.rb +0 -31
  71. data/spec/unit/formatter/total_byte_spec.rb +0 -16
  72. data/spec/unit/formatter/total_spec.rb +0 -16
  73. data/spec/unit/frequency_spec.rb +0 -27
  74. data/spec/unit/head_spec.rb +0 -32
  75. data/spec/unit/hide_cursor_spec.rb +0 -27
  76. data/spec/unit/inspect_spec.rb +0 -11
  77. data/spec/unit/iterate_spec.rb +0 -79
  78. data/spec/unit/log_spec.rb +0 -29
  79. data/spec/unit/meter_spec.rb +0 -70
  80. data/spec/unit/multi/advance_spec.rb +0 -123
  81. data/spec/unit/multi/events_spec.rb +0 -115
  82. data/spec/unit/multi/finish_spec.rb +0 -41
  83. data/spec/unit/multi/line_inset_spec.rb +0 -65
  84. data/spec/unit/multi/register_spec.rb +0 -35
  85. data/spec/unit/multi/stop_spec.rb +0 -15
  86. data/spec/unit/new_spec.rb +0 -66
  87. data/spec/unit/pipeline_spec.rb +0 -19
  88. data/spec/unit/ratio_spec.rb +0 -31
  89. data/spec/unit/reset_spec.rb +0 -31
  90. data/spec/unit/resize_spec.rb +0 -35
  91. data/spec/unit/set_current_spec.rb +0 -43
  92. data/spec/unit/start_spec.rb +0 -14
  93. data/spec/unit/stop_spec.rb +0 -19
  94. data/spec/unit/update_spec.rb +0 -22
  95. data/spec/unit/width_spec.rb +0 -21
  96. data/tasks/console.rake +0 -9
  97. data/tasks/coverage.rake +0 -9
  98. data/tasks/spec.rake +0 -27
  99. data/tty-progressbar.gemspec +0 -30
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TTY
4
+ class ProgressBar
5
+ # Used to measure the elapsed time for multiple time intervals
6
+ #
7
+ # @api private
8
+ class Timer
9
+ attr_reader :start_time
10
+
11
+ # Create Timer
12
+ #
13
+ # @api private
14
+ def initialize
15
+ reset
16
+ end
17
+
18
+ # Reset the start time to nil and elapsed time to zero
19
+ #
20
+ # @api public
21
+ def reset
22
+ @running = false
23
+ @offset = 0
24
+ @start_time = nil
25
+ end
26
+
27
+ # Check whether or not the timer is running
28
+ #
29
+ # @return [Boolean]
30
+ #
31
+ # @api public
32
+ def running?
33
+ @running
34
+ end
35
+
36
+ # Total elapsed time
37
+ #
38
+ # @return [Float]
39
+ # the elapsed time in seconds
40
+ #
41
+ # @api public
42
+ def elapsed_time
43
+ if running?
44
+ elapsed_until_now + @offset
45
+ else
46
+ @offset
47
+ end
48
+ end
49
+
50
+ # Measure current time interval
51
+ #
52
+ # @api public
53
+ def elapsed_until_now
54
+ time_so_far = Time.now - @start_time
55
+ # protect against negative time drifting
56
+ time_so_far > 0 ? time_so_far : 0
57
+ end
58
+
59
+ # Start measuring elapsed time for a new interval
60
+ #
61
+ # @return [Time]
62
+ # return the start time
63
+ #
64
+ # @api public
65
+ def start
66
+ return @start_time if running?
67
+
68
+ @running = true
69
+ @start_time = Time.now
70
+ end
71
+
72
+ # Stop measuring elapsed time for the current interval
73
+ #
74
+ # @return [Float]
75
+ # return elapsed time for the stopped interval
76
+ #
77
+ # @api public
78
+ def stop
79
+ return 0 unless running?
80
+
81
+ interval = elapsed_until_now
82
+ @offset += interval
83
+ @running = false
84
+ @start_time = nil
85
+ interval
86
+ end
87
+ end # Timer
88
+ end # ProgressBar
89
+ end # TTY
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TTY
2
4
  class ProgressBar
3
- VERSION = '0.14.0'.freeze
5
+ VERSION = "0.18.0"
4
6
  end # ProgressBar
5
7
  end # TTY
metadata CHANGED
@@ -1,138 +1,140 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tty-progressbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Murach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-17 00:00:00.000000000 Z
11
+ date: 2021-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: strings-ansi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.2'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: tty-cursor
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: 0.5.0
33
+ version: '0.7'
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: 0.5.0
40
+ version: '0.7'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: tty-screen
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: 0.6.4
47
+ version: '0.8'
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: 0.6.4
54
+ version: '0.8'
41
55
  - !ruby/object:Gem::Dependency
42
- name: bundler
56
+ name: unicode-display_width
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
46
60
  - !ruby/object:Gem::Version
47
- version: 1.5.0
61
+ version: '1.6'
48
62
  - - "<"
49
63
  - !ruby/object:Gem::Version
50
- version: '2.0'
51
- type: :development
64
+ version: '3.0'
65
+ type: :runtime
52
66
  prerelease: false
53
67
  version_requirements: !ruby/object:Gem::Requirement
54
68
  requirements:
55
69
  - - ">="
56
70
  - !ruby/object:Gem::Version
57
- version: 1.5.0
71
+ version: '1.6'
58
72
  - - "<"
59
73
  - !ruby/object:Gem::Version
60
- version: '2.0'
74
+ version: '3.0'
61
75
  - !ruby/object:Gem::Dependency
62
- name: rspec
76
+ name: rake
63
77
  requirement: !ruby/object:Gem::Requirement
64
78
  requirements:
65
- - - "~>"
79
+ - - ">="
66
80
  - !ruby/object:Gem::Version
67
- version: '3.1'
81
+ version: '0'
68
82
  type: :development
69
83
  prerelease: false
70
84
  version_requirements: !ruby/object:Gem::Requirement
71
85
  requirements:
72
- - - "~>"
86
+ - - ">="
73
87
  - !ruby/object:Gem::Version
74
- version: '3.1'
88
+ version: '0'
75
89
  - !ruby/object:Gem::Dependency
76
- name: timecop
90
+ name: rspec
77
91
  requirement: !ruby/object:Gem::Requirement
78
92
  requirements:
79
- - - "~>"
93
+ - - ">="
80
94
  - !ruby/object:Gem::Version
81
- version: 0.9.1
95
+ version: '3.0'
82
96
  type: :development
83
97
  prerelease: false
84
98
  version_requirements: !ruby/object:Gem::Requirement
85
99
  requirements:
86
- - - "~>"
100
+ - - ">="
87
101
  - !ruby/object:Gem::Version
88
- version: 0.9.1
102
+ version: '3.0'
89
103
  - !ruby/object:Gem::Dependency
90
- name: rake
104
+ name: timecop
91
105
  requirement: !ruby/object:Gem::Requirement
92
106
  requirements:
93
- - - ">="
107
+ - - "~>"
94
108
  - !ruby/object:Gem::Version
95
- version: '0'
109
+ version: '0.9'
96
110
  type: :development
97
111
  prerelease: false
98
112
  version_requirements: !ruby/object:Gem::Requirement
99
113
  requirements:
100
- - - ">="
114
+ - - "~>"
101
115
  - !ruby/object:Gem::Version
102
- version: '0'
103
- description: A flexible progress bars drawing in terminal emulators.
116
+ version: '0.9'
117
+ description: Display a single or multiple progress bars in the terminal. A progress
118
+ bar can show determinate or indeterminate progress that can be paused and resumed
119
+ at any time. A bar format supports many tokens for common information display like
120
+ elapsed time, estimated time to completion, mean rate and more.
104
121
  email:
105
- - ''
122
+ - piotr@piotrmurach.com
106
123
  executables: []
107
124
  extensions: []
108
- extra_rdoc_files: []
125
+ extra_rdoc_files:
126
+ - README.md
127
+ - CHANGELOG.md
128
+ - LICENSE.txt
109
129
  files:
110
- - ".codeclimate.yml"
111
- - ".gitignore"
112
- - ".rspec"
113
- - ".travis.yml"
114
130
  - CHANGELOG.md
115
- - CODE_OF_CONDUCT.md
116
- - Gemfile
117
131
  - LICENSE.txt
118
132
  - README.md
119
- - Rakefile
120
- - appveyor.yml
121
- - examples/color.rb
122
- - examples/failure.rb
123
- - examples/iterator.rb
124
- - examples/lazy.rb
125
- - examples/multi/main_bar.rb
126
- - examples/multi/simple.rb
127
- - examples/simple.rb
128
- - examples/slow_process.rb
129
- - examples/speed.rb
130
- - examples/threaded.rb
131
- - examples/tokens.rb
132
133
  - lib/tty-progressbar.rb
133
134
  - lib/tty/progressbar.rb
134
135
  - lib/tty/progressbar/configuration.rb
135
136
  - lib/tty/progressbar/converter.rb
137
+ - lib/tty/progressbar/formats.rb
136
138
  - lib/tty/progressbar/formatter.rb
137
139
  - lib/tty/progressbar/formatter/bar.rb
138
140
  - lib/tty/progressbar/formatter/byte_rate.rb
@@ -140,70 +142,29 @@ files:
140
142
  - lib/tty/progressbar/formatter/current_byte.rb
141
143
  - lib/tty/progressbar/formatter/elapsed.rb
142
144
  - lib/tty/progressbar/formatter/estimated.rb
145
+ - lib/tty/progressbar/formatter/estimated_time.rb
143
146
  - lib/tty/progressbar/formatter/mean_byte.rb
144
147
  - lib/tty/progressbar/formatter/mean_rate.rb
145
148
  - lib/tty/progressbar/formatter/percent.rb
146
149
  - lib/tty/progressbar/formatter/rate.rb
147
150
  - lib/tty/progressbar/formatter/total.rb
148
151
  - lib/tty/progressbar/formatter/total_byte.rb
152
+ - lib/tty/progressbar/formatters.rb
149
153
  - lib/tty/progressbar/meter.rb
150
154
  - lib/tty/progressbar/multi.rb
151
155
  - lib/tty/progressbar/pipeline.rb
156
+ - lib/tty/progressbar/timer.rb
152
157
  - lib/tty/progressbar/version.rb
153
- - spec/spec_helper.rb
154
- - spec/unit/advance_spec.rb
155
- - spec/unit/clear_spec.rb
156
- - spec/unit/complete_spec.rb
157
- - spec/unit/converter/to_bytes_spec.rb
158
- - spec/unit/converter/to_seconds_spec.rb
159
- - spec/unit/converter/to_time_spec.rb
160
- - spec/unit/custom_formatter_spec.rb
161
- - spec/unit/custom_token_spec.rb
162
- - spec/unit/events_spec.rb
163
- - spec/unit/finish_spec.rb
164
- - spec/unit/formatter/bar_spec.rb
165
- - spec/unit/formatter/byte_rate_spec.rb
166
- - spec/unit/formatter/current_byte_spec.rb
167
- - spec/unit/formatter/current_spec.rb
168
- - spec/unit/formatter/elapsed_spec.rb
169
- - spec/unit/formatter/estimated_spec.rb
170
- - spec/unit/formatter/mean_byte_spec.rb
171
- - spec/unit/formatter/mean_rate_spec.rb
172
- - spec/unit/formatter/percent_spec.rb
173
- - spec/unit/formatter/rate_spec.rb
174
- - spec/unit/formatter/total_byte_spec.rb
175
- - spec/unit/formatter/total_spec.rb
176
- - spec/unit/frequency_spec.rb
177
- - spec/unit/head_spec.rb
178
- - spec/unit/hide_cursor_spec.rb
179
- - spec/unit/inspect_spec.rb
180
- - spec/unit/iterate_spec.rb
181
- - spec/unit/log_spec.rb
182
- - spec/unit/meter_spec.rb
183
- - spec/unit/multi/advance_spec.rb
184
- - spec/unit/multi/events_spec.rb
185
- - spec/unit/multi/finish_spec.rb
186
- - spec/unit/multi/line_inset_spec.rb
187
- - spec/unit/multi/register_spec.rb
188
- - spec/unit/multi/stop_spec.rb
189
- - spec/unit/new_spec.rb
190
- - spec/unit/pipeline_spec.rb
191
- - spec/unit/ratio_spec.rb
192
- - spec/unit/reset_spec.rb
193
- - spec/unit/resize_spec.rb
194
- - spec/unit/set_current_spec.rb
195
- - spec/unit/start_spec.rb
196
- - spec/unit/stop_spec.rb
197
- - spec/unit/update_spec.rb
198
- - spec/unit/width_spec.rb
199
- - tasks/console.rake
200
- - tasks/coverage.rake
201
- - tasks/spec.rake
202
- - tty-progressbar.gemspec
203
- homepage: https://piotrmurach.github.io/tty/
158
+ homepage: https://ttytoolkit.org
204
159
  licenses:
205
160
  - MIT
206
- metadata: {}
161
+ metadata:
162
+ allowed_push_host: https://rubygems.org
163
+ bug_tracker_uri: https://github.com/piotrmurach/tty-progressbar/issues
164
+ changelog_uri: https://github.com/piotrmurach/tty-progressbar/blob/master/CHANGELOG.md
165
+ documentation_uri: https://www.rubydoc.info/gems/tty-progressbar
166
+ homepage_uri: https://ttytoolkit.org
167
+ source_code_uri: https://github.com/piotrmurach/tty-progressbar
207
168
  post_install_message:
208
169
  rdoc_options: []
209
170
  require_paths:
@@ -219,55 +180,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
180
  - !ruby/object:Gem::Version
220
181
  version: '0'
221
182
  requirements: []
222
- rubyforge_project:
223
- rubygems_version: 2.5.1
183
+ rubygems_version: 3.1.2
224
184
  signing_key:
225
185
  specification_version: 4
226
- summary: A flexible progress bars drawing in terminal emulators.
227
- test_files:
228
- - spec/spec_helper.rb
229
- - spec/unit/advance_spec.rb
230
- - spec/unit/clear_spec.rb
231
- - spec/unit/complete_spec.rb
232
- - spec/unit/converter/to_bytes_spec.rb
233
- - spec/unit/converter/to_seconds_spec.rb
234
- - spec/unit/converter/to_time_spec.rb
235
- - spec/unit/custom_formatter_spec.rb
236
- - spec/unit/custom_token_spec.rb
237
- - spec/unit/events_spec.rb
238
- - spec/unit/finish_spec.rb
239
- - spec/unit/formatter/bar_spec.rb
240
- - spec/unit/formatter/byte_rate_spec.rb
241
- - spec/unit/formatter/current_byte_spec.rb
242
- - spec/unit/formatter/current_spec.rb
243
- - spec/unit/formatter/elapsed_spec.rb
244
- - spec/unit/formatter/estimated_spec.rb
245
- - spec/unit/formatter/mean_byte_spec.rb
246
- - spec/unit/formatter/mean_rate_spec.rb
247
- - spec/unit/formatter/percent_spec.rb
248
- - spec/unit/formatter/rate_spec.rb
249
- - spec/unit/formatter/total_byte_spec.rb
250
- - spec/unit/formatter/total_spec.rb
251
- - spec/unit/frequency_spec.rb
252
- - spec/unit/head_spec.rb
253
- - spec/unit/hide_cursor_spec.rb
254
- - spec/unit/inspect_spec.rb
255
- - spec/unit/iterate_spec.rb
256
- - spec/unit/log_spec.rb
257
- - spec/unit/meter_spec.rb
258
- - spec/unit/multi/advance_spec.rb
259
- - spec/unit/multi/events_spec.rb
260
- - spec/unit/multi/finish_spec.rb
261
- - spec/unit/multi/line_inset_spec.rb
262
- - spec/unit/multi/register_spec.rb
263
- - spec/unit/multi/stop_spec.rb
264
- - spec/unit/new_spec.rb
265
- - spec/unit/pipeline_spec.rb
266
- - spec/unit/ratio_spec.rb
267
- - spec/unit/reset_spec.rb
268
- - spec/unit/resize_spec.rb
269
- - spec/unit/set_current_spec.rb
270
- - spec/unit/start_spec.rb
271
- - spec/unit/stop_spec.rb
272
- - spec/unit/update_spec.rb
273
- - spec/unit/width_spec.rb
186
+ summary: A flexible and extensible progress bar for terminal applications.
187
+ test_files: []
@@ -1,11 +0,0 @@
1
- ---
2
- engines:
3
- fixme:
4
- enabled: true
5
- ratings:
6
- paths:
7
- - lib/**/*.rb
8
- exclude_paths:
9
- - spec/**/*
10
- - examples/**/*
11
- - tasks/**/*
data/.gitignore DELETED
@@ -1,14 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- *.bundle
11
- *.so
12
- *.o
13
- *.a
14
- mkmf.log