tty-progressbar 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +7 -0
  3. data/CHANGELOG.md +9 -0
  4. data/Gemfile +3 -3
  5. data/README.md +27 -13
  6. data/lib/tty/progressbar.rb +37 -22
  7. data/lib/tty/progressbar/version.rb +1 -1
  8. data/spec/spec_helper.rb +2 -2
  9. data/spec/unit/advance_spec.rb +1 -1
  10. data/spec/unit/clear_spec.rb +0 -2
  11. data/spec/unit/complete_spec.rb +2 -4
  12. data/spec/unit/converter/to_bytes_spec.rb +2 -4
  13. data/spec/unit/converter/to_seconds_spec.rb +2 -4
  14. data/spec/unit/converter/to_time_spec.rb +2 -4
  15. data/spec/unit/custom_formatter_spec.rb +1 -1
  16. data/spec/unit/custom_token_spec.rb +1 -1
  17. data/spec/unit/finish_spec.rb +2 -4
  18. data/spec/unit/formatter/bar_spec.rb +1 -3
  19. data/spec/unit/formatter/byte_rate_spec.rb +2 -4
  20. data/spec/unit/formatter/current_byte_spec.rb +2 -4
  21. data/spec/unit/formatter/current_spec.rb +2 -4
  22. data/spec/unit/formatter/elapsed_spec.rb +1 -3
  23. data/spec/unit/formatter/estimated_spec.rb +2 -4
  24. data/spec/unit/formatter/mean_byte_spec.rb +2 -4
  25. data/spec/unit/formatter/mean_rate_spec.rb +2 -4
  26. data/spec/unit/formatter/percent_spec.rb +2 -4
  27. data/spec/unit/formatter/rate_spec.rb +2 -4
  28. data/spec/unit/formatter/total_byte_spec.rb +2 -4
  29. data/spec/unit/formatter/total_spec.rb +2 -4
  30. data/spec/unit/frequency_spec.rb +0 -2
  31. data/spec/unit/hide_cursor_spec.rb +1 -3
  32. data/spec/unit/inspect_spec.rb +13 -0
  33. data/spec/unit/log_spec.rb +1 -3
  34. data/spec/unit/meter_spec.rb +1 -1
  35. data/spec/unit/new_spec.rb +1 -3
  36. data/spec/unit/pipeline_spec.rb +1 -3
  37. data/spec/unit/ratio_spec.rb +1 -1
  38. data/spec/unit/reset_spec.rb +1 -3
  39. data/spec/unit/resize_spec.rb +3 -5
  40. data/spec/unit/set_current_spec.rb +1 -3
  41. data/spec/unit/start_spec.rb +1 -3
  42. data/spec/unit/width_spec.rb +1 -3
  43. metadata +5 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7cfa129b15dd05ae8aa61f50a438bad476dc1e05
4
- data.tar.gz: 1c3250520ab0679a59d2c0cc4ab5484ee89aa63e
3
+ metadata.gz: 8e137d51b66bb2d42c3b21390f09323b7a7cc31b
4
+ data.tar.gz: 90374c2957298fe9f02ec5de90a06fa9b5371956
5
5
  SHA512:
6
- metadata.gz: 43591871c9a77b4ecfd937381bdaf447f9d7df956c00b44821b0dfdbfa14aa19ddfac4d40a24ee8c02b728764902ae21ce9c14b74dad8726f2d97b138fe66347
7
- data.tar.gz: 931e0a313f3393456d2488fff96592ec0b6c012d42805346f9bf95a7d0b4966f1a1458b4a2fe4b793f2cf463abe0c60e1baf39377b18fd9b149156c0a9d2e028
6
+ metadata.gz: 37c1713fde3ec813436bd8ea3b190f66670a15477a1020bcb7256999477b4eb50aa7781a3520b4eb31545fab121f569dc72b6541b2b5dd059fc86e5c1750ff32
7
+ data.tar.gz: 99efdc1a6d78fa7a52692102fea4969e558de445076ea66b07913076583a628bd82980cb3329f632270f96829c1b0f47278b5c95baca5b5c22c4b219a99714d8
data/.codeclimate.yml ADDED
@@ -0,0 +1,7 @@
1
+ ratings:
2
+ paths:
3
+ - lib/**/*.rb
4
+ exclude_paths:
5
+ - spec/**/*
6
+ - examples/**/*
7
+ - tasks/**/*
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change log
2
2
 
