monetize 1.9.3 → 1.9.4

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: 9bf6700b6d319c454fcc18dc2ffd9414bd565d5797b456ffbe4db4bd16aa4d53
4
- data.tar.gz: 11d999ec312805bed1f95b48f283d237785dffc6f64698a4b6c85f5a19f0d1d5
3
+ metadata.gz: 6268692fea7908fbc268790bf98cca9795df28eed380b07d2683eed6f5dad4d1
4
+ data.tar.gz: 8d795add425b915dc88ecf910505af69b7c1f340ae412083e4c230f0622c2e27
5
5
  SHA512:
6
- metadata.gz: 14414941fae908b1ef3e00c6c421f9572cafb159287d78816484dc7c1444078a294a058d9b718b82ecf8a0656db1ecb3f2304c807890d65575a19728c8df5159
7
- data.tar.gz: fa4bfdf4d423f36b36918d41bdb2e695e8b684c75e195445f01391a94c7d9610777241511a90b8a6165d03fb0fd1a32860e422b644825a80267187eeaa1390fc
6
+ metadata.gz: e4291ebf0a43a4bea5a2973186b1dca2d9d9fa08729acb956073efb2628d6898620f5eb1110ade3bba5dbac313894babd4ab59c0d1db92b8cb8e041974a0d402
7
+ data.tar.gz: 06d080183a460c5777b9f7443655bcb00d214ee18a6294f0838a3ac4bfec95715ab1ad5704001d286a6bc1ed0966a4a031942bd946ef9d249372ea527a120785
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.9.4
4
+ - Fix symbol parsing that are surrounded by other characters
5
+
3
6
  ## 1.9.3
4
7
  - Fix input parsing when currency symbol after the amount
5
8
 
@@ -82,8 +82,8 @@ module Monetize
82
82
  end
83
83
 
84
84
  def compute_currency
85
- matches = input.match(currency_symbol_regex)
86
- CURRENCY_SYMBOLS[matches[:symbol]] if matches
85
+ match = input.match(currency_symbol_regex)
86
+ CURRENCY_SYMBOLS[match.to_s] if match
87
87
  end
88
88
 
89
89
  def extract_major_minor(num, currency)
@@ -153,7 +153,7 @@ module Monetize
153
153
  end
154
154
 
155
155
  def currency_symbol_regex
156
- /(?<symbol>#{regex_safe_symbols})/
156
+ /(?<![A-Z])(#{regex_safe_symbols})(?![A-Z])/i
157
157
  end
158
158
  end
159
159
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Monetize
4
- VERSION = '1.9.3'
4
+ VERSION = '1.9.4'
5
5
  end
@@ -118,6 +118,11 @@ describe Monetize do
118
118
  expect(Monetize.parse('L9.99')).to eq Money.new(999, 'USD')
119
119
  end
120
120
 
121
+ it 'ignores ZAR symbols that is part of a text' do
122
+ expect(Monetize.parse('EUR 9.99')).to eq Money.new(999, 'EUR')
123
+ expect(Monetize.parse('9.99 EUR')).to eq Money.new(999, 'EUR')
124
+ end
125
+
121
126
  context 'negatives' do
122
127
  it 'ignores the ambiguous kr symbol' do
123
128
  # Could mean either of DKK, EEK, ISK, NOK, SEK
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monetize
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.3
4
+ version: 1.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane Emmons
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-01-01 00:00:00.000000000 Z
12
+ date: 2020-01-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: money