big_money 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 1
3
3
  :minor: 2
4
- :patch: 1
4
+ :patch: 2
5
5
  :build:
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "big_money"
8
- s.version = "1.2.1"
8
+ s.version = "1.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Shane Hanna", "Marshall Roch"]
12
- s.date = "2012-12-20"
12
+ s.date = "2012-12-21"
13
13
  s.description = "BigDecimal backed amount of money in a particular currency."
14
14
  s.email = ["shane.hanna@gmail.com", "mroch@cmu.edu"]
15
15
  s.extra_rdoc_files = [
@@ -86,6 +86,14 @@ class BigMoney
86
86
  amount.nonzero? && self
87
87
  end
88
88
 
89
+ def positive?
90
+ self > self.class.new(0, self.currency)
91
+ end
92
+
93
+ def negative?
94
+ self < self.class.new(0, self.currency)
95
+ end
96
+
89
97
  def <=>(money)
90
98
  money.kind_of?(self.class) ? (currency <=> money.currency).nonzero? || (amount <=> money.amount).nonzero? || 0 : nil
91
99
  end
@@ -100,6 +100,7 @@ class TestBigMoney < Test::Unit::TestCase
100
100
 
101
101
  should 'zero?' do
102
102
  assert_equal BigMoney.new(-1.05).zero?, false
103
+ assert_equal BigMoney.new(-1).zero?, false
103
104
  assert_equal BigMoney.new(0).zero?, true
104
105
  assert_equal BigMoney.new(0.0).zero?, true
105
106
  assert_equal BigMoney.new(1).zero?, false
@@ -108,11 +109,30 @@ class TestBigMoney < Test::Unit::TestCase
108
109
 
109
110
  should 'nonzero?' do
110
111
  assert_equal BigMoney.new(-1.05).nonzero?, BigMoney.new(-1.05)
112
+ assert_equal BigMoney.new(-1).nonzero?, BigMoney.new(-1)
111
113
  assert_equal BigMoney.new(0).nonzero?, nil
112
114
  assert_equal BigMoney.new(0.0).nonzero?, nil
113
115
  assert_equal BigMoney.new(1).nonzero?, BigMoney.new(1)
114
116
  assert_equal BigMoney.new(1.05).nonzero?, BigMoney.new(1.05)
115
117
  end
118
+
119
+ should 'negative?' do
120
+ assert_equal BigMoney.new(-1.05).negative?, true
121
+ assert_equal BigMoney.new(-1).negative?, true
122
+ assert_equal BigMoney.new(0).negative?, false
123
+ assert_equal BigMoney.new(0.0).negative?, false
124
+ assert_equal BigMoney.new(1).negative?, false
125
+ assert_equal BigMoney.new(1.05).negative?, false
126
+ end
127
+
128
+ should 'positive?' do
129
+ assert_equal BigMoney.new(-1.05).positive?, false
130
+ assert_equal BigMoney.new(-1).positive?, false
131
+ assert_equal BigMoney.new(0).positive?, false
132
+ assert_equal BigMoney.new(0.0).positive?, false
133
+ assert_equal BigMoney.new(1).positive?, true
134
+ assert_equal BigMoney.new(1.05).positive?, true
135
+ end
116
136
  end
117
137
 
118
138
  context 'serialization' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: big_money
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-12-20 00:00:00.000000000 Z
13
+ date: 2012-12-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: jeweler
@@ -138,7 +138,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
138
  version: '0'
139
139
  segments:
140
140
  - 0
141
- hash: -1594666296486135105
141
+ hash: 1256381880328552037
142
142
  required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  none: false
144
144
  requirements: