ruby-progressbar 1.8.0 → 1.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +3 -3
- data.tar.gz.sig +1 -2
- data/lib/ruby-progressbar/calculators/length.rb +22 -10
- data/lib/ruby-progressbar/version.rb +1 -1
- data/spec/ruby-progressbar/calculators/length_calculator_spec.rb +17 -0
- metadata +6 -3
- metadata.gz.sig +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aaa3f7e32cac695d077a27a84cba08b85a29e17c
|
4
|
+
data.tar.gz: 41cb1de8b816501fd0aedd4f0d6c97a225a30509
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 547e32812e53ba09ad84b04a4bf9452b0a0edc00aba832f2d8c68bf57cb34ea4a6af9f00810e38d0575ae775c0c07267074822541fdd008207f0480e06ed8770
|
7
|
+
data.tar.gz: 24ed9018e51d5dd3a35622ea063e70c9a721becf3355124adc5a7735c59ad6d6bfc774f59a741f883fbdbc7ac4194fcf806f8ab98b848c489c4f35214c654ddf
|
checksums.yaml.gz.sig
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
���
|
2
|
-
�
|
3
|
-
|
1
|
+
[��!��+(��_�������$�G}i���"O�gi��11���q1
|
2
|
+
�\82EN�lLl�6��q�&ߴ��{`BL�R��Q��tq���Le�l��'.�`6�l�խ�+�jY�E<�=�R]>��f᠏c����q%e�&��N0�19���0�3R[���[�q�PVoG
|
3
|
+
�yv��y�K${��9���Grzϻ�D�2-1fz���ր�$�X��c<a4�Sq�p��t���7v?nj��^���*
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
��鬗��j�tw��ح��cIu�����,�90��\}�k��r���P�u���J�f�,l5�� ��F>}�B<
|
1
|
+
��SJ�&�o��k�w_�>|����W��\�'/��a� ���:aO�0g�n���q�J�S��ܮ� �`�T�jg����A�5QX�O|Dp��#�*USj0�T�k��_}��r���A���1��Wrbt��#�O=~�ۨ�������0�N���W��pYs>������?׆t>�)f�����%>�h�z3gΞ�q@M�*��� t
|
@@ -4,7 +4,7 @@ class Length
|
|
4
4
|
attr_reader :length_override
|
5
5
|
attr_accessor :current_length
|
6
6
|
|
7
|
-
def initialize(options)
|
7
|
+
def initialize(options = {})
|
8
8
|
self.length_override = options[:length]
|
9
9
|
self.current_length = nil
|
10
10
|
end
|
@@ -51,21 +51,33 @@ class Length
|
|
51
51
|
require 'io/console'
|
52
52
|
|
53
53
|
def dynamic_width
|
54
|
-
|
55
|
-
|
54
|
+
if IO.console
|
55
|
+
dynamic_width_via_io_object
|
56
|
+
else
|
57
|
+
dynamic_width_via_system_calls
|
58
|
+
end
|
56
59
|
end
|
57
60
|
rescue LoadError
|
58
61
|
def dynamic_width
|
59
|
-
|
62
|
+
dynamic_width_via_system_calls
|
60
63
|
end
|
64
|
+
end
|
61
65
|
|
62
|
-
|
63
|
-
|
64
|
-
|
66
|
+
def dynamic_width_via_io_object
|
67
|
+
_rows, columns = IO.console.winsize
|
68
|
+
columns
|
69
|
+
end
|
65
70
|
|
66
|
-
|
67
|
-
|
68
|
-
|
71
|
+
def dynamic_width_via_system_calls
|
72
|
+
dynamic_width_stty.nonzero? || dynamic_width_tput
|
73
|
+
end
|
74
|
+
|
75
|
+
def dynamic_width_stty
|
76
|
+
`stty size 2>/dev/null`.split[1].to_i
|
77
|
+
end
|
78
|
+
|
79
|
+
def dynamic_width_tput
|
80
|
+
`tput cols 2>/dev/null`.to_i
|
69
81
|
end
|
70
82
|
|
71
83
|
def unix?
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rspectacular'
|
2
|
+
require 'ruby-progressbar/calculators/running_average'
|
3
|
+
|
4
|
+
class ProgressBar
|
5
|
+
module Calculators
|
6
|
+
RSpec.describe Length do
|
7
|
+
it 'can properly calculate the length even if IO.console is nil' do
|
8
|
+
calculator = Length.new
|
9
|
+
|
10
|
+
expect(IO).to receive(:console).and_return nil
|
11
|
+
expect(calculator).to receive(:dynamic_width_via_system_calls).and_return 123_456
|
12
|
+
|
13
|
+
expect(calculator.calculate_length).to eql 123_456
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
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.8.
|
4
|
+
version: 1.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thekompanee
|
@@ -32,7 +32,7 @@ cert_chain:
|
|
32
32
|
QwSfDGz6+zsImi5N3UT71+mk7YcviQSgvMRl3VkAv8MZ6wcJ5SQRpf9w0OeFH6Ln
|
33
33
|
nNbCoHiYeXX/lz/M6AIbxDIZZTwxcyvF7bdrQ2fbH5MsfQ==
|
34
34
|
-----END CERTIFICATE-----
|
35
|
-
date: 2016-
|
35
|
+
date: 2016-05-13 00:00:00.000000000 Z
|
36
36
|
dependencies:
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: rspec
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- lib/ruby-progressbar/version.rb
|
143
143
|
- spec/fixtures/benchmark.rb
|
144
144
|
- spec/ruby-progressbar/base_spec.rb
|
145
|
+
- spec/ruby-progressbar/calculators/length_calculator_spec.rb
|
145
146
|
- spec/ruby-progressbar/calculators/running_average_spec.rb
|
146
147
|
- spec/ruby-progressbar/components/bar_spec.rb
|
147
148
|
- spec/ruby-progressbar/components/percentage_spec.rb
|
@@ -180,13 +181,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
181
|
version: '0'
|
181
182
|
requirements: []
|
182
183
|
rubyforge_project:
|
183
|
-
rubygems_version: 2.5.1
|
184
|
+
rubygems_version: 2.4.5.1
|
184
185
|
signing_key:
|
185
186
|
specification_version: 4
|
186
187
|
summary: Ruby/ProgressBar is a flexible text progress bar library for Ruby.
|
187
188
|
test_files:
|
188
189
|
- spec/fixtures/benchmark.rb
|
189
190
|
- spec/ruby-progressbar/base_spec.rb
|
191
|
+
- spec/ruby-progressbar/calculators/length_calculator_spec.rb
|
190
192
|
- spec/ruby-progressbar/calculators/running_average_spec.rb
|
191
193
|
- spec/ruby-progressbar/components/bar_spec.rb
|
192
194
|
- spec/ruby-progressbar/components/percentage_spec.rb
|
@@ -205,3 +207,4 @@ test_files:
|
|
205
207
|
- spec/ruby-progressbar/timer_spec.rb
|
206
208
|
- spec/spec_helper.rb
|
207
209
|
- spec/support/time.rb
|
210
|
+
has_rdoc:
|
metadata.gz.sig
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
|
2
|
+
�)w�X��(u��;�f�����!��t�s���X_}b�L�8˭Qa�z2i��ф�+�ܓ�څ�����w�г!�������۟��DKF"�55����<��M.��^]
|