humanize-bytes 2.0.0 → 2.0.1

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
  SHA1:
3
- metadata.gz: f822f2ca03aaef2328c13d7695900d9a8c56a410
4
- data.tar.gz: ec6452119bbedd0ed6bf35d78904c0a35fb29081
3
+ metadata.gz: b822e696f285eb1cef5a3adc0a204264a9e18acf
4
+ data.tar.gz: b6a0b750bdb3063662be4e4c998cea19dfe767e8
5
5
  SHA512:
6
- metadata.gz: 2ccc4c753f4801f4fb244d3c5b758e52b44d27d93552e7772415222c0682ce34ab56f9297fa52202de8e070cf2a174263c9585bec206678a0fda646e1a353051
7
- data.tar.gz: 8bc447ae715d88ca0e1c7ceb7b93f184108cb94c2d9af77c1ac1f23df046aa0672b6ed061c004867fed50a6e0d669a13af61125c5c9152866689ab89b87c44d5
6
+ metadata.gz: 550886946965209414c1257ed751400961ce4454176b872e5b31775c350e429a0cbf14ec67eff914f4829c8ef97cf8896381c764eff3cf9ed3e231c8334b7464
7
+ data.tar.gz: 6745bafdf1844cc8f252f40243a4bacd2b2e39e2dc733742be0e41cb4ad16265ff447b2533c51df0835e729e5b4db7472175812e46336be48abab78771a82f45
@@ -19,4 +19,5 @@ Gem::Specification.new do |gem|
19
19
 
20
20
  gem.add_development_dependency 'rake'
21
21
  gem.add_development_dependency 'rspec'
22
+ gem.add_development_dependency 'pry'
22
23
  end
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, value.to_s.size)
29
- ("%.#{size}f" % value).to_f
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
@@ -1,5 +1,5 @@
1
1
  module Humanize
2
2
  class Bytes
3
- VERSION = '2.0.0'
3
+ VERSION = '2.0.1'
4
4
  end
5
5
  end
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, value.to_s.size)
29
- ("%.#{size}f" % value).to_f
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, value.to_s.size)
29
- ("%.#{size}f" % value).to_f
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, value.to_s.size)
29
- ("%.#{size}f" % value).to_f
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
@@ -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.0)
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
@@ -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
@@ -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.0)
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
@@ -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.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: []