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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e6d46a5e6d4c8b7e1dec430cfeb98a98536bb336
4
- data.tar.gz: 523799519e83fca200b5d813a0ca010ab2ae090e
2
+ SHA256:
3
+ metadata.gz: 6268692fea7908fbc268790bf98cca9795df28eed380b07d2683eed6f5dad4d1
4
+ data.tar.gz: 8d795add425b915dc88ecf910505af69b7c1f340ae412083e4c230f0622c2e27
5
5
  SHA512:
6
- metadata.gz: a88d6ce931f8c0d37653c3067a76caa4be8f5adbc10d78e2c1ee5d8b8089163b38926506c5e1a3524192b3d7e745a22f1d48d9773570239ce11f5a0fc122ee1d
7
- data.tar.gz: d83465b93fdf95a3cb25ecfa805e694a775dab789766b046076948382cb01f64aeb78484b53e9afa60fd557a317fbfcd3ac51208559693c8196e9228a27c9ea6
6
+ metadata.gz: e4291ebf0a43a4bea5a2973186b1dca2d9d9fa08729acb956073efb2628d6898620f5eb1110ade3bba5dbac313894babd4ab59c0d1db92b8cb8e041974a0d402
7
+ data.tar.gz: 06d080183a460c5777b9f7443655bcb00d214ee18a6294f0838a3ac4bfec95715ab1ad5704001d286a6bc1ed0966a4a031942bd946ef9d249372ea527a120785
data/.travis.yml CHANGED
@@ -1,15 +1,18 @@
1
1
  sudo: false
2
- language: ruby
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.7
9
- - 2.4.4
10
- - 2.5.1
11
- - 2.6.0
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
@@ -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
- /\A[\+|\-]?(?<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.2'
4
+ VERSION = '1.9.4'
5
5
  end
@@ -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.2
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: 2019-07-06 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
@@ -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
- rubyforge_project:
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.