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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 752c49ba346a3c44c84575d7c9342729666430e8
4
- data.tar.gz: 177308181d7d1a004ace9e3d7d1b3f341a074ac0
3
+ metadata.gz: 24efb7c5a6f63618a6cd3988dfbb28513b89ca7d
4
+ data.tar.gz: 76318b62fc23e62f3ab4ad605b4e5cc5d0679fd0
5
5
  SHA512:
6
- metadata.gz: 1b3736c481b79a3c1faa4e3187181a862a4861567166b30b8196b9966d7828d7f3d8a279c03c69453dda14f3f4124723df03389f396b16842e5d3ebe9ee096e5
7
- data.tar.gz: f11c8c2062a848b0d5fac52f05c8d9c86c8707f0fbb04772c83f324e906c903f347bce9072f55000c463e3757a7367fdf68d704655b3417e77329d11b28b548a
6
+ metadata.gz: 962f9763ab9f0ba52a3c3b1903be90c08a1d2111e382ece0db00f3fe08a01e8cb36761fb0dca828139e88fb1c01f40c8eda1be21d09ef91d876674095534f0f9
7
+ data.tar.gz: a409f99aede0565c349075817200296ab79e2765f78f63baa0ad98a39dbd0160df6efe2ec846aa1120d16a7c340341ff7145ca8dc04c8e26956cb7532a2c7bb7
@@ -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
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'coveralls', '>= 0.8.17', require: false
3
+ gem 'coveralls', '>= 0.8.20', require: false
4
4
 
5
5
  # JSON gem no longer supports ruby < 2.0.0
6
6
  if defined?(JRUBY_VERSION)
@@ -27,6 +27,7 @@ module Monetize
27
27
  'Fr' => 'CHF',
28
28
  'zł' => 'PLN',
29
29
  '₸' => 'KZT',
30
+ "₩" => 'KRW',
30
31
  }
31
32
 
32
33
  MULTIPLIER_SUFFIXES = {
@@ -2,6 +2,7 @@
2
2
 
3
3
  class Hash
4
4
  def to_money(currency = nil)
5
- Money.new(self[:cents], self[:currency] || currency || Money.default_currency)
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
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Monetize
4
- VERSION = '1.6.0'
4
+ VERSION = '1.7.0'
5
5
  end
@@ -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.8'
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.6.0
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-01-05 00:00:00.000000000 Z
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.8'
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.8'
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.5.1
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.