monetize 1.9.4 → 1.10.0
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 +4 -4
- data/.github/workflows/ruby.yml +34 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +0 -2
- data/README.md +0 -1
- data/lib/monetize/parser.rb +3 -2
- data/lib/monetize/version.rb +1 -1
- data/spec/core_extensions_spec.rb +2 -2
- data/spec/monetize_spec.rb +4 -0
- data/spec/spec_helper.rb +0 -2
- metadata +6 -7
- data/.coveralls.yml +0 -1
- data/.travis.yml +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63f57158028647c2bde5bac4c2186e16e9a3874d6c6d756b08e091d1357fcfcc
|
4
|
+
data.tar.gz: 5dd093ceef480ffd21fbfaa3a0912cdc7421f797c4570a2a8bde9665534aa6ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b4001dd8967421873f84b9b0201bd0985d1388d89c41c2c048498db185cd2d4bdd144c581293fff70e34c5fb88aecbf68f2e3d2d086f1f278f58047e519aebe
|
7
|
+
data.tar.gz: 468cc1fd1f127eb570e8599ef20309240f5e95c5731374848c663995d4935e4bb6773ffd40691d2bd4148c58e51e641806a3d7a97d25851a5877bc74621fe059
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ master ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ master ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
strategy:
|
21
|
+
matrix:
|
22
|
+
ruby-version: ['2.6', '2.7', '3.0']
|
23
|
+
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@v2
|
26
|
+
- name: Set up Ruby
|
27
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
28
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
29
|
+
uses: ruby/setup-ruby@v1
|
30
|
+
with:
|
31
|
+
ruby-version: ${{ matrix.ruby-version }}
|
32
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
33
|
+
- name: Run tests
|
34
|
+
run: bundle exec rspec spec
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.10.0
|
4
|
+
- When using the `assume_from_symbol` option, the currency in the input string will be used over the assumed currency based on symbol. For example, `$1.05 CAD` will use `CAD` instead of `USD`.
|
5
|
+
|
3
6
|
## 1.9.4
|
4
7
|
- Fix symbol parsing that are surrounded by other characters
|
5
8
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
[](http://badge.fury.io/rb/monetize)
|
4
4
|
[](https://travis-ci.org/RubyMoney/monetize)
|
5
5
|
[](https://codeclimate.com/github/RubyMoney/monetize)
|
6
|
-
[](https://coveralls.io/r/RubyMoney/monetize)
|
7
6
|
[](https://gemnasium.com/RubyMoney/monetize)
|
8
7
|
[](http://opensource.org/licenses/MIT)
|
9
8
|
|
data/lib/monetize/parser.rb
CHANGED
@@ -63,8 +63,9 @@ module Monetize
|
|
63
63
|
|
64
64
|
def parse_currency
|
65
65
|
computed_currency = nil
|
66
|
-
computed_currency =
|
67
|
-
computed_currency ||=
|
66
|
+
computed_currency = input[/[A-Z]{2,3}/]
|
67
|
+
computed_currency ||= compute_currency if assume_from_symbol?
|
68
|
+
|
68
69
|
|
69
70
|
computed_currency || fallback_currency || Money.default_currency
|
70
71
|
end
|
data/lib/monetize/version.rb
CHANGED
@@ -7,7 +7,7 @@ require 'monetize/core_extensions'
|
|
7
7
|
describe Monetize, 'core extensions' do
|
8
8
|
describe NilClass do
|
9
9
|
describe '#to_money' do
|
10
|
-
it '
|
10
|
+
it 'works as documented' do
|
11
11
|
money = nil.to_money
|
12
12
|
expect(money.cents).to eq 0
|
13
13
|
expect(money.currency).to eq Money.default_currency
|
@@ -22,7 +22,7 @@ describe Monetize, 'core extensions' do
|
|
22
22
|
|
23
23
|
describe Numeric do
|
24
24
|
describe '#to_money' do
|
25
|
-
it '
|
25
|
+
it 'works as documented' do
|
26
26
|
money = 1234.to_money
|
27
27
|
expect(money.cents).to eq 1_234_00
|
28
28
|
expect(money.currency).to eq Money.default_currency
|
data/spec/monetize_spec.rb
CHANGED
@@ -118,6 +118,10 @@ describe Monetize do
|
|
118
118
|
expect(Monetize.parse('L9.99')).to eq Money.new(999, 'USD')
|
119
119
|
end
|
120
120
|
|
121
|
+
it 'should use provided currency over symbol' do
|
122
|
+
expect(Monetize.parse('$1.05 CAD')).to eq Money.new(105, 'CAD')
|
123
|
+
end
|
124
|
+
|
121
125
|
it 'ignores ZAR symbols that is part of a text' do
|
122
126
|
expect(Monetize.parse('EUR 9.99')).to eq Money.new(999, 'EUR')
|
123
127
|
expect(Monetize.parse('9.99 EUR')).to eq Money.new(999, 'EUR')
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monetize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane Emmons
|
8
8
|
- Anthony Dmitriyev
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-01-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: money
|
@@ -75,10 +75,9 @@ executables: []
|
|
75
75
|
extensions: []
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
|
-
- ".
|
78
|
+
- ".github/workflows/ruby.yml"
|
79
79
|
- ".gitignore"
|
80
80
|
- ".rubocop.yml"
|
81
|
-
- ".travis.yml"
|
82
81
|
- CHANGELOG.md
|
83
82
|
- CONTRIBUTING.md
|
84
83
|
- Gemfile
|
@@ -107,7 +106,7 @@ metadata:
|
|
107
106
|
changelog_uri: https://github.com/RubyMoney/monetize/blob/master/CHANGELOG.md
|
108
107
|
source_code_uri: https://github.com/RubyMoney/monetize/
|
109
108
|
bug_tracker_uri: https://github.com/RubyMoney/monetize/issues
|
110
|
-
post_install_message:
|
109
|
+
post_install_message:
|
111
110
|
rdoc_options: []
|
112
111
|
require_paths:
|
113
112
|
- lib
|
@@ -123,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
122
|
version: '0'
|
124
123
|
requirements: []
|
125
124
|
rubygems_version: 3.0.3
|
126
|
-
signing_key:
|
125
|
+
signing_key:
|
127
126
|
specification_version: 4
|
128
127
|
summary: A library for converting various objects into `Money` objects.
|
129
128
|
test_files:
|
data/.coveralls.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
repo_token: pbKErt5rAW1iRYGMIAGGAAHfVRmiBzxfd
|
data/.travis.yml
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
language:
|
3
|
-
- ruby
|
4
|
-
- java
|
5
|
-
rvm:
|
6
|
-
- 1.9.3
|
7
|
-
- 2.0.0
|
8
|
-
- 2.1.10
|
9
|
-
- 2.2.10
|
10
|
-
- 2.3.8
|
11
|
-
- 2.4.6
|
12
|
-
- 2.5.5
|
13
|
-
- 2.6.3
|
14
|
-
- jruby-9.0.5.0
|
15
|
-
jdk: openjdk8
|
16
|
-
before_install:
|
17
|
-
- gem install bundler --version '~> 1.17'
|
18
|
-
script: bundle exec rspec spec
|
19
|
-
notifications:
|
20
|
-
recipients:
|
21
|
-
- shane@emmons.io
|