monetize 1.9.2 → 1.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +8 -5
- data/CHANGELOG.md +6 -0
- data/lib/monetize/parser.rb +3 -3
- data/lib/monetize/version.rb +1 -1
- data/spec/monetize_spec.rb +9 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6268692fea7908fbc268790bf98cca9795df28eed380b07d2683eed6f5dad4d1
|
4
|
+
data.tar.gz: 8d795add425b915dc88ecf910505af69b7c1f340ae412083e4c230f0622c2e27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4291ebf0a43a4bea5a2973186b1dca2d9d9fa08729acb956073efb2628d6898620f5eb1110ade3bba5dbac313894babd4ab59c0d1db92b8cb8e041974a0d402
|
7
|
+
data.tar.gz: 06d080183a460c5777b9f7443655bcb00d214ee18a6294f0838a3ac4bfec95715ab1ad5704001d286a6bc1ed0966a4a031942bd946ef9d249372ea527a120785
|
data/.travis.yml
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
sudo: false
|
2
|
-
language:
|
2
|
+
language:
|
3
|
+
- ruby
|
4
|
+
- java
|
3
5
|
rvm:
|
4
6
|
- 1.9.3
|
5
7
|
- 2.0.0
|
6
8
|
- 2.1.10
|
7
9
|
- 2.2.10
|
8
|
-
- 2.3.
|
9
|
-
- 2.4.
|
10
|
-
- 2.5.
|
11
|
-
- 2.6.
|
10
|
+
- 2.3.8
|
11
|
+
- 2.4.6
|
12
|
+
- 2.5.5
|
13
|
+
- 2.6.3
|
12
14
|
- jruby-9.0.5.0
|
15
|
+
jdk: openjdk8
|
13
16
|
before_install:
|
14
17
|
- gem install bundler --version '~> 1.17'
|
15
18
|
script: bundle exec rspec spec
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.9.4
|
4
|
+
- Fix symbol parsing that are surrounded by other characters
|
5
|
+
|
6
|
+
## 1.9.3
|
7
|
+
- Fix input parsing when currency symbol after the amount
|
8
|
+
|
3
9
|
## 1.9.2
|
4
10
|
- Respect Money.rounding_mode when parsing strings
|
5
11
|
- Deprecate Monetize.extract_cents
|
data/lib/monetize/parser.rb
CHANGED
@@ -82,8 +82,8 @@ module Monetize
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def compute_currency
|
85
|
-
|
86
|
-
CURRENCY_SYMBOLS[
|
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
|
-
|
156
|
+
/(?<![A-Z])(#{regex_safe_symbols})(?![A-Z])/i
|
157
157
|
end
|
158
158
|
end
|
159
159
|
end
|
data/lib/monetize/version.rb
CHANGED
data/spec/monetize_spec.rb
CHANGED
@@ -70,6 +70,10 @@ describe Monetize do
|
|
70
70
|
expect(Monetize.parse("#{symbol}#{amount_in_units}")).to eq Money.new(amount, iso_code)
|
71
71
|
end
|
72
72
|
|
73
|
+
it "parses formatted inputs with #{iso_code} symbol is after the amount" do
|
74
|
+
expect(Monetize.parse("#{amount_in_units}#{symbol}")).to eq Money.new(amount, iso_code)
|
75
|
+
end
|
76
|
+
|
73
77
|
context 'prefix' do
|
74
78
|
it 'parses formatted inputs with plus sign and currency as a symbol' do
|
75
79
|
expect(Monetize.parse("+#{symbol}#{amount_in_units}")).to eq Money.new(amount, iso_code)
|
@@ -114,6 +118,11 @@ describe Monetize do
|
|
114
118
|
expect(Monetize.parse('L9.99')).to eq Money.new(999, 'USD')
|
115
119
|
end
|
116
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
|
+
|
117
126
|
context 'negatives' do
|
118
127
|
it 'ignores the ambiguous kr symbol' do
|
119
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.
|
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:
|
12
|
+
date: 2020-01-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: money
|
@@ -122,8 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
122
|
- !ruby/object:Gem::Version
|
123
123
|
version: '0'
|
124
124
|
requirements: []
|
125
|
-
|
126
|
-
rubygems_version: 2.6.8
|
125
|
+
rubygems_version: 3.0.3
|
127
126
|
signing_key:
|
128
127
|
specification_version: 4
|
129
128
|
summary: A library for converting various objects into `Money` objects.
|