money_helper 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8fc38d5c4921667c0f06286f5058378d60658b3f991dd7a343f5ab597384560c
4
- data.tar.gz: c88db16a193d5674d9f902466aace23c8b7b1a0f71b89733589a05be7059049b
3
+ metadata.gz: 655460145cd04f3561bb2e212287b760bb0dd93c4eb97c5533a2d40b4aff8482
4
+ data.tar.gz: 904a30dd0a437daf2f93d411a3d65e456e41420af74943d716729594905df180
5
5
  SHA512:
6
- metadata.gz: 1c258cca4d8ac444695faedd9245d1f805bcb5534bcf6f864dffdcfe330bf8f54f6c10caf800e32c1c2621bc523f6277acde3821a16c6a11edf31b777cdbdc6b
7
- data.tar.gz: 8133b959081243c17b6d160ec72a802ed79648989c60ebaca8546a8509cc145b1148f89de4cc1e4ee89cc51459cc0e54fcf58f29a7d5fd412b4f1a93a85744fa
6
+ metadata.gz: b3cd552b0e52f2d0ff8fc2456598aa19931932609f46eaa89e896e08e5744f00279627cd58531c9113fc236bc457af6fa5101a38ea55206168e1a33e58f8c684
7
+ data.tar.gz: 4c1298bd61b4121c8e652afda3c4f4a7247bcd790a1450927b96d7cbe3c82aee73bcb4f971647be98e7aa83f15e842b4b3dccc0ac936dd6d49f61e54705cedc6
data/Appraisals CHANGED
@@ -13,7 +13,7 @@ appraise 'activesupport_61' do
13
13
  end
14
14
 
15
15
  appraise 'activesupport_edge' do
16
- git 'git://github.com/rails/rails.git' do
16
+ git 'https://github.com/rails/rails.git', branch: 'main' do
17
17
  gem 'activesupport', require: 'active_support'
18
18
  end
19
19
  end
data/CHANGELOG.md CHANGED
@@ -1,8 +1,12 @@
1
- ### 3.0.0 (Next)
1
+ ### 3.0.1 (Next)
2
2
 