3
+ ## [v0.8.1] - 2016-02-27
4
+
5
+ ### Added
6
+ * Add progress bar #inspect
7
+
8
+ ### Fixed
9
+ * Fix the progressbar resizing call, help from @squarism
10
+
3
11
  ## [v0.8.0] - 2016-02-07
4
12
 
5
13
  ### Changed
@@ -69,6 +77,7 @@
69
77
 
70
78
  * Initial implementation and release
71
79
 
80
+ [v0.8.1]: https://github.com/peter-murach/tty-progressbar/compare/v0.8.0...v0.8.1
72
81
  [v0.8.0]: https://github.com/peter-murach/tty-progressbar/compare/v0.7.0...v0.8.0
73
82
  [v0.7.0]: https://github.com/peter-murach/tty-progressbar/compare/v0.6.0...v0.7.0
74
83
  [v0.6.0]: https://github.com/peter-murach/tty-progressbar/compare/v0.5.1...v0.6.0
data/Gemfile CHANGED
@@ -2,15 +2,15 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- group :development do
5
+ group :test do
6
6
  gem 'rspec', '~> 3.4.0'
7
7
  gem 'yard', '~> 0.8.7'
8
8
  gem 'timecop', '~> 0.7.1'
9
9
  gem 'pastel', '~> 0.6.0'
10
+ gem 'codeclimate-test-reporter'
11
+ gem 'simplecov', '~> 0.11.2'
10
12
  end
11
13
 
12
14
  group :metrics do
13
- gem 'coveralls', '~> 0.8.10'
14
- gem 'simplecov', '~> 0.11.2'
15
15
  gem 'yardstick', '~> 0.9.9'
16
16
  end
