infobar 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/README.md +3 -0
- data/VERSION +1 -1
- data/infobar.gemspec +3 -3
- data/lib/infobar/number.rb +12 -4
- data/lib/infobar/version.rb +1 -1
- data/spec/infobar/number_spec.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6be0ff22b6b4cff7706761d7362eef626b328500026c47a13594069a4891f9e1
|
4
|
+
data.tar.gz: 0ffe940091eb19ede807132116d24a65492380f4d0f23b23c7e686643369818f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 493f9b92d05a2bb2ad01abae64d042865fc6ee69e1c949548b8f6c50fd6f8f81adc5f2f54fc9d3cf1aecea9f95bc0b66593e3d89e7f3ee3a591cf164018f22d1
|
7
|
+
data.tar.gz: 737d899878bacb22bd7cf417cd6eab20561c2f902021f7646947bfe3280cb908135953de5b05124ed10506a579f08ee548428c11687d0c2efa9c2d23b4ba0e9c
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -21,6 +21,9 @@ Display progress of computations and additional information to the terminal.
|
|
21
21
|
|
22
22
|
## Changes
|
23
23
|
|
24
|
+
* 2018-03-05 Release 0.5.0
|
25
|
+
- Allow counter values to be formatted with units.
|
26
|
+
|
24
27
|
* 2017-12-08 Release 0.4.0
|
25
28
|
- Automatically iterate when `with_infobar` is passed a block.
|
26
29
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/infobar.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: infobar 0.
|
2
|
+
# stub: infobar 0.5.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "infobar".freeze
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.5.0"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
10
10
|
s.authors = ["Florian Frank".freeze]
|
11
|
-
s.date = "
|
11
|
+
s.date = "2018-03-05"
|
12
12
|
s.description = "This gem displays progress of computations and additional information to the terminal.".freeze
|
13
13
|
s.email = "flori@ping.de".freeze
|
14
14
|
s.extra_rdoc_files = ["README.md".freeze, "lib/infobar.rb".freeze, "lib/infobar/counter.rb".freeze, "lib/infobar/display.rb".freeze, "lib/infobar/duration.rb".freeze, "lib/infobar/fancy_interface.rb".freeze, "lib/infobar/fifo.rb".freeze, "lib/infobar/frequency.rb".freeze, "lib/infobar/input_output.rb".freeze, "lib/infobar/message.rb".freeze, "lib/infobar/number.rb".freeze, "lib/infobar/rate.rb".freeze, "lib/infobar/spinner.rb".freeze, "lib/infobar/timer.rb".freeze, "lib/infobar/trend.rb".freeze, "lib/infobar/version.rb".freeze]
|
data/lib/infobar/number.rb
CHANGED
@@ -1,9 +1,17 @@
|
|
1
1
|
class Infobar::Number
|
2
|
-
def initialize(value, format: nil, separate: nil)
|
2
|
+
def initialize(value, format: nil, unit: nil, prefix: 1000, separate: nil)
|
3
3
|
duration = Tins::Duration.new(value)
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
case format
|
5
|
+
when /%U/
|
6
|
+
unit ||= 'i/s'
|
7
|
+
prefix ||= 1000
|
8
|
+
@string = Tins::Unit.format(value, format: format, unit: unit, prefix: prefix)
|
9
|
+
else
|
10
|
+
format ||= '%f'
|
11
|
+
@string = format ? format % value : value.to_s
|
12
|
+
if Integer === value && separate
|
13
|
+
@string.gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{separate}")
|
14
|
+
end
|
7
15
|
end
|
8
16
|
end
|
9
17
|
|
data/lib/infobar/version.rb
CHANGED
data/spec/infobar/number_spec.rb
CHANGED
@@ -8,5 +8,16 @@ describe Infobar::Number do
|
|
8
8
|
it 'can convert number into string for format' do
|
9
9
|
expect(described_class.new(Math::PI, format: '%.3f').to_s).to eq '3.142'
|
10
10
|
end
|
11
|
+
|
12
|
+
it 'can convert number into string for unit format' do
|
13
|
+
expect(
|
14
|
+
described_class.new(
|
15
|
+
1e6 * Math::PI,
|
16
|
+
unit: ?B,
|
17
|
+
prefix: 1024,
|
18
|
+
format: '%.3f%U'
|
19
|
+
).to_s
|
20
|
+
).to eq '2.996MB'
|
21
|
+
end
|
11
22
|
end
|
12
23
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infobar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|