satoshi-unit 0.1.3 → 0.1.4

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: bdb279ef09cb9e4937e2dcedbfef5d78c4588de2
4
- data.tar.gz: cd8a2c2b8924a4a2ab4f75cc61aee5bf2916c941
3
+ metadata.gz: 41cb4c206a9417270a6817b02ded0a24497ae265
4
+ data.tar.gz: 5b925bc1994bee512ba7ac3e825f5a7529c10891
5
5
  SHA512:
6
- metadata.gz: 832af23c57375567304fef946768d11d8b927c7ec9b2b76947af7f5a17500736137e18156662b47287c703923f3b5589798df683564b68665406b25cc690cc1b
7
- data.tar.gz: dd116f5d126fc000a6a947d405bd17c98e955998c741d48b2d07546bfa4bf67ba07fc92be5a167b4afb9a9653cafd3c9cea2192430e4e581bda0852033a051ae
6
+ metadata.gz: 5bd17a21670a36c6962c9f4efd39e0548b53275ed857e20a623f7ca1bdaadf4321ea0be7f1d8a0b518c221046b63b74b7c9f9eb932775188fd8507efd62607c2
7
+ data.tar.gz: f0b4f142b6ac14735f79f81cb4acdfce57d530d505ba8dc86df29fef02a6c6a6d3e4cce9e6968db08d60c4b21710c80d6baca4b7f38e8f14c2e8a010d90fcadf
@@ -8,7 +8,7 @@ GEM
8
8
  diff-lcs (1.2.5)
9
9
  faraday (0.9.0)
10
10
  multipart-post (>= 1.2, < 3)
11
- git (1.2.6)
11
+ git (1.2.7)
12
12
  github_api (0.11.3)
13
13
  addressable (~> 2.3)
14
14
  descendants_tracker (~> 0.0.1)
@@ -17,7 +17,7 @@ GEM
17
17
  multi_json (>= 1.7.5, < 2.0)
18
18
  nokogiri (~> 1.6.0)
19
19
  oauth2
20
- hashie (2.1.1)
20
+ hashie (3.1.0)
21
21
  highline (1.6.21)
22
22
  jeweler (2.0.1)
23
23
  builder
@@ -46,15 +46,19 @@ GEM
46
46
  rake (10.3.2)
47
47
  rdoc (4.1.1)
48
48
  json (~> 1.4)
49
- rspec (2.14.1)
50
- rspec-core (~> 2.14.0)
51
- rspec-expectations (~> 2.14.0)
52
- rspec-mocks (~> 2.14.0)
53
- rspec-core (2.14.8)
54
- rspec-expectations (2.14.5)
55
- diff-lcs (>= 1.1.3, < 2.0)
56
- rspec-mocks (2.14.6)
57
- thread_safe (0.3.3)
49
+ rspec (3.0.0)
50
+ rspec-core (~> 3.0.0)
51
+ rspec-expectations (~> 3.0.0)
52
+ rspec-mocks (~> 3.0.0)
53
+ rspec-core (3.0.2)
54
+ rspec-support (~> 3.0.0)
55
+ rspec-expectations (3.0.2)
56
+ diff-lcs (>= 1.2.0, < 2.0)
57
+ rspec-support (~> 3.0.0)
58
+ rspec-mocks (3.0.2)
59
+ rspec-support (~> 3.0.0)
60
+ rspec-support (3.0.2)
61
+ thread_safe (0.3.4)
58
62
 
59
63
  PLATFORMS
60
64
  ruby
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -89,13 +89,15 @@ class Satoshi
89
89
  private
90
90
 
91
91
  def to_denomination(digits_after_delimiter)
92
- return @value if digits_after_delimiter <= 0
93
- leading_zeros = "0"*(18-@value.to_s.length)
94
- result = leading_zeros + @value.to_s
92
+ sign = @value < 0 ? -1 : 1
93
+ val = @value.abs
94
+ return val if digits_after_delimiter <= 0
95
+ leading_zeros = "0"*(18-val.to_s.length)
96
+ result = leading_zeros + val.to_s
95
97
  result.reverse!
96
98
  result = result.slice(0..digits_after_delimiter-1) + '.' + result.slice(digits_after_delimiter..17)
97
99
  result.reverse!
98
- result.sub(/\A0*/, '').sub(/0*\Z/, '').to_f # remove zeros on both sides
100
+ result.sub(/\A0*/, '').sub(/0*\Z/, '').to_f*sign # remove zeros on both sides
99
101
  end
100
102
 
101
103
  def convert_to_satoshi(n)
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: satoshi-unit 0.1.3 ruby lib
5
+ # stub: satoshi-unit 0.1.4 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "satoshi-unit"
9
- s.version = "0.1.3"
9
+ s.version = "0.1.4"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Roman Snitko"]
14
- s.date = "2014-06-02"
14
+ s.date = "2014-07-04"
15
15
  s.description = "Converts various bitcoin denominations in Satoshis and back"
16
16
  s.email = "roman.snitko@gmail.com"
17
17
  s.extra_rdoc_files = [
@@ -30,9 +30,13 @@ describe Satoshi do
30
30
  end
31
31
 
32
32
  it "treats nil in value as 0" do
33
- expect(Satoshi.new < 1).to be_true
34
- expect(Satoshi.new > 1).to be_false
35
- expect(Satoshi.new == 0).to be_true
33
+ expect(Satoshi.new < 1).to be_truthy
34
+ expect(Satoshi.new > 1).to be_falsy
35
+ expect(Satoshi.new == 0).to be_truthy
36
+ end
37
+
38
+ it "converts negative values correctly" do
39
+ expect(Satoshi.new(-1.00, unit: :mbtc).to_btc).to eq(-0.001)
36
40
  end
37
41
 
38
42
  end
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: satoshi-unit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Snitko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-02 00:00:00.000000000 Z
11
+ date: 2014-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: jeweler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.0.1
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.0.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: Converts various bitcoin denominations in Satoshis and back
@@ -60,8 +60,8 @@ extra_rdoc_files:
60
60
  - LICENSE.txt
61
61
  - README.md
62
62
  files:
63
- - .document
64
- - .rspec
63
+ - ".document"
64
+ - ".rspec"
65
65
  - Gemfile
66
66
  - Gemfile.lock
67
67
  - LICENSE.txt
@@ -82,12 +82,12 @@ require_paths:
82
82
  - lib
83
83
  required_ruby_version: !ruby/object:Gem::Requirement
84
84
  requirements:
85
- - - '>='
85
+ - - ">="
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0'
88
88
  required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  requirements:
90
- - - '>='
90
+ - - ">="
91
91
  - !ruby/object:Gem::Version
92
92
  version: '0'
93
93
  requirements: []