humanize-bytes 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/humanize-bytes.gemspec +1 -0
- data/lib/humanize/byte.rb +3 -2
- data/lib/humanize/bytes.rb +1 -1
- data/lib/humanize/giga.rb +3 -2
- data/lib/humanize/kilo.rb +3 -2
- data/lib/humanize/mega.rb +3 -2
- data/spec/humanize/byte_spec.rb +2 -2
- data/spec/humanize/giga_spec.rb +2 -2
- data/spec/humanize/kilo_spec.rb +2 -2
- data/spec/humanize/mega_spec.rb +2 -2
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b822e696f285eb1cef5a3adc0a204264a9e18acf
|
4
|
+
data.tar.gz: b6a0b750bdb3063662be4e4c998cea19dfe767e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 550886946965209414c1257ed751400961ce4454176b872e5b31775c350e429a0cbf14ec67eff914f4829c8ef97cf8896381c764eff3cf9ed3e231c8334b7464
|
7
|
+
data.tar.gz: 6745bafdf1844cc8f252f40243a4bacd2b2e39e2dc733742be0e41cb4ad16265ff447b2533c51df0835e729e5b4db7472175812e46336be48abab78771a82f45
|
data/humanize-bytes.gemspec
CHANGED
data/lib/humanize/byte.rb
CHANGED
@@ -25,8 +25,9 @@ module Humanize
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def to_s(options = {})
|
28
|
-
size = options.fetch(:decimal_digits,
|
29
|
-
(
|
28
|
+
size = options.fetch(:decimal_digits, nil)
|
29
|
+
size ||= value.to_s.split('.').size == 1 ? 0 : value.to_s.split('.').last.size
|
30
|
+
("%.#{size}f" % value).to_s
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
data/lib/humanize/bytes.rb
CHANGED
data/lib/humanize/giga.rb
CHANGED
@@ -25,8 +25,9 @@ module Humanize
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def to_s(options = {})
|
28
|
-
size = options.fetch(:decimal_digits,
|
29
|
-
(
|
28
|
+
size = options.fetch(:decimal_digits, nil)
|
29
|
+
size ||= value.to_s.split('.').size == 1 ? 0 : value.to_s.split('.').last.size
|
30
|
+
("%.#{size}f" % value).to_s
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
data/lib/humanize/kilo.rb
CHANGED
@@ -25,8 +25,9 @@ module Humanize
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def to_s(options = {})
|
28
|
-
size = options.fetch(:decimal_digits,
|
29
|
-
(
|
28
|
+
size = options.fetch(:decimal_digits, nil)
|
29
|
+
size ||= value.to_s.split('.').size == 1 ? 0 : value.to_s.split('.').last.size
|
30
|
+
("%.#{size}f" % value).to_s
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
data/lib/humanize/mega.rb
CHANGED
@@ -25,8 +25,9 @@ module Humanize
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def to_s(options = {})
|
28
|
-
size = options.fetch(:decimal_digits,
|
29
|
-
(
|
28
|
+
size = options.fetch(:decimal_digits, nil)
|
29
|
+
size ||= value.to_s.split('.').size == 1 ? 0 : value.to_s.split('.').last.size
|
30
|
+
("%.#{size}f" % value).to_s
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
data/spec/humanize/byte_spec.rb
CHANGED
@@ -45,7 +45,7 @@ describe Humanize::Byte do
|
|
45
45
|
context "#to_s" do
|
46
46
|
context 'without any specification' do
|
47
47
|
it "should return a float with all digits" do
|
48
|
-
expect(b.to_s).to eq(2147843648
|
48
|
+
expect(b.to_s).to eq('2147843648')
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -55,7 +55,7 @@ describe Humanize::Byte do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should return a float with specified digits" do
|
58
|
-
expect(@b.to_s(:decimal_digits => 2)).to eq(2147843648.23)
|
58
|
+
expect(@b.to_s(:decimal_digits => 2)).to eq('2147843648.23')
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
data/spec/humanize/giga_spec.rb
CHANGED
@@ -45,7 +45,7 @@ describe Humanize::Giga do
|
|
45
45
|
context "#to_s" do
|
46
46
|
context 'without any specification' do
|
47
47
|
it "should return a float with all digits" do
|
48
|
-
expect(g.to_s).to eq(3.25)
|
48
|
+
expect(g.to_s).to eq('3.25')
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -55,7 +55,7 @@ describe Humanize::Giga do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should return a float with specified digits" do
|
58
|
-
expect(@g.to_s(:decimal_digits => 1)).to eq(3.2)
|
58
|
+
expect(@g.to_s(:decimal_digits => 1)).to eq('3.2')
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
data/spec/humanize/kilo_spec.rb
CHANGED
@@ -45,7 +45,7 @@ describe Humanize::Kilo do
|
|
45
45
|
context "#to_s" do
|
46
46
|
context 'without any specification' do
|
47
47
|
it "should return a float with all digits" do
|
48
|
-
expect(k.to_s).to eq(5000
|
48
|
+
expect(k.to_s).to eq('5000')
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -55,7 +55,7 @@ describe Humanize::Kilo do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should return a float with specified digits" do
|
58
|
-
expect(@k.to_s(:decimal_digits => 1)).to eq(2147843648.2)
|
58
|
+
expect(@k.to_s(:decimal_digits => 1)).to eq('2147843648.2')
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
data/spec/humanize/mega_spec.rb
CHANGED
@@ -45,13 +45,13 @@ describe Humanize::Mega do
|
|
45
45
|
context "#to_s" do
|
46
46
|
context 'without any specification' do
|
47
47
|
it "should return a float with all digits" do
|
48
|
-
expect(m.to_s).to eq(4.8828125)
|
48
|
+
expect(m.to_s).to eq('4.8828125')
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
context 'with decimal_digits specified' do
|
53
53
|
it "should return a float with specified digits" do
|
54
|
-
expect(m.to_s(:decimal_digits => 1)).to eq(4.9)
|
54
|
+
expect(m.to_s(:decimal_digits => 1)).to eq('4.9')
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: humanize-bytes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paulo Henrique Lopes Ribeiro
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description:
|
42
56
|
email: plribeiro3000@gmail.com
|
43
57
|
executables: []
|