3
- * [#27](https://github.com/artsy/money_helper/pull/27): Update `money_to_text` to pass `format` options to `Money#format` for additional features such as `no_cents` - [@agrberg](https://github.com/agrberg).
3
+ * [#29](https://github.com/artsy/money_helper/pull/29): Update `money_range_to_text` to receive `with_currency` parameter for optional ISO code printing - [@leamotta](https://github.com/leamotta).
4
4
  * Your contribution here.
5
5
 
6
+ ### 3.0.0 (2022-02-16)
7
+
8
+ * [#27](https://github.com/artsy/money_helper/pull/27): Update `money_to_text` to pass `format` options to `Money#format` for additional features such as `no_cents` - [@agrberg](https://github.com/agrberg).
9
+
6
10
  ### 2.0.0 (2021-09-20)
7
11
 
8
12
  #### Breaking Changes
@@ -4,7 +4,7 @@
4
4
 
5
5
  source 'http://rubygems.org'
6
6
 
7
- git 'git://github.com/rails/rails.git' do
7
+ git 'https://github.com/rails/rails.git', branch: 'main' do
8
8
  gem 'activesupport', require: 'active_support'
9
9
  end
10
10
 
data/lib/money_helper.rb CHANGED
@@ -70,17 +70,18 @@ module MoneyHelper
70
70
  # high: (Integer) amount in minor unit
71
71
  # currency: (String) optional ISO currency code, defaulting to USD
72
72
  # delimiter: (String) optional
73
- def self.money_range_to_text(low, high, currency: 'USD', delimiter: ' - ')
73
+ # with_currency: (Boolean) optional flag to include ISO currency code, defaulting to true
74
+ def self.money_range_to_text(low, high, currency: 'USD', delimiter: ' - ', with_currency: true)
74
75
  if low.blank? && high.blank?
75
76
  ''
76
77
  elsif low.blank?
77
- "Under #{money_to_text(high, currency: currency)}"
78
+ "Under #{money_to_text(high, currency: currency, with_currency: with_currency)}"
78
79
  elsif high.blank?
79
- "#{money_to_text(low, currency: currency)} and up"
80
+ "#{money_to_text(low, currency: currency, with_currency: with_currency)} and up"
80
81
  elsif low == high
81
- money_to_text(low, currency: currency)
82
+ money_to_text(low, currency: currency, with_currency: with_currency)
82
83
  else
83
- formatted_low = money_to_text(low, currency: currency)
84
+ formatted_low = money_to_text(low, currency: currency, with_currency: with_currency)
84
85
  formatted_high = money_to_text(high, currency: currency, with_currency: false, format: { symbol: false })
85
86
  [formatted_low, formatted_high].compact.join(delimiter)
86
87
  end
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MoneyHelper
4
- VERSION = '3.0.0'
4
+ VERSION = '3.0.1'
5
5
  end
@@ -205,18 +205,36 @@ describe MoneyHelper do
205
205
  expect(MoneyHelper.money_range_to_text(nil, 40_983_27, currency: 'USD')).to eql('Under USD $40,983.27')
206
206
  end
207
207
 
208
+ it "prefixes the text 'Under ' when low amount not given and omits ISO code when with_currency is false" do
209
+ expect(MoneyHelper.money_range_to_text(nil, 40_983_27, currency: 'USD', with_currency: false)).to eql('Under $40,983.27')
210
+ end
211
+
208
212
  it "appends the text ' and up' when high amount not given" do
209
213
  expect(MoneyHelper.money_range_to_text(30_175_93, nil, currency: 'USD')).to eql('USD $30,175.93 and up')
210
214
  end
211
215
 
216
+ it "appends the text ' and up' when high amount not given and omits ISO code when with_currency is false" do
217
+ expect(MoneyHelper.money_range_to_text(30_175_93, nil, currency: 'USD', with_currency: false)).to eql('$30,175.93 and up')
218
+ end
219
+
212
220
  it 'treats as a single price when low amount and high amount are identical' do
213
221
  expect(MoneyHelper.money_range_to_text(30_175_93, 30_175_93, currency: 'USD')).to eql('USD $30,175.93')
214
222
  end
215
223
 
224
+ it 'treats as a single price when low amount and high amount are identical and omits ISO code when with_currency is false' do
225
+ expect(MoneyHelper.money_range_to_text(30_175_93, 30_175_93, currency: 'USD', with_currency: false)).to eql('$30,175.93')
226
+ end
227
+
216
228
  it 'returns empty string when both amounts are nil' do
217
229
  expect(MoneyHelper.money_range_to_text(nil, nil, currency: 'USD')).to eql('')
218
230
  end
219
231
 
232
+ it 'omits ISO code when with_currency is false' do
233
+ expect(MoneyHelper.money_range_to_text(30_175_93, 40_983_27, currency: 'EUR', with_currency: false)).to eql('€30.175,93 - 40.983,27')
234
+ expect(MoneyHelper.money_range_to_text(30_175_93, 40_983_27, currency: 'AUD', with_currency: false)).to eql('$30,175.93 - 40,983.27')
235
+ expect(MoneyHelper.money_range_to_text(30_175_93, 40_983_27, currency: 'AMD', with_currency: false)).to eql('դր.30,175.93 - 40,983.27')
236
+ end
237
+
220
238
  it "raises an exception when currency can't be found" do
221
239
  expect do
222
240
  MoneyHelper.money_range_to_text(10_000, 20_000, currency: 'ITL')
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: money_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sahil Yakhmi
8
8
  - Joey Aghion
9
9
  - Matt Zikherman
10
10
  - Sarah Weir
11
- autorequire:
11
+ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2022-02-16 00:00:00.000000000 Z
14
+ date: 2023-03-21 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
@@ -102,7 +102,7 @@ homepage: https://github.com/artsy/money_helper
102
102
  licenses:
103
103
  - MIT
104
104
  metadata: {}
105
- post_install_message:
105
+ post_install_message:
106
106
  rdoc_options: []
107
107
  require_paths:
108
108
  - lib
@@ -117,8 +117,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  - !ruby/object:Gem::Version
118
118
  version: 1.3.6
119
119
  requirements: []
120
- rubygems_version: 3.2.27
121
- signing_key:
120
+ rubygems_version: 3.1.2
121
+ signing_key:
122
122
  specification_version: 4
123
123
  summary: MoneyHelper international price formatting utility.
124
124
  test_files: