monetize 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile +1 -1
- data/lib/monetize.rb +1 -0
- data/lib/monetize/core_extensions/hash.rb +2 -1
- data/lib/monetize/version.rb +1 -1
- data/monetize.gemspec +1 -1
- data/spec/core_extensions_spec.rb +16 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24efb7c5a6f63618a6cd3988dfbb28513b89ca7d
|
4
|
+
data.tar.gz: 76318b62fc23e62f3ab4ad605b4e5cc5d0679fd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 962f9763ab9f0ba52a3c3b1903be90c08a1d2111e382ece0db00f3fe08a01e8cb36761fb0dca828139e88fb1c01f40c8eda1be21d09ef91d876674095534f0f9
|
7
|
+
data.tar.gz: a409f99aede0565c349075817200296ab79e2765f78f63baa0ad98a39dbd0160df6efe2ec846aa1120d16a7c340341ff7145ca8dc04c8e26956cb7532a2c7bb7
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.7.0
|
4
|
+
- Money version updated to 6.9
|
5
|
+
- Coveralls version update to 0.8.20
|
6
|
+
- Add South Korean Won currency
|
7
|
+
- Improve conversion to Money from Hash
|
8
|
+
|
3
9
|
## 1.6.0
|
4
10
|
- Ruby 2.4.0 support
|
5
11
|
- Money version updated to 6.8
|
@@ -48,3 +54,4 @@
|
|
48
54
|
- Add rake console task
|
49
55
|
- Fix issue where parsing a Money object resulted in a Money object with its currency set to `Money.default_currency`,
|
50
56
|
rather than the currency that it was sent in as.
|
57
|
+
- Add South Korean Won currency
|
data/Gemfile
CHANGED
data/lib/monetize.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
class Hash
|
4
4
|
def to_money(currency = nil)
|
5
|
-
|
5
|
+
hash_currency = self[:currency].is_a?(Hash) ? self[:currency][:iso_code] : self[:currency]
|
6
|
+
Money.new(self[:cents] || self[:fractional], hash_currency || currency || Money.default_currency)
|
6
7
|
end
|
7
8
|
end
|
data/lib/monetize/version.rb
CHANGED
data/monetize.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
|
-
spec.add_dependency 'money', '~> 6.
|
22
|
+
spec.add_dependency 'money', '~> 6.9'
|
23
23
|
|
24
24
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
25
25
|
spec.add_development_dependency 'rake'
|
@@ -182,6 +182,14 @@ describe Monetize, 'core extensions' do
|
|
182
182
|
end
|
183
183
|
end
|
184
184
|
|
185
|
+
context 'when currency argument is a hash' do
|
186
|
+
subject(:hash) { {cents: 100, currency: {iso_code: 'EUR'}} }
|
187
|
+
|
188
|
+
it 'converts Hash to Money using iso_code from currency hash' do
|
189
|
+
expect(hash.to_money).to eq(Money.new(100, 'EUR'))
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
185
193
|
context 'when no currency is passed' do
|
186
194
|
subject(:hash) { {cents: 123} }
|
187
195
|
|
@@ -191,6 +199,14 @@ describe Monetize, 'core extensions' do
|
|
191
199
|
expect(hash.to_money('USD')).to eq(Money.new(123, 'USD'))
|
192
200
|
end
|
193
201
|
end
|
202
|
+
|
203
|
+
context "when key name is 'fractional'" do
|
204
|
+
subject(:hash) { {fractional: 100} }
|
205
|
+
|
206
|
+
it 'converts Hash to Money, interpreting fractional as cents' do
|
207
|
+
expect(hash.to_money).to eq(Money.new(100, 'USD'))
|
208
|
+
end
|
209
|
+
end
|
194
210
|
end
|
195
211
|
end
|
196
212
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monetize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane Emmons
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: money
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '6.
|
19
|
+
version: '6.9'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '6.
|
26
|
+
version: '6.9'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
119
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.
|
120
|
+
rubygems_version: 2.6.8
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: A library for converting various objects into `Money` objects.
|