ruby-progressbar 1.10.0 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 42ee7acdeadf208ea04bd6a634dbc999b264fe0914f1ffd7782ecbac90e50858
4
- data.tar.gz: 0e7ece6126e208f2636f8e4841c6fd26ee1d935c16ff5d84075e65ac70371b98
3
+ metadata.gz: a326fec3040bac0fc963d989df67f252d45243a7983184b88f0ccdfda4d0f35c
4
+ data.tar.gz: 7aaaae56892722f0fc22a440f21f5f13e54f9171fb64b6630386d67ac0515f14
5
5
  SHA512:
6
- metadata.gz: 36159642c868a944be95a1e6466366516096f7f875437ce3c304418ead4e97349cd8acac7123c2dc9550d18999f1ea629cc34aa622ae5497cea5cfa7a5563ee2
7
- data.tar.gz: fc513c2a18cbd165cc1b69dc47c17d9c8f7844f14d86707c15fbc8ecea8c7ff51a9872d9b1bb61e4d505ce054a993c61dcdc7c260cb97a36edb53de49805496c
6
+ metadata.gz: 0f8d6034719ec5276dee6bb1f11bb14ad4696dcd8dbf6fa88b26eebf6e8e4f658ee2d686f406aa9c25a71b2f0d8ce8dcd22c4b58af5c8cd6cd42f39f88301916
7
+ data.tar.gz: 14978170664e0308259fad1e4dd9ea11adacf3f48a03c8faf532d3a0691aed7a9fd7a397f7dcc7bea389d0f2716b36e1a77a54c4560593012008ba6811dafb3b
checksums.yaml.gz.sig CHANGED
Binary file
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2016 The Kompanee, Ltd
1
+ Copyright (c) 2010-2019 The Kompanee, Ltd
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,38 +1,131 @@
1
1
  Ruby/ProgressBar
2
- ================================
3
- [![Gem Version](https://img.shields.io/gem/v/ruby-progressbar.svg)](https://rubygems.org/gems/ruby-progressbar) ![Rubygems Rank Overall](https://img.shields.io/gem/rt/ruby-progressbar.svg) ![Rubygems Rank Daily](https://img.shields.io/gem/rd/ruby-progressbar.svg) ![Rubygems Downloads](https://img.shields.io/gem/dv/ruby-progressbar/stable.svg) [![Build Status](https://img.shields.io/travis/jfelchner/ruby-progressbar/master.svg)](http://travis-ci.org/jfelchner/ruby-progressbar) [![Code Climate](https://codeclimate.com/github/jfelchner/ruby-progressbar.svg)](https://codeclimate.com/github/jfelchner/ruby-progressbar) [![Code Climate](https://codeclimate.com/github/jfelchner/ruby-progressbar/coverage.svg)](https://codeclimate.com/github/jfelchner/ruby-progressbar)
2
+ ================================================================================
3
+
4
+ <div align="center">
5
+ <a href="https://rubygems.org/gems/ruby-progressbar" alt="RubyGems Version">
6
+ <img src="https://img.shields.io/gem/v/ruby-progressbar.svg?style=flat-square&label=current-version" alt="RubyGems Version" />
7
+ </a>
8
+
9
+ <a href="https://rubygems.org/gems/ruby-progressbar" alt="RubyGems Rank Overall">
10
+ <img src="https://img.shields.io/gem/rt/ruby-progressbar.svg?style=flat-square&label=total-rank" alt="RubyGems Rank Overall" />
11
+ </a>
12
+
13
+ <a href="https://rubygems.org/gems/ruby-progressbar" alt="RubyGems Rank Daily">
14
+ <img src="https://img.shields.io/gem/rd/ruby-progressbar.svg?style=flat-square&label=daily-rank" alt="RubyGems Rank Daily" />
15
+ </a>
16
+
17
+ <a href="https://rubygems.org/gems/ruby-progressbar" alt="RubyGems Downloads">
18
+ <img src="https://img.shields.io/gem/dt/ruby-progressbar.svg?style=flat-square&label=total-downloads" alt="RubyGems Downloads" />
19
+ </a>
20
+
21
+ <a href="https://github.com/jfelchner/ruby-progressbar/actions?query=workflow%3ABuild" alt="Build Status">
22
+ <img src="https://img.shields.io/github/workflow/status/jfelchner/ruby-progressbar/Build?label=CI&style=flat-square&logo=github" alt="Build Status" />
23
+ </a>
24
+
25
+ <a href="#" alt="Maintainability">
26
+ <img src="https://img.shields.io/codeclimate/maintainability/jfelchner/ruby-progressbar?style=flat-square&label=grade" alt="Maintainability" />
27
+ </a>
28
+ </div>
29
+
30
+ <br>
4
31
 
5
32
  <img src="https://kompanee-public-assets.s3.amazonaws.com/readmes/ruby-progressbar-cage.png" align="right" />
6
33
 
7
- The **ultimate** text progress bar library for Ruby! It'll **SMASH YOU OVER THE HEAD** with a **PURE RUSH** of progress bar excitement!
34
+ The **ultimate** text progress bar library for Ruby! It'll **SMASH YOU OVER THE
35
+ HEAD** with a **PURE RUSH** of progress bar excitement!
8
36
 
9
- Don't miss out on what all the kids are talking about! If you want everyone to know that your gem or app can survive _in the cage_ then YOU WANT **RUBY-PROGRESSBAR**!
37
+ Don't miss out on what all the kids are talking about! If you want everyone to
38
+ know that your gem or app can survive _in the cage_ then YOU WANT
39
+ **RUBY-PROGRESSBAR**!
10
40
 
11
- <br><br><br>
41
+ <br>
12
42
 
13
- Full Reference
14
- --------------------------------
43
+ It's Better Than The Other 186,312 Progress Bar Libraries Because
44
+ --------------------------------------------------------------------------------
45
+
46
+ * It has [stood the test of time][history] (2008-today)
47
+
48
+ * Full test suite
49
+
50
+ * [_**ZERO**_ dependencies][gemspec]
51
+
52
+ * Used by [tons of other open source projects][dependencies] (which means we
53
+ find out about bugs quickly)
54
+
55
+ * It's pretty [freakin' sweet](https://www.youtube.com/watch?v=On3IoVhf_GM)
56
+
57
+ * And most importantly... our awesome [contributors][contributors]
58
+
59
+ Basic Usage
60
+ --------------------------------------------------------------------------------
15
61
 
16
- There's gotten to be too much awesome to pack into one page. Visit the [wiki](https://github.com/jfelchner/ruby-progressbar/wiki) for the full documentation.
62
+ ### Creation
17
63
 
18
- Here's a [quick link](https://github.com/jfelchner/ruby-progressbar/wiki/Basic-Usage) to the 'Basic Usage' section.
64
+ It's simple to get started:
65
+
66
+ ```ruby
67
+ progressbar = ProgressBar.create
68
+ ```
69
+
70
+ Creates a basic progress bar beginning at `0`, a maximum capacity of `100` and
71
+ tells it to start.
72
+
73
+ ```text
74
+ Progress: | |
75
+ ```
76
+
77
+ ### Marking Progress
78
+
79
+ Every call to `#increment` will advance the bar by `1`. Therefore:
80
+
81
+ ```ruby
82
+ 50.times { progressbar.increment }
83
+ ```
84
+
85
+ Would output an advancing line which would end up here:
86
+
87
+ ```text
88
+ Progress: |=================================== |
89
+ ```
90
+
91
+ ### Animation
92
+
93
+ ![Basic Usage Marking Progress](http://kompanee-public-assets.s3.amazonaws.com/readmes/ruby-progressbar-basic-usage-marking-progress-2.gif)
94
+
95
+ Full Reference
96
+ --------------------------------------------------------------------------------
97
+
98
+ There's gotten to be too much awesome to pack into one page. Visit the
99
+ [wiki][wiki] for the full documentation.
19
100
 
20
101
  Issues
21
- --------------------------------
102
+ --------------------------------------------------------------------------------
22
103
 
23
- If you have problems, please create a [Github issue](https://github.com/jfelchner/ruby-progressbar/issues).
104
+ If you have problems, please create a [Github issue][issues].
24
105
 
25
106
  Credits
26
- --------------------------------
107
+ --------------------------------------------------------------------------------
27
108
 
28
- ![The Kompanee](https://kompanee-public-assets.s3.amazonaws.com/readmes/kompanee-horizontal-black.png)
109
+ ![The Kompanee][kompanee-logo]
29
110
 
30
- ruby-progressbar is maintained by [The Kompanee, Ltd.](http://www.thekompanee.com)
111
+ ruby-progressbar is maintained by [The Kompanee, Ltd.][kompanee-site]
31
112
 
32
113
  The names and logos for The Kompanee are trademarks of The Kompanee, Ltd.
33
114
 
34
115
  License
35
- --------------------------------
116
+ --------------------------------------------------------------------------------
117
+
118
+ ruby-progressbar 1.0 is Copyright &copy; 2011-2021 The Kompanee. It is free
119
+ software, and may be redistributed under the terms specified in the LICENSE
120
+ file.
121
+ ruby-progressbar 0.9.0 is Copyright &copy; 2008 [Satoru Takabayashi][satoru]
36
122
 
37
- ruby-progressbar 1.0 is Copyright &copy; 2011-2018 The Kompanee. It is free software, and may be redistributed under the terms specified in the LICENSE file.
38
- ruby-progressbar 0.9.0 is Copyright &copy; 2008 [Satoru Takabayashi](http://0xcc.net)
123
+ [contributors]: https://github.com/jfelchner/ruby-progressbar/graphs/contributors
124
+ [dependencies]: https://github.com/jfelchner/ruby-progressbar/network/dependents
125
+ [gemspec]: https://github.com/jfelchner/ruby-progressbar/blob/master/ruby-progressbar.gemspec
126
+ [history]: https://github.com/jfelchner/ruby-progressbar/wiki/History
127
+ [issues]: https://github.com/jfelchner/ruby-progressbar/issues
128
+ [kompanee-logo]: https://kompanee-public-assets.s3.amazonaws.com/readmes/kompanee-horizontal-black.png
129
+ [kompanee-site]: http://www.thekompanee.com
130
+ [satoru]: http://0xcc.net
131
+ [wiki]: https://github.com/jfelchner/ruby-progressbar/wiki
@@ -1,9 +1,38 @@
1
1
  require 'forwardable'
2
2
 
3
+ require 'ruby-progressbar/components/bar'
4
+ require 'ruby-progressbar/components/percentage'
5
+ require 'ruby-progressbar/components/rate'
6
+ require 'ruby-progressbar/components/time'
7
+ require 'ruby-progressbar/components/title'
8
+ require 'ruby-progressbar/format/formatter'
9
+ require 'ruby-progressbar/format/string'
10
+ require 'ruby-progressbar/outputs/non_tty'
11
+ require 'ruby-progressbar/outputs/tty'
12
+ require 'ruby-progressbar/progress'
13
+ require 'ruby-progressbar/projector'
14
+ require 'ruby-progressbar/timer'
15
+
3
16
  class ProgressBar
4
17
  class Base
5
18
  extend Forwardable
6
19
 
20
+ # rubocop:disable Layout/HeredocIndentation
21
+ SMOOTHING_DEPRECATION_WARNING = <<-HEREDOC.tr("\n", ' ')
22
+ WARNING: Passing the 'smoothing' option is deprecated and will be removed
23
+ in version 2.0. Please pass { projector: { type: 'smoothing', strength: 0.x }}.
24
+ For more information on why this change is happening, visit
25
+ https://github.com/jfelchner/ruby-progressbar/wiki/Upgrading
26
+ HEREDOC
27
+
28
+ RUNNING_AVERAGE_RATE_DEPRECATION_WARNING = <<-HEREDOC.tr("\n", ' ')
29
+ WARNING: Passing the 'running_average_rate' option is deprecated and will be removed
30
+ in version 2.0. Please pass { projector: { type: 'smoothing', strength: 0.x }}.
31
+ For more information on why this change is happening, visit
32
+ https://github.com/jfelchner/ruby-progressbar/wiki/Upgrading
33
+ HEREDOC
34
+ # rubocop:enable Layout/HeredocIndentation
35
+
7
36
  def_delegators :output,
8
37
  :clear,
9
38
  :log,
@@ -13,22 +42,41 @@ class Base
13
42
  :progress,
14
43
  :total
15
44
 
16
- def initialize(options = {})
45
+ def initialize(options = {}) # rubocop:disable Metrics/AbcSize
46
+ options[:projector] ||= {}
47
+
17
48
  self.autostart = options.fetch(:autostart, true)
18
49
  self.autofinish = options.fetch(:autofinish, true)
19
50
  self.finished = false
20
51
 
21
52
  self.timer = Timer.new(options)
53
+ projector_opts = if options[:projector].any?
54
+ options[:projector]
55
+ elsif options[:smoothing]
56
+ warn SMOOTHING_DEPRECATION_WARNING
57
+
58
+ { :strength => options[:smoothing] }
59
+ elsif options[:running_average_rate]
60
+ warn RUNNING_AVERAGE_RATE_DEPRECATION_WARNING
61
+
62
+ { :strength => options[:smoothing] }
63
+ else
64
+ {}
65
+ end
66
+ self.projector = Projector.
67
+ from_type(options[:projector][:type]).
68
+ new(projector_opts)
22
69
  self.progressable = Progress.new(options)
23
70
 
24
- options = options.merge(:timer => timer,
25
- :progress => progressable)
71
+ options = options.merge(:progress => progressable,
72
+ :projector => projector,
73
+ :timer => timer)
26
74
 
27
- self.title_comp = Components::Title.new(options)
28
- self.bar = Components::Bar.new(options)
29
- self.percentage = Components::Percentage.new(options)
30
- self.rate = Components::Rate.new(options)
31
- self.time = Components::Time.new(options)
75
+ self.title_component = Components::Title.new(options)
76
+ self.bar_component = Components::Bar.new(options)
77
+ self.percentage_component = Components::Percentage.new(options)
78
+ self.rate_component = Components::Rate.new(options)
79
+ self.time_component = Components::Time.new(options)
32
80
 
33
81
  self.output = Output.detect(options.merge(:bar => self))
34
82
  @format = Format::String.new(output.resolve_format(options[:format]))
@@ -67,6 +115,7 @@ class Base
67
115
  output.with_refresh do
68
116
  self.finished = false
69
117
  progressable.reset
118
+ projector.reset
70
119
  timer.reset
71
120
  end
72
121
  end
@@ -102,19 +151,19 @@ class Base
102
151
  end
103
152
 
104
153
  def progress_mark=(mark)
105
- output.refresh_with_format_change { bar.progress_mark = mark }
154
+ output.refresh_with_format_change { bar_component.progress_mark = mark }
106
155
  end
107
156
 
108
157
  def remainder_mark=(mark)
109
- output.refresh_with_format_change { bar.remainder_mark = mark }
158
+ output.refresh_with_format_change { bar_component.remainder_mark = mark }
110
159
  end
111
160
 
112
161
  def title
113
- title_comp.title
162
+ title_component.title
114
163
  end
115
164
 
116
165
  def title=(title)
117
- output.refresh_with_format_change { title_comp.title = title }
166
+ output.refresh_with_format_change { title_component.title = title }
118
167
  end
119
168
 
120
169
  def to_s(new_format = nil)
@@ -123,29 +172,29 @@ class Base
123
172
  Format::Formatter.process(@format, output.length, self)
124
173
  end
125
174
 
126
- # rubocop:disable Metrics/AbcSize, Metrics/LineLength
175
+ # rubocop:disable Metrics/AbcSize, Layout/LineLength
127
176
  def to_h
128
177
  {
129
178
  'output_stream' => output.__send__(:stream),
130
179
  'length' => output.length,
131
- 'title' => title_comp.title,
132
- 'progress_mark' => bar.progress_mark,
133
- 'remainder_mark' => bar.remainder_mark,
180
+ 'title' => title_component.title,
181
+ 'progress_mark' => bar_component.progress_mark,
182
+ 'remainder_mark' => bar_component.remainder_mark,
134
183
  'progress' => progressable.progress,
135
184
  'total' => progressable.total,
136
185
  'percentage' => progressable.percentage_completed_with_precision.to_f,
137
- 'elapsed_time_in_seconds' => time.__send__(:timer).elapsed_seconds,
138
- 'estimated_time_remaining_in_seconds' => time.__send__(:estimated_seconds_remaining),
139
- 'base_rate_of_change' => rate.__send__(:base_rate),
140
- 'scaled_rate_of_change' => rate.__send__(:scaled_rate),
141
- 'unknown_progress_animation_steps' => bar.upa_steps,
186
+ 'elapsed_time_in_seconds' => time_component.__send__(:timer).elapsed_seconds,
187
+ 'estimated_time_remaining_in_seconds' => time_component.__send__(:estimated_seconds_remaining),
188
+ 'base_rate_of_change' => rate_component.__send__(:base_rate),
189
+ 'scaled_rate_of_change' => rate_component.__send__(:scaled_rate),
190
+ 'unknown_progress_animation_steps' => bar_component.upa_steps,
142
191
  'throttle_rate' => output.__send__(:throttle).rate,
143
192
  'started?' => started?,
144
193
  'stopped?' => stopped?,
145
194
  'finished?' => finished?
146
195
  }
147
196
  end
148
- # rubocop:enable Metrics/AbcSize, Metrics/LineLength
197
+ # rubocop:enable Metrics/AbcSize, Layout/LineLength
149
198
 
150
199
  def inspect
151
200
  "#<ProgressBar:#{progress}/#{total || 'unknown'}>"
@@ -162,13 +211,14 @@ class Base
162
211
  protected
163
212
 
164
213
  attr_accessor :output,
214
+ :projector,
165
215
  :timer,
166
216
  :progressable,
167
- :title_comp,
168
- :bar,
169
- :percentage,
170
- :rate,
171
- :time,
217
+ :title_component,
218
+ :bar_component,
219
+ :percentage_component,
220
+ :rate_component,
221
+ :time_component,
172
222
  :autostart,
173
223
  :autofinish,
174
224
  :finished
@@ -176,6 +226,7 @@ class Base
176
226
  def update_progress(*args)
177
227
  output.with_refresh do
178
228
  progressable.__send__(*args)
229
+ projector.__send__(*args)
179
230
  timer.stop if finished?
180
231
  end
181
232
  end
@@ -50,12 +50,11 @@ class Length
50
50
  end
51
51
  # rubocop:enable Style/RescueStandardError
52
52
 
53
- # rubocop:disable Lint/DuplicateMethods
54
53
  begin
55
54
  require 'io/console'
56
55
 
57
56
  def dynamic_width
58
- if output && output.tty?
57
+ if output && output.tty? && output.respond_to?(:winsize)
59
58
  dynamic_width_via_output_stream_object
60
59
  elsif IO.console
61
60
  dynamic_width_via_io_object
@@ -68,7 +67,6 @@ class Length
68
67
  dynamic_width_via_system_calls
69
68
  end
70
69
  end
71
- # rubocop:enable Lint/DuplicateMethods
72
70
 
73
71
  def dynamic_width_via_output_stream_object
74
72
  _rows, columns = output.winsize
@@ -32,22 +32,6 @@ class Bar
32
32
  end
33
33
  end
34
34
 
35
- private
36
-
37
- def integrated_percentage_complete_string
38
- return standard_complete_string if completed_length < 5
39
-
40
- " #{progress.percentage_completed} ".to_s.center(completed_length, progress_mark)
41
- end
42
-
43
- def standard_complete_string
44
- progress_mark * completed_length
45
- end
46
-
47
- def incomplete_string
48
- remainder_mark * (length - completed_length)
49
- end
50
-
51
35
  def bar(length)
52
36
  self.length = length
53
37
 
@@ -66,12 +50,6 @@ class Bar
66
50
  to_s(:format => :integrated_percentage)
67
51
  end
68
52
 
69
- def unknown_string
70
- unknown_frame_string = unknown_progress_frame * ((length / upa_steps.size) + 2)
71
-
72
- unknown_frame_string[0, length]
73
- end
74
-
75
53
  def incomplete_space(length)
76
54
  self.length = length
77
55
 
@@ -88,6 +66,28 @@ class Bar
88
66
  integrated_percentage_complete_string
89
67
  end
90
68
 
69
+ private
70
+
71
+ def integrated_percentage_complete_string
72
+ return standard_complete_string if completed_length < 5
73
+
74
+ " #{progress.percentage_completed} ".to_s.center(completed_length, progress_mark)
75
+ end
76
+
77
+ def standard_complete_string
78
+ progress_mark * completed_length
79
+ end
80
+
81
+ def incomplete_string
82
+ remainder_mark * (length - completed_length)
83
+ end
84
+
85
+ def unknown_string
86
+ unknown_frame_string = unknown_progress_frame * ((length / upa_steps.size) + 2)
87
+
88
+ unknown_frame_string[0, length]
89
+ end
90
+
91
91
  def completed_length
92
92
  (length * progress.percentage_completed / 100).floor
93
93
  end
@@ -7,10 +7,8 @@ class Percentage
7
7
  self.progress = options[:progress]
8
8
  end
9
9
 
10
- private
11
-
12
10
  def percentage
13
- progress.percentage_completed
11
+ progress.percentage_completed.to_s
14
12
  end
15
13
 
16
14
  def justified_percentage
@@ -2,23 +2,17 @@ class ProgressBar
2
2
  module Components
3
3
  class Rate
4
4
  attr_accessor :rate_scale,
5
- :started_at,
6
- :stopped_at,
7
5
  :timer,
8
6
  :progress
9
7
 
10
8
  def initialize(options = {})
11
9
  self.rate_scale = options[:rate_scale] || lambda { |x| x }
12
- self.started_at = nil
13
- self.stopped_at = nil
14
10
  self.timer = options[:timer]
15
11
  self.progress = options[:progress]
16
12
  end
17
13
 
18
- private
19
-
20
14
  def rate_of_change(format_string = '%i')
21
- return 0 unless elapsed_seconds > 0
15
+ return '0' if elapsed_seconds <= 0
22
16
 
23
17
  format_string % scaled_rate
24
18
  end
@@ -27,6 +21,8 @@ class Rate
27
21
  rate_of_change('%.2f')
28
22
  end
29
23
 
24
+ private
25
+
30
26
  def scaled_rate
31
27
  rate_scale.call(base_rate)
32
28
  end
@@ -12,57 +12,58 @@ class Time
12
12
  NO_TIME_ELAPSED_TEXT = '--:--:--'.freeze
13
13
  ESTIMATED_LABEL = ' ETA'.freeze
14
14
  ELAPSED_LABEL = 'Time'.freeze
15
+ WALL_CLOCK_FORMAT = '%H:%M:%S'.freeze
16
+ OOB_TEXT_TO_FORMAT = {
17
+ :unknown => OOB_UNKNOWN_TIME_TEXT,
18
+ :friendly => OOB_FRIENDLY_TIME_TEXT
19
+ }.freeze
15
20
 
16
21
  def initialize(options = {})
17
- self.out_of_bounds_time_format = options[:out_of_bounds_time_format]
18
- self.timer = options[:timer]
19
- self.progress = options[:progress]
22
+ self.timer = options[:timer]
23
+ self.progress = options[:progress]
24
+ self.projector = options[:projector]
20
25
  end
21
26
 
22
- def estimated_with_label
23
- "#{ESTIMATED_LABEL}: #{estimated}"
27
+ def estimated_with_label(out_of_bounds_time_format = nil)
28
+ "#{ESTIMATED_LABEL}: #{estimated(out_of_bounds_time_format)}"
24
29
  end
25
30
 
26
31
  def elapsed_with_label
27
32
  "#{ELAPSED_LABEL}: #{elapsed}"
28
33
  end
29
34
 
30
- protected
31
-
32
35
  def estimated_with_no_oob
33
- self.out_of_bounds_time_format = nil
34
-
35
- estimated_with_elapsed_fallback
36
+ estimated_with_elapsed_fallback(nil)
36
37
  end
37
38
 
38
39
  def estimated_with_unknown_oob
39
- self.out_of_bounds_time_format = :unknown
40
-
41
- estimated_with_elapsed_fallback
40
+ estimated_with_elapsed_fallback(:unknown)
42
41
  end
43
42
 
44
43
  def estimated_with_friendly_oob
45
- self.out_of_bounds_time_format = :friendly
46
-
47
- estimated_with_elapsed_fallback
44
+ estimated_with_elapsed_fallback(:friendly)
48
45
  end
49
46
 
50
- attr_reader :out_of_bounds_time_format
51
- attr_accessor :timer,
52
- :progress
47
+ def estimated_wall_clock
48
+ return timer.stopped_at.strftime(WALL_CLOCK_FORMAT) if progress.finished?
49
+ return NO_TIME_ELAPSED_TEXT unless timer.started?
53
50
 
54
- def out_of_bounds_time_format=(format)
55
- unless OOB_TIME_FORMATS.include? format
56
- fail 'Invalid Out Of Bounds time format. Valid formats are ' +
57
- OOB_TIME_FORMATS.inspect
58
- end
51
+ memo_estimated_seconds_remaining = estimated_seconds_remaining
52
+ return NO_TIME_ELAPSED_TEXT unless memo_estimated_seconds_remaining
59
53
 
60
- @out_of_bounds_time_format = format
54
+ (timer.now + memo_estimated_seconds_remaining).
55
+ strftime(WALL_CLOCK_FORMAT)
61
56
  end
62
57
 
58
+ protected
59
+
60
+ attr_accessor :timer,
61
+ :progress,
62
+ :projector
63
+
63
64
  private
64
65
 
65
- def estimated
66
+ def estimated(out_of_bounds_time_format)
66
67
  memo_estimated_seconds_remaining = estimated_seconds_remaining
67
68
 
68
69
  return OOB_UNKNOWN_TIME_TEXT unless memo_estimated_seconds_remaining
@@ -70,7 +71,7 @@ class Time
70
71
  hours, minutes, seconds = timer.divide_seconds(memo_estimated_seconds_remaining)
71
72
 
72
73
  if hours > OOB_LIMIT_IN_HOURS && out_of_bounds_time_format
73
- out_of_bounds_time
74
+ OOB_TEXT_TO_FORMAT.fetch(out_of_bounds_time_format)
74
75
  else
75
76
  TIME_FORMAT % [hours, minutes, seconds]
76
77
  end
@@ -84,23 +85,16 @@ class Time
84
85
  TIME_FORMAT % [hours, minutes, seconds]
85
86
  end
86
87
 
87
- def estimated_with_elapsed_fallback
88
- progress.finished? ? elapsed_with_label : estimated_with_label
88
+ def estimated_with_elapsed_fallback(out_of_bounds_time_format)
89
+ return elapsed_with_label if progress.finished?
90
+
91
+ estimated_with_label(out_of_bounds_time_format)
89
92
  end
90
93
 
91
94
  def estimated_seconds_remaining
92
- return if progress.unknown? || progress.none? || timer.stopped?
93
-
94
- (timer.elapsed_seconds * (progress.total / progress.running_average - 1)).round
95
- end
95
+ return if progress.unknown? || projector.none? || progress.none? || timer.stopped? || timer.reset?
96
96
 
97
- def out_of_bounds_time
98
- case out_of_bounds_time_format
99
- when :unknown
100
- OOB_UNKNOWN_TIME_TEXT
101
- when :friendly
102
- OOB_FRIENDLY_TIME_TEXT
103
- end
97
+ (timer.elapsed_seconds * ((progress.total / projector.projection) - 1)).round
104
98
  end
105
99
  end
106
100
  end
@@ -13,7 +13,7 @@ class Formatter
13
13
  bar_length = max_length -
14
14
  processed_string.displayable_length +
15
15
  format_string.bar_molecule_placeholder_length
16
- bar_length = (bar_length < 0) ? 0 : bar_length
16
+ bar_length = 0 if bar_length < 0
17
17
 
18
18
  format_string.bar_molecules.each do |molecule|
19
19
  processed_string.gsub!(molecule.full_key,
@@ -2,26 +2,27 @@ class ProgressBar
2
2
  module Format
3
3
  class Molecule
4
4
  MOLECULES = {
5
- :t => [:title_comp, :title],
6
- :T => [:title_comp, :title],
7
- :c => [:progressable, :progress],
8
- :C => [:progressable, :total],
9
- :u => [:progressable, :total_with_unknown_indicator],
10
- :p => [:percentage, :percentage],
11
- :P => [:percentage, :percentage_with_precision],
12
- :j => [:percentage, :justified_percentage],
13
- :J => [:percentage, :justified_percentage_with_precision],
14
- :a => [:time, :elapsed_with_label],
15
- :e => [:time, :estimated_with_unknown_oob],
16
- :E => [:time, :estimated_with_friendly_oob],
17
- :f => [:time, :estimated_with_no_oob],
18
- :B => [:bar, :complete_bar],
19
- :b => [:bar, :bar],
20
- :W => [:bar, :complete_bar_with_percentage],
21
- :w => [:bar, :bar_with_percentage],
22
- :i => [:bar, :incomplete_space],
23
- :r => [:rate, :rate_of_change],
24
- :R => [:rate, :rate_of_change_with_precision]
5
+ :t => [:title_component, :title],
6
+ :T => [:title_component, :title],
7
+ :c => [:progressable, :progress],
8
+ :C => [:progressable, :total],
9
+ :u => [:progressable, :total_with_unknown_indicator],
10
+ :p => [:percentage_component, :percentage],
11
+ :P => [:percentage_component, :percentage_with_precision],
12
+ :j => [:percentage_component, :justified_percentage],
13
+ :J => [:percentage_component, :justified_percentage_with_precision],
14
+ :a => [:time_component, :elapsed_with_label],
15
+ :e => [:time_component, :estimated_with_unknown_oob],
16
+ :E => [:time_component, :estimated_with_friendly_oob],
17
+ :f => [:time_component, :estimated_with_no_oob],
18
+ :l => [:time_component, :estimated_wall_clock],
19
+ :B => [:bar_component, :complete_bar],
20
+ :b => [:bar_component, :bar],
21
+ :W => [:bar_component, :complete_bar_with_percentage],
22
+ :w => [:bar_component, :bar_with_percentage],
23
+ :i => [:bar_component, :incomplete_space],
24
+ :r => [:rate_component, :rate_of_change],
25
+ :R => [:rate_component, :rate_of_change_with_precision]
25
26
  }.freeze
26
27
 
27
28
  BAR_MOLECULES = %w{W w B b i}.freeze
@@ -1,8 +1,10 @@
1
+ require 'ruby-progressbar/format/molecule'
2
+
1
3
  class ProgressBar
2
4
  module Format
3
5
  class String < ::String
4
- MOLECULE_PATTERN = /%[a-zA-Z]/
5
- ANSI_SGR_PATTERN = /\e\[[\d;]+m/
6
+ MOLECULE_PATTERN = /%[a-zA-Z]/.freeze
7
+ ANSI_SGR_PATTERN = /\e\[[\d;]+m/.freeze
6
8
 
7
9
  def displayable_length
8
10
  gsub(ANSI_SGR_PATTERN, '').length
@@ -29,7 +31,7 @@ class String < ::String
29
31
  end
30
32
 
31
33
  molecules
32
- end
34
+ end
33
35
  end
34
36
  end
35
37
  end
@@ -1,3 +1,6 @@
1
+ require 'ruby-progressbar/calculators/length'
2
+ require 'ruby-progressbar/throttle'
3
+
1
4
  class ProgressBar
2
5
  class Output
3
6
  DEFAULT_OUTPUT_STREAM = $stdout
@@ -17,7 +17,7 @@ class Tty < Output
17
17
  end
18
18
 
19
19
  def default_format
20
- DEFAULT_FORMAT_STRING
20
+ ENV['RUBY_PROGRESS_BAR_FORMAT'] || DEFAULT_FORMAT_STRING
21
21
  end
22
22
 
23
23
  def resolve_format(other_format)
@@ -4,25 +4,19 @@ class ProgressBar
4
4
  class Progress
5
5
  DEFAULT_TOTAL = 100
6
6
  DEFAULT_BEGINNING_POSITION = 0
7
- DEFAULT_SMOOTHING = 0.1
8
7
 
9
8
  attr_reader :total,
10
9
  :progress
11
-
12
- attr_accessor :starting_position,
13
- :running_average,
14
- :smoothing
10
+ attr_accessor :starting_position
15
11
 
16
12
  def initialize(options = {})
17
- self.total = options.fetch(:total, DEFAULT_TOTAL)
18
- self.smoothing = options[:smoothing] || DEFAULT_SMOOTHING
13
+ self.total = options.fetch(:total, DEFAULT_TOTAL)
19
14
 
20
- start :at => DEFAULT_BEGINNING_POSITION
15
+ start(:at => DEFAULT_BEGINNING_POSITION)
21
16
  end
22
17
 
23
18
  def start(options = {})
24
- self.running_average = 0
25
- self.progress = \
19
+ self.progress = \
26
20
  self.starting_position = options[:at] || progress
27
21
  end
28
22
 
@@ -55,7 +49,7 @@ class Progress
55
49
  end
56
50
 
57
51
  def reset
58
- start :at => starting_position
52
+ start(:at => starting_position)
59
53
  end
60
54
 
61
55
  def progress=(new_progress)
@@ -65,10 +59,6 @@ class Progress
65
59
  end
66
60
 
67
61
  @progress = new_progress
68
-
69
- self.running_average = Calculators::RunningAverage.calculate(running_average,
70
- absolute,
71
- smoothing)
72
62
  end
73
63
 
74
64
  def total=(new_total)
@@ -93,7 +83,7 @@ class Progress
93
83
  end
94
84
 
95
85
  def none?
96
- running_average.zero? || progress.zero?
86
+ progress.zero?
97
87
  end
98
88
 
99
89
  def unknown?
@@ -0,0 +1,14 @@
1
+ require 'ruby-progressbar/projectors/smoothed_average'
2
+
3
+ class ProgressBar
4
+ class Projector
5
+ DEFAULT_PROJECTOR = ProgressBar::Projectors::SmoothedAverage
6
+ NAME_TO_PROJECTOR_MAP = {
7
+ 'smoothed' => ProgressBar::Projectors::SmoothedAverage
8
+ }.freeze
9
+
10
+ def self.from_type(name)
11
+ NAME_TO_PROJECTOR_MAP.fetch(name, DEFAULT_PROJECTOR)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,71 @@
1
+ class ProgressBar
2
+ module Projectors
3
+ class SmoothedAverage
4
+ DEFAULT_STRENGTH = 0.1
5
+ DEFAULT_BEGINNING_POSITION = 0
6
+
7
+ attr_accessor :samples,
8
+ :strength
9
+ attr_reader :projection
10
+
11
+ def initialize(options = {})
12
+ self.samples = []
13
+ self.projection = 0.0
14
+ self.strength = options[:strength] || DEFAULT_STRENGTH
15
+
16
+ start(:at => DEFAULT_BEGINNING_POSITION)
17
+ end
18
+
19
+ def start(options = {})
20
+ self.projection = 0.0
21
+ self.progress = samples[0] = (options[:at] || progress)
22
+ end
23
+
24
+ def decrement
25
+ self.progress -= 1
26
+ end
27
+
28
+ def increment
29
+ self.progress += 1
30
+ end
31
+
32
+ def progress
33
+ samples[1]
34
+ end
35
+
36
+ def total=(_new_total); end
37
+
38
+ def reset
39
+ start(:at => samples[0])
40
+ end
41
+
42
+ def progress=(new_progress)
43
+ samples[1] = new_progress
44
+ self.projection = \
45
+ self.class.calculate(
46
+ @projection,
47
+ absolute,
48
+ strength
49
+ )
50
+ end
51
+
52
+ def none?
53
+ projection.zero?
54
+ end
55
+
56
+ def self.calculate(current_projection, new_value, rate)
57
+ (new_value * (1.0 - rate)) + (current_projection * rate)
58
+ end
59
+
60
+ protected
61
+
62
+ attr_writer :projection
63
+
64
+ private
65
+
66
+ def absolute
67
+ samples[1] - samples[0]
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,28 @@
1
+ class ProgressBar
2
+ module Refinements
3
+ module Enumerator
4
+ ARITY_ERROR_MESSAGE = 'Only two arguments allowed to be passed to ' \
5
+ 'with_progressbar (item, progress_bar)'.freeze
6
+
7
+ refine ::Enumerator do
8
+ def with_progressbar(options = {}, &block)
9
+ progress_bar = ProgressBar.create(options.merge(:starting_at => 0, :total => size))
10
+
11
+ each do |item|
12
+ progress_bar.increment
13
+
14
+ next unless block
15
+
16
+ yielded_args = []
17
+ yielded_args << item if block.arity > 0
18
+ yielded_args << progress_bar if block.arity > 1
19
+
20
+ fail ::ArgumentError, ARITY_ERROR_MESSAGE if block.arity > 2
21
+
22
+ yield(*yielded_args)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1 +1 @@
1
- require 'ruby-progressbar/refinements/enumerator'
1
+ require 'ruby-progressbar/refinements/progress_enumerator'
@@ -2,10 +2,10 @@
2
2
  class ProgressBar
3
3
  class Time
4
4
  TIME_MOCKING_LIBRARY_METHODS = [
5
- :__simple_stub__now, # ActiveSupport
6
- :now_without_mock_time, # Timecop
7
- :now_without_delorean, # Delorean
8
- :now # Actual
5
+ :__simple_stub__now, # ActiveSupport
6
+ :now_without_mock_time, # Timecop
7
+ :now_without_delorean, # Delorean
8
+ :now # Unmocked
9
9
  ].freeze
10
10
 
11
11
  def initialize(time = ::Time)
@@ -13,15 +13,13 @@ class Time
13
13
  end
14
14
 
15
15
  def now
16
- time.__send__ unmocked_time_method
16
+ time.__send__(unmocked_time_method)
17
17
  end
18
18
 
19
19
  def unmocked_time_method
20
- @unmocked_time_method ||= begin
21
- TIME_MOCKING_LIBRARY_METHODS.find do |method|
22
- time.respond_to? method
23
- end
24
- end
20
+ @unmocked_time_method ||= TIME_MOCKING_LIBRARY_METHODS.find do |method|
21
+ time.respond_to? method
22
+ end
25
23
  end
26
24
 
27
25
  protected
@@ -6,7 +6,7 @@ class Timer
6
6
  :stopped_at
7
7
 
8
8
  def initialize(options = {})
9
- self.time = options[:time] || Time.new
9
+ self.time = options[:time] || ::ProgressBar::Time.new
10
10
  end
11
11
 
12
12
  def start
@@ -28,6 +28,10 @@ class Timer
28
28
  start
29
29
  end
30
30
 
31
+ def now
32
+ time.now
33
+ end
34
+
31
35
  def started?
32
36
  started_at
33
37
  end
@@ -51,6 +55,8 @@ class Timer
51
55
  end
52
56
 
53
57
  def elapsed_seconds
58
+ return 0 unless started?
59
+
54
60
  ((stopped_at || time.now) - started_at)
55
61
  end
56
62
 
@@ -1,3 +1,3 @@
1
1
  class ProgressBar
2
- VERSION = '1.10.0'.freeze
2
+ VERSION = '1.13.0'.freeze
3
3
  end
@@ -1,15 +1,9 @@
1
- require 'ruby-progressbar/output'
2
- require 'ruby-progressbar/outputs/tty'
3
- require 'ruby-progressbar/outputs/non_tty'
4
- require 'ruby-progressbar/timer'
5
- require 'ruby-progressbar/progress'
6
- require 'ruby-progressbar/throttle'
7
- require 'ruby-progressbar/calculators/length'
8
- require 'ruby-progressbar/calculators/running_average'
9
- require 'ruby-progressbar/components'
10
- require 'ruby-progressbar/format'
1
+ # frozen_string_literal: true
2
+
11
3
  require 'ruby-progressbar/base'
12
- require 'ruby-progressbar/refinements' unless RUBY_VERSION.start_with?('1.')
4
+ require 'ruby-progressbar/refinements' if Module.
5
+ private_instance_methods.
6
+ include?(:using)
13
7
 
14
8
  class ProgressBar
15
9
  def self.create(*args)
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-progressbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0
4
+ version: 1.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thekompanee
@@ -12,8 +12,8 @@ cert_chain:
12
12
  - |
13
13
  -----BEGIN CERTIFICATE-----
14
14
  MIIEdjCCAt6gAwIBAgIBATANBgkqhkiG9w0BAQsFADAyMTAwLgYDVQQDDCdhY2Nv
15
- dW50c19ydWJ5Z2Vtcy9EQz10aGVrb21wYW5lZS9EQz1jb20wHhcNMTgwODAzMjEz
16
- NDA1WhcNMTkwODAzMjEzNDA1WjAyMTAwLgYDVQQDDCdhY2NvdW50c19ydWJ5Z2Vt
15
+ dW50c19ydWJ5Z2Vtcy9EQz10aGVrb21wYW5lZS9EQz1jb20wHhcNMjMwMjI2MTcx
16
+ MDI1WhcNMjYwMjI1MTcxMDI1WjAyMTAwLgYDVQQDDCdhY2NvdW50c19ydWJ5Z2Vt
17
17
  cy9EQz10aGVrb21wYW5lZS9EQz1jb20wggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAw
18
18
  ggGKAoIBgQCqhYn5ODEoLvuBIF2M1GzoaZU28+ntP5QApvDE0Te04n0JbBC1cNYH
19
19
  mr71neeSx7tlZ9w9kJ/8GNcY5bm7pNJqhyhfc+uG9M7FttcxM8AYXogjcdUDP234
@@ -26,17 +26,17 @@ cert_chain:
26
26
  GoP81fN6l88CAwEAAaOBljCBkzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV
27
27
  HQ4EFgQUL4eV4OM9h7fkM27qf9p4ragHi6AwLAYDVR0RBCUwI4EhYWNjb3VudHMr
28
28
  cnVieWdlbXNAdGhla29tcGFuZWUuY29tMCwGA1UdEgQlMCOBIWFjY291bnRzK3J1
29
- YnlnZW1zQHRoZWtvbXBhbmVlLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEANh9Y8ccw
30
- o3/+ZNjNhewsxip/oj8NZHRBLfrSXNT8nIxlB/CrHXHJ5UvJmsH45MYnU8Blsm04
31
- T6PNtZIh8sPWF0ByU/gJhs23C2CGgeDrijZWL/VcOK8ErhLd92lrtXiCei4mexo5
32
- flFW1vLZVTJRiXzVSmuBLkrhQE7BqSHvUTz2vkyf4f/G9jnqp+8Tf0IRZiPGFi82
33
- 2qI/IOGmCb8Oqybt4lcHymLZBYPmj1hb/HVxEWTmQ9Y6ePHSonoK+QZf6Vi+wKga
34
- JxeLxFp0fQc+Mfjx+bFdJgOhcXMjLnDtAaQoDkQfRvQmCTKkXUhNRoTiWtxojkjX
35
- 8mN+AQ66SKTSztEZRZWizqWmTUtkSG+IKlL5E9fUkLYsKV3xgiuwgh+3vSdz398u
36
- KuaMSG4L1U+uHNl3upTjh6wZjzKptsxE0eHSeTlt74ei2EZ4XpDQgMAdxnG19eUY
37
- Ew38fD/eb7KjFt6HWjaE88pp12uYoAUV0xTysHhml+rk1/rn/h3T1Exa
29
+ YnlnZW1zQHRoZWtvbXBhbmVlLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEAD/tBN1cM
30
+ 8Qu6u+rPM3SEtlEK/ZdVY0IowXtXMskkderNBJ4HY+xBfIWyAXLTr3Fy6xscVZ95
31
+ raFCiWHqvR577u3/BsVZ5BoQ0g25oY2bwoamQSdx71ygs25Q+UFbg6lHq6olszj0
32
+ HqKXUy/iPFb+OzGq7NOtKOD5pHl3ew8H7U5tfh0kx6B5TdL9BZLurjskW0n2G+kY
33
+ NSGCTGYU8wY4Bsk/AmfoFT/ATwmrf68CTD+IBY5yvt2DGvcyuSrX1RQP8Vk//0EP
34
+ J2ezTNGIBeQFcyyo09gMfy1yxv9XAvwmy6pAx7/m/F2XzTiXuzmJ7zJ6J0OaHUG4
35
+ svJgf3o9Eor2okQND60Qdpdl4qdSy3KaNqvQQbTRB96e/+K8ksz4rras5jPaAs0p
36
+ DV37k4cni6c/jUm2CqepsJ/dbzeWdkhcuO6hwEQV0jvFky5C6d5hHcrbJwxl1sTL
37
+ V+pWW6L9MSZzKkjWVJXD43B3tWBjIDthQVTzS4j90PUkUXgBXjS7Jxj/
38
38
  -----END CERTIFICATE-----
39
- date: 2018-08-03 00:00:00.000000000 Z
39
+ date: 2023-03-04 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
@@ -81,33 +81,19 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.3'
83
83
  - !ruby/object:Gem::Dependency
84
- name: warning_filter
84
+ name: timecop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.0.6
89
+ version: '0.9'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.0.6
97
- - !ruby/object:Gem::Dependency
98
- name: timecop
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - '='
102
- - !ruby/object:Gem::Version
103
- version: 0.6.0
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - '='
109
- - !ruby/object:Gem::Version
110
- version: 0.6.0
96
+ version: '0.9'
111
97
  description: 'Ruby/ProgressBar is an extremely flexible text progress bar library
112
98
  for Ruby. The output can be customized with a flexible formatting system including:
113
99
  percentage, bars of various formats, elapsed time and estimated time remaining.'
@@ -123,15 +109,12 @@ files:
123
109
  - lib/ruby-progressbar.rb
124
110
  - lib/ruby-progressbar/base.rb
125
111
  - lib/ruby-progressbar/calculators/length.rb
126
- - lib/ruby-progressbar/calculators/running_average.rb
127
- - lib/ruby-progressbar/components.rb
128
112
  - lib/ruby-progressbar/components/bar.rb
129
113
  - lib/ruby-progressbar/components/percentage.rb
130
114
  - lib/ruby-progressbar/components/rate.rb
131
115
  - lib/ruby-progressbar/components/time.rb
132
116
  - lib/ruby-progressbar/components/title.rb
133
117
  - lib/ruby-progressbar/errors/invalid_progress_error.rb
134
- - lib/ruby-progressbar/format.rb
135
118
  - lib/ruby-progressbar/format/formatter.rb
136
119
  - lib/ruby-progressbar/format/molecule.rb
137
120
  - lib/ruby-progressbar/format/string.rb
@@ -140,8 +123,10 @@ files:
140
123
  - lib/ruby-progressbar/outputs/null.rb
141
124
  - lib/ruby-progressbar/outputs/tty.rb
142
125
  - lib/ruby-progressbar/progress.rb
126
+ - lib/ruby-progressbar/projector.rb
127
+ - lib/ruby-progressbar/projectors/smoothed_average.rb
143
128
  - lib/ruby-progressbar/refinements.rb
144
- - lib/ruby-progressbar/refinements/enumerator.rb
129
+ - lib/ruby-progressbar/refinements/progress_enumerator.rb
145
130
  - lib/ruby-progressbar/throttle.rb
146
131
  - lib/ruby-progressbar/time.rb
147
132
  - lib/ruby-progressbar/timer.rb
@@ -150,10 +135,9 @@ homepage: https://github.com/jfelchner/ruby-progressbar
150
135
  licenses:
151
136
  - MIT
152
137
  metadata:
153
- allowed_push_host: https://rubygems.org
154
138
  bug_tracker_uri: https://github.com/jfelchner/ruby-progressbar/issues
155
- changelog_uri: https://github.com/jfelchner/ruby-progressbar/CHANGELOG.md
156
- documentation_uri: https://github.com/jfelchner/ruby-progressbar/tree/releases/v1.10.0
139
+ changelog_uri: https://github.com/jfelchner/ruby-progressbar/blob/master/CHANGELOG.md
140
+ documentation_uri: https://github.com/jfelchner/ruby-progressbar/tree/releases/v1.13.0
157
141
  homepage_uri: https://github.com/jfelchner/ruby-progressbar
158
142
  source_code_uri: https://github.com/jfelchner/ruby-progressbar
159
143
  wiki_uri: https://github.com/jfelchner/ruby-progressbar/wiki
@@ -172,8 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
156
  - !ruby/object:Gem::Version
173
157
  version: '0'
174
158
  requirements: []
175
- rubyforge_project:
176
- rubygems_version: 2.7.7
159
+ rubygems_version: 3.1.6
177
160
  signing_key:
178
161
  specification_version: 4
179
162
  summary: Ruby/ProgressBar is a flexible text progress bar library for Ruby.
metadata.gz.sig CHANGED
Binary file
@@ -1,9 +0,0 @@
1
- class ProgressBar
2
- module Calculators
3
- class RunningAverage
4
- def self.calculate(current_average, new_value_to_average, smoothing_factor)
5
- new_value_to_average * (1.0 - smoothing_factor) + current_average * smoothing_factor
6
- end
7
- end
8
- end
9
- end
@@ -1,5 +0,0 @@
1
- require 'ruby-progressbar/components/bar'
2
- require 'ruby-progressbar/components/percentage'
3
- require 'ruby-progressbar/components/rate'
4
- require 'ruby-progressbar/components/time'
5
- require 'ruby-progressbar/components/title'
@@ -1,3 +0,0 @@
1
- require 'ruby-progressbar/format/molecule'
2
- require 'ruby-progressbar/format/formatter'
3
- require 'ruby-progressbar/format/string'
@@ -1,23 +0,0 @@
1
- class ProgressBar
2
- module Refinements
3
- module Enumerator
4
- refine ::Enumerator do
5
- def with_progressbar(options = {}, &block)
6
- chain = ::Enumerator.new do |yielder|
7
- progress_bar = ProgressBar.create(options.merge(:starting_at => 0, :total => size))
8
-
9
- each do |*args|
10
- yielder.yield(*args).tap do
11
- progress_bar.increment
12
- end
13
- end
14
- end
15
-
16
- return chain unless block_given?
17
-
18
- chain.each(&block)
19
- end
20
- end
21
- end
22
- end
23
- end