data/README.md CHANGED
@@ -2,13 +2,12 @@
2
2
  [![Gem Version](https://badge.fury.io/rb/tty-progressbar.svg)][gem]
3
3
  [![Build Status](https://secure.travis-ci.org/peter-murach/tty-progressbar.svg?branch=master)][travis]
4
4
  [![Code Climate](https://codeclimate.com/github/peter-murach/tty-progressbar/badges/gpa.svg)][codeclimate]
5
- [![Coverage Status](https://coveralls.io/repos/peter-murach/tty-progressbar/badge.svg)][coverage]
5
+ [![Coverage Status](https://codeclimate.com/github/peter-murach/tty-progressbar/badges/coverage.svg)][codeclimate]
6
6
  [![Inline docs](http://inch-ci.org/github/peter-murach/tty-progressbar.svg?branch=master)][inchpages]
7
7
 
8
8
  [gem]: http://badge.fury.io/rb/tty-progressbar
9
9
  [travis]: http://travis-ci.org/peter-murach/tty-progressbar
10
10
  [codeclimate]: https://codeclimate.com/github/peter-murach/tty-progressbar
11
- [coverage]: https://coveralls.io/r/peter-murach/tty-progressbar
12
11
  [inchpages]: http://inch-ci.org/github/peter-murach/tty-progressbar
13
12
 
14
13
  > A flexible progress bars drawing in terminal emulators.
@@ -44,11 +43,12 @@ Or install it yourself as:
44
43
  * [1.1 advance](#11-advance)
45
44
  * [1.2 current=](#12-current)
46
45
  * [1.3 ratio=](#13-ratio)
47
- * [1.4 start](#14-start)
48
- * [1.5 finish](#15-finish)
49
- * [1.6 complete?](#16-complete)
50
- * [1.7 reset](#17-reset)
51
- * [1.8 resize](#18-resize)
46
+ * [1.4 width=](#14-width)
47
+ * [1.5 start](#15-start)
48
+ * [1.6 finish](#16-finish)
49
+ * [1.7 complete?](#17-complete)
50
+ * [1.8 reset](#18-reset)
51
+ * [1.9 resize](#19-resize)
52
52
  * [2. Configuration](#2-configuration)
53
53
  * [2.1 Frequency](#21-frequency)
54
54
  * [2.2 Interval](#22-interval)
@@ -112,7 +112,21 @@ In order to update overall completion of a progress bar as an exact percentage u
112
112
  bar.ratio = 0.5
113
113
  ```
114
114
 
115
- ### 1.4 start
115
+ ### 1.4 width=
116
+
117
+ You can set how many terminal columns will the `:bar` actually span excluding any other tokens and/or text. For example if you need the bar to be always 20 columns wwide do:
118
+
119
+ ```ruby
120
+ bar.width = 20
121
+ ```
122
+
123
+ or with configuration options:
124
+
125
+ ```ruby
126
+ bar = TTY::ProgressBar.new("[:bar]", width: 20)
127
+ ```
128
+
129
+ ### 1.5 start
116
130
 
117
131
  By default the timer for internal time esitamation is started automatically when the `advance` method is called. However, if you require control on when the progression timer is started use `start` call:
118
132
 
@@ -120,7 +134,7 @@ By default the timer for internal time esitamation is started automatically when
120
134
  bar.start # => sets timer and draws initial progress bar
121
135
  ```
122
136
 
123
- ### 1.5 finish
137
+ ### 1.6 finish
124
138
 
125
139
  In order to immediately stop and finish the progress call `finish`. This will finish drawing the progress and return to new line.
126
140
 
@@ -128,7 +142,7 @@ In order to immediately stop and finish the progress call `finish`. This will fi
128
142
  bar.finish
129
143
  ```
130
144
 
131
- ### 1.6 complete?
145
+ ### 1.7 complete?
132
146
 
133
147
  During progresion you can check if bar is finished or not by calling `complete?`.
134
148
 
@@ -136,7 +150,7 @@ During progresion you can check if bar is finished or not by calling `complete?`
136
150
  bar.complete? # => false
137
151
  ```
138
152
 
139
- ### 1.7 reset
153
+ ### 1.8 reset
140
154
 
141
155
  In order to reset currently running or finished progress bar to its original configuration and initial position use `reset` like so:
142
156
 
@@ -144,7 +158,7 @@ In order to reset currently running or finished progress bar to its original con
144
158
  bar.reset
145
159
  ```
146
160
 
147
- ### 1.8 resize
161
+ ### 1.9 resize
148
162
 
149
163
  If you wish for a progress bar to change it's current width, you can use `resize` by passing in a new desired length:
150
164
 
@@ -157,7 +171,7 @@ bar.resize(50) # => will resize bar proportionately from this point onwards
157
171
  There are number of configuration options that can be provided:
158
172
 
159
173
  * `total` total number of steps to completion
160
- * `width` for the bars display including formatting options defaulting to total
174
+ * `width` of the bars display in terminal columns excluding formatting options. Defaults to total steps
161
175
  * `complete` completion character by default `=`
162
176
  * `incomplete` incomplete character by default single space
163
177
  * `output` the output stream defaulting to `stderr`
@@ -24,7 +24,7 @@ module TTY
24
24
 
25
25
  def_delegators :@configuration, :total, :width, :no_width,
26
26
  :complete, :incomplete, :hide_cursor, :clear,
27
- :output, :frequency
27
+ :output, :frequency, :interval, :width=
28
28
 
29
29
  def_delegators :@meter, :rate, :mean_rate
30
30
 
@@ -74,7 +74,7 @@ module TTY
74
74
  @meter = Meter.new(options.fetch(:interval, 1))
75
75
 
76
76
  @formatter.load
77
- register_callbacks
77
+ register_signals
78
78
  end
79
79
 
80
80
  # Start progression by drawing bar and setting time
@@ -94,6 +94,7 @@ module TTY
94
94
  #
95
95
  # @api public
96
96
  def advance(progress = 1, tokens = {})
97
+ #handle_signals
97
98
  return if @done
98
99
 
99
100
  if progress.respond_to?(:to_hash)
@@ -179,19 +180,16 @@ module TTY
179
180
 
180
181
  # Resize progress bar with new configuration
181
182
  #
183
+ # @param [Integer] new_width
184
+ # the new width for the bar display
185
+ #
182
186
  # @api public
183
- def resize(new_width)
187
+ def resize(new_width = nil)
184
188
  fail 'Cannot resize finished progress bar' if @done
185
-
189
+ clear_line
186
190
  if new_width
187
- @configuration.no_width = false
188
- @configuration.width = new_width
189
- else
190
- @configuration.no_width = true
191
- @configuration.width = 0
191
+ self.width = new_width
192
192
  end
193
-
194
- advance(0) # rerender with new configuration
195
193
  end
196
194
 
197
195
  # End the progress
@@ -266,6 +264,31 @@ module TTY
266
264
  TTY::Screen.width
267
265
  end
268
266
 
267
+ # Show bar format
268
+ #
269
+ # @return [String]
270
+ #
271
+ # @api public
272
+ def to_s
273
+ @format.to_s
274
+ end
275
+
276
+ # Inspect bar properties
277
+ #
278
+ # @return [String]
279
+ #
280
+ # @api public
281
+ def inspect
282
+ output = "#<#{self.class.name} "
283
+ output << "@format=\"#{format}\", "
284
+ output << "@current=\"#{@current}\", "
285
+ output << "@total=\"#{total}\", "
286
+ output << "@width=\"#{width}\", "
287
+ output << "@complete=\"#{complete}\", "
288
+ output << "@incomplete=\"#{incomplete}\", "
289
+ output << "@interval=\"#{interval}\">"
290
+ end
291
+
269
292
  private
270
293
 
271
294
  # Pad message out with spaces
@@ -279,21 +302,13 @@ module TTY
279
302
  message
280
303
  end
281
304
 
282
- EXIT_SIGS = [:QUIT, :TERM, :INT]
283
-
284
305
  # Handle resize and kill signals
285
306
  #
286
307
  # @api private
287
- def register_callbacks
288
- callback = proc do
289
- adjusted_width = width < max_columns ? width : max_columns
290
- send(:resize, adjusted_width)
291
- end
292
- Signal.trap('WINCH', &callback)
308
+ def register_signals
309
+ trap(:WINCH) { resize }
293
310
 
294
- EXIT_SIGS.each do |sig|
295
- Signal.trap(sig) { finish && fail(Interrupt) }
296
- end
311
+ trap(:INT) { exit! }
297
312
  end
298
313
  end # ProgressBar
299
314
  end # TTY
@@ -2,6 +2,6 @@
2
2
 
3
3
  module TTY
4
4
  class ProgressBar
5
- VERSION = '0.8.0'
5
+ VERSION = '0.8.1'
6
6
  end # ProgressBar
7
7
  end # TTY
data/spec/spec_helper.rb CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  if RUBY_VERSION > '1.9' and (ENV['COVERAGE'] || ENV['TRAVIS'])
4
4
  require 'simplecov'
5
- require 'coveralls'
5
+ require 'codeclimate-test-reporter'
6
6
 
7
7
  SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
8
8
  SimpleCov::Formatter::HTMLFormatter,
9
- Coveralls::SimpleCov::Formatter
9
+ CodeClimate::TestReporter::Formatter
10
10
  ]
11
11
 
12
12
  SimpleCov.start do
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- RSpec.describe TTY::ProgressBar, '.advance' do
3
+ RSpec.describe TTY::ProgressBar, '#advance' do
4
4
  let(:output) { StringIO.new('', 'w+') }
5
5
 
6
6
  it "advances by custom value" do
@@ -1,7 +1,5 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
3
  RSpec.describe TTY::ProgressBar, 'clear' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
@@ -1,8 +1,6 @@
1
- # coding: utf-8
1
+ # encoding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar, '.complete?' do
3
+ RSpec.describe TTY::ProgressBar, '#complete?' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
8
6
  it "checks for completness" do
@@ -1,8 +1,6 @@
1
- # coding: utf-8
1
+ # encoding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar::Converter, '.to_bytes' do
3
+ RSpec.describe TTY::ProgressBar::Converter, '#to_bytes' do
6
4
  subject(:converter) { described_class.new }
7
5
 
8
6
  it "converts 1000 to bytes" do
@@ -1,8 +1,6 @@
1
- # coding: utf-8
1
+ # encoding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar::Converter, '.to_seconds' do
3
+ RSpec.describe TTY::ProgressBar::Converter, '#to_seconds' do
6
4
  subject(:converter) { described_class.new }
7
5
 
8
6
  it "ensure 5 digit precision for < 1" do
@@ -1,8 +1,6 @@
1
- # coding: utf-8
1
+ # encoding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar::Converter, '.to_time' do
3
+ RSpec.describe TTY::ProgressBar::Converter, '#to_time' do
6
4
  subject(:converter) { described_class.new }
7
5
 
8
6
  it "converts seconds to seconds" do
@@ -1,4 +1,4 @@
1
- # coding: utf-8
1
+ # encoding: utf-8
2
2
 
3
3
  RSpec.describe TTY::ProgressBar, 'custom formatter' do
4
4
  let(:output) { StringIO.new('', 'w+') }
@@ -1,4 +1,4 @@
1
- # coding: utf-8
1
+ # encoding: utf-8
2
2
 
3
3
  RSpec.describe TTY::ProgressBar, 'custom token' do
4
4
  let(:output) { StringIO.new('', 'w+') }
@@ -1,8 +1,6 @@
1
- # coding: utf-8
1
+ # encoding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar, '.finish' do
3
+ RSpec.describe TTY::ProgressBar, '#finish' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
8
6
  it 'finishes progress' do
@@ -1,8 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar, 'bar' do
3
+ RSpec.describe TTY::ProgressBar, ':bar token' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
8
6
  it "animates bar" do
@@ -1,8 +1,6 @@
1
- # coding: utf-8
1
+ # encoding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar, 'byte_rate' do
3
+ RSpec.describe TTY::ProgressBar, ':byte_rate token' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
8
6
  before { Timecop.safe_mode = false }
@@ -1,8 +1,6 @@
1
- # coding: utf-8
1
+ # encoding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar, 'current_byte' do
3
+ RSpec.describe TTY::ProgressBar, ':current_byte token' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
8
6
  it "displays bytes processed" do
@@ -1,8 +1,6 @@
1
- # coding: utf-8
1
+ # encoding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar, 'current' do
3
+ RSpec.describe TTY::ProgressBar, ':current token' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
8
6
  it "displays current value" do
@@ -1,8 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar, 'elapsed' do
3
+ RSpec.describe TTY::ProgressBar, ':elapsed token' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
8
6
  before { Timecop.safe_mode = false }
@@ -1,8 +1,6 @@
1
- # coding: utf-8
1
+ # encoding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar, 'estimated' do
3
+ RSpec.describe TTY::ProgressBar, ':eta token' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
8
6
  before { Timecop.safe_mode = false }
@@ -1,8 +1,6 @@
1
- # coding: utf-8
1
+ # encoding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar, 'mean_byte' do
3
+ RSpec.describe TTY::ProgressBar, ':mean_byte token' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
8
6
  before { Timecop.safe_mode = false }
@@ -1,8 +1,6 @@
1
- # coding: utf-8
1
+ # encoding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar, 'mean_rate' do
3
+ RSpec.describe TTY::ProgressBar, ':mean_rate token' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
8
6
  before { Timecop.safe_mode = false }
@@ -1,8 +1,6 @@
1
- # coding: utf-8
1
+ # encoding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar, 'percent' do
3
+ RSpec.describe TTY::ProgressBar, ':percent token' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
8
6
  it "displays percent finished" do
@@ -1,8 +1,6 @@
1
- # coding: utf-8
1
+ # encoding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar, 'rate' do
3
+ RSpec.describe TTY::ProgressBar, ':rate token' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
8
6
  before { Timecop.safe_mode = false }
@@ -1,8 +1,6 @@
1
- # coding: utf-8
1
+ # encoding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar, 'total_byte' do
3
+ RSpec.describe TTY::ProgressBar, ':total_byte token' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
8
6
  it "displays bytes total" do
@@ -1,8 +1,6 @@
1
- # coding: utf-8
1
+ # encoding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar, 'total' do
3
+ RSpec.describe TTY::ProgressBar, ':total token' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
8
6
  it "displays bytes total" do
@@ -1,7 +1,5 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
3
  RSpec.describe TTY::ProgressBar, 'frequency' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
@@ -1,8 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar, 'hide_cursor' do
3
+ RSpec.describe TTY::ProgressBar, '#hide_cursor' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
8
6
  it "hides cursor" do
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+
3
+ RSpec.describe TTY::ProgressBar, '#inspect' do
4
+ it "inspects bar properties" do
5
+ bar = described_class.new("downloading [:bar] :total", total: 30)
6
+ expect(bar.inspect).to eq(%q{#<TTY::ProgressBar @format="downloading [:bar] :total", @current="0", @total="30", @width="30", @complete="=", @incomplete=" ", @interval="">})
7
+ end
8
+
9
+ it "prints string format" do
10
+ bar = described_class.new("downloading [:bar] :total", total: 30)
11
+ expect(bar.to_s).to eq("downloading [:bar] :total")
12
+ end
13
+ end
@@ -1,8 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar, '.log' do
3
+ RSpec.describe TTY::ProgressBar, '#log' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
8
6
  it "logs message" do
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- RSpec.describe TTY::ProgressBar::Meter, '.rate' do
3
+ RSpec.describe TTY::ProgressBar::Meter, '#rate' do
4
4
 
5
5
  before { Timecop.safe_mode = false }
6
6
 
@@ -1,8 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar, '.new' do
3
+ RSpec.describe TTY::ProgressBar, '::new' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
8
6
  it "displays output where width == total" do
@@ -1,8 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar::Pipeline, '.decorate' do
3
+ RSpec.describe TTY::ProgressBar::Pipeline, '#decorate' do
6
4
  subject(:pipeline) { described_class.new }
7
5
 
8
6
  it "decorates tokenized string with pipeline formatters" do
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- RSpec.describe TTY::ProgressBar, '.ratio=' do
3
+ RSpec.describe TTY::ProgressBar, '#ratio=' do
4
4
  let(:output) { StringIO.new('', 'w+') }
5
5
 
6
6
  it "allows to set ratio" do
@@ -1,8 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar, '.reset' do
3
+ RSpec.describe TTY::ProgressBar, '#reset' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
8
6
  it "resets current progress" do
@@ -1,8 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar, '.resize' do
3
+ RSpec.describe TTY::ProgressBar, '#resize' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
8
6
  it "resizes output down by x2" do
@@ -14,7 +12,7 @@ RSpec.describe TTY::ProgressBar, '.resize' do
14
12
  expect(output.read).to eq([
15
13
  "\e[1G[== ]",
16
14
  "\e[1G[==== ]",
17
- "\e[1G[== ]",
15
+ "\e[0m\e[1000D\e[K",
18
16
  "\e[1G[=== ]",
19
17
  "\e[1G[==== ]",
20
18
  "\e[1G[=====]\n"
@@ -30,7 +28,7 @@ RSpec.describe TTY::ProgressBar, '.resize' do
30
28
  expect(output.read).to eq([
31
29
  "\e[1G[== ]",
32
30
  "\e[1G[==== ]",
33
- "\e[1G[======== ]",
31
+ "\e[0m\e[1000D\e[K",
34
32
  "\e[1G[============ ]",
35
33
  "\e[1G[================ ]",
36
34
  "\e[1G[====================]\n"
@@ -1,8 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar, 'current=' do
3
+ RSpec.describe TTY::ProgressBar, '#current=' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
8
6
  it "allows to go back" do
@@ -1,8 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar, '.start' do
3
+ RSpec.describe TTY::ProgressBar, '#start' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
8
6
  it "starts timer and draws initial progress" do
@@ -1,8 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'spec_helper'
4
-
5
- RSpec.describe TTY::ProgressBar, 'width' do
3
+ RSpec.describe TTY::ProgressBar, '#width' do
6
4
  let(:output) { StringIO.new('', 'w+') }
7
5
 
8
6
  it "handles width exceeding terminal width" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tty-progressbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Murach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-07 00:00:00.000000000 Z
11
+ date: 2016-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-screen
@@ -65,6 +65,7 @@ executables: []
65
65
  extensions: []
66
66
  extra_rdoc_files: []
67
67
  files:
68
+ - .codeclimate.yml
68
69
  - .gitignore
69
70
  - .rspec
70
71
  - .travis.yml
@@ -121,6 +122,7 @@ files:
121
122
  - spec/unit/formatter/total_spec.rb
122
123
  - spec/unit/frequency_spec.rb
123
124
  - spec/unit/hide_cursor_spec.rb
125
+ - spec/unit/inspect_spec.rb
124
126
  - spec/unit/log_spec.rb
125
127
  - spec/unit/meter_spec.rb
126
128
  - spec/unit/new_spec.rb
@@ -184,6 +186,7 @@ test_files:
184
186
  - spec/unit/formatter/total_spec.rb
185
187
  - spec/unit/frequency_spec.rb
186
188
  - spec/unit/hide_cursor_spec.rb
189
+ - spec/unit/inspect_spec.rb
187
190
  - spec/unit/log_spec.rb
188
191
  - spec/unit/meter_spec.rb
189
192
  - spec/unit/new_spec.rb