money-heuristics 0.1.0 → 1.0.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 +5 -5
- data/CHANGELOG.md +11 -0
- data/LICENSE +17 -17
- data/README.md +19 -3
- data/lib/money-heuristics/analyzer.rb +14 -5
- data/lib/money-heuristics/heuristics.rb +2 -2
- data/lib/money-heuristics/version.rb +3 -1
- data/lib/money-heuristics.rb +2 -0
- data/money-heuristics.gemspec +17 -13
- metadata +19 -84
- data/.coveralls.yml +0 -1
- data/.gitignore +0 -23
- data/.rspec +0 -1
- data/.travis.yml +0 -25
- data/CONTRIBUTING.md +0 -17
- data/Gemfile +0 -6
- data/Rakefile +0 -17
- data/spec/heuristics_spec.rb +0 -162
- data/spec/spec_helper.rb +0 -28
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 43353ad87ea39e31b2e4a3278a59e7d47b303a7209480db6a6bd08db180326ac
|
|
4
|
+
data.tar.gz: 6588ecd66f5bf131f7352ff0d4f74955c7395de2763e222f95d70b85ce67674e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e7a87e77124733d3bd59b79f83d2fe7aada1867b829bbaa475bc47fd5190b9ffccc697633579af570b01668ed75232281402c7796bb718ae33795a81de645ea7
|
|
7
|
+
data.tar.gz: efba2e13e679b0e3775b4213206d8b6bc63d0962a6862d66a21459a7a48caad3eb4a16aad063c766ebd65d2d014c72b76ee7ef4b534520db2566191974dfd15c
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
## 1.0.0
|
|
6
|
+
|
|
7
|
+
- **Breaking change:** Update Money gem dependency to ~> 7.0. See the [Money 7.0 upgrading guide](https://github.com/RubyMoney/money/blob/main/UPGRADING-7.0.md)
|
|
8
|
+
- **Breaking change:** Drop support for Ruby < 3.1
|
|
9
|
+
|
|
10
|
+
## 0.1.1
|
|
11
|
+
|
|
12
|
+
- Bumped money dependency to >= 6.9.0
|
|
13
|
+
|
|
3
14
|
## 0.1.0
|
|
4
15
|
|
|
5
16
|
- Refactored code
|
data/LICENSE
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
MIT License
|
|
2
2
|
|
|
3
3
|
Copyright (c) 2005 Tobias Lutke
|
|
4
4
|
Copyright (c) 2008 Phusion
|
|
5
|
+
Copyright (c) 2025 Shane Emmons
|
|
5
6
|
|
|
6
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
the following conditions:
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
13
|
|
|
14
|
-
The above copyright notice and this permission notice shall be
|
|
15
|
-
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
16
|
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
OF
|
|
23
|
-
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
data/README.md
CHANGED
|
@@ -4,9 +4,25 @@ This is a module for heuristic analysis of the string input for the
|
|
|
4
4
|
[money gem](https://github.com/RubyMoney/money). It was formerly part of the gem.
|
|
5
5
|
|
|
6
6
|
[](https://rubygems.org/gems/money-heuristics)
|
|
7
|
-
[](https://github.com/RubyMoney/money-heuristics/actions/workflows/ruby.yml)
|
|
8
|
+
[](https://opensource.org/license/MIT)
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
Include this line in your `Gemfile`:
|
|
13
|
+
|
|
14
|
+
```ruby
|
|
15
|
+
gem 'money-heuristics'
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```ruby
|
|
21
|
+
>> Money::Currency.analyze 'USD 200'
|
|
22
|
+
=> ["USD"]
|
|
23
|
+
>> Money::Currency.analyze 'zł123,000.50'
|
|
24
|
+
=> ["PLN"]
|
|
25
|
+
```
|
|
10
26
|
|
|
11
27
|
## Contributing
|
|
12
28
|
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
module MoneyHeuristics
|
|
2
2
|
class Analyzer
|
|
3
3
|
attr_reader :search_tree, :words
|
|
4
|
-
attr_accessor :str, :currencies
|
|
4
|
+
attr_accessor :str, :currencies, :methods
|
|
5
5
|
|
|
6
6
|
def initialize(str, search_tree)
|
|
7
7
|
@str = (str || '').dup
|
|
8
8
|
@search_tree = search_tree
|
|
9
9
|
@currencies = []
|
|
10
|
+
@methods = { iso_code: :search_by_iso_code,
|
|
11
|
+
symbol: :search_by_symbol,
|
|
12
|
+
name: :search_by_name }
|
|
10
13
|
end
|
|
11
14
|
|
|
12
|
-
def process
|
|
15
|
+
def process(filters)
|
|
13
16
|
format
|
|
14
17
|
return [] if str.empty?
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
search_by_iso_code
|
|
18
|
-
search_by_name
|
|
19
|
+
filter_methods(filters).each { |method| send(method) }
|
|
19
20
|
|
|
20
21
|
prepare_reply
|
|
21
22
|
end
|
|
@@ -80,5 +81,13 @@ module MoneyHeuristics
|
|
|
80
81
|
codes.sort!
|
|
81
82
|
codes
|
|
82
83
|
end
|
|
84
|
+
|
|
85
|
+
def filter_methods(filters)
|
|
86
|
+
filtered = methods.values_at(*filters).compact
|
|
87
|
+
|
|
88
|
+
return methods.values if filtered.empty?
|
|
89
|
+
|
|
90
|
+
filtered
|
|
91
|
+
end
|
|
83
92
|
end
|
|
84
93
|
end
|
|
@@ -10,10 +10,10 @@ module MoneyHeuristics
|
|
|
10
10
|
# currency in an entire sentence
|
|
11
11
|
#
|
|
12
12
|
# Returns: Array (matched results)
|
|
13
|
-
def analyze(str)
|
|
13
|
+
def analyze(str, filters: [])
|
|
14
14
|
@_heuristics_search_tree ||= MoneyHeuristics::SearchTree.new(table).build
|
|
15
15
|
|
|
16
|
-
return MoneyHeuristics::Analyzer.new(str, @_heuristics_search_tree).process
|
|
16
|
+
return MoneyHeuristics::Analyzer.new(str, @_heuristics_search_tree).process(filters)
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
end
|
data/lib/money-heuristics.rb
CHANGED
data/money-heuristics.gemspec
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
5
|
|
|
4
6
|
require "money-heuristics/version"
|
|
@@ -7,23 +9,25 @@ Gem::Specification.new do |s|
|
|
|
7
9
|
s.name = "money-heuristics"
|
|
8
10
|
s.version = MoneyHeuristics::VERSION
|
|
9
11
|
s.platform = Gem::Platform::RUBY
|
|
10
|
-
s.authors = ['Shane Emmons']
|
|
11
|
-
s.email = ['shane@emmons.io']
|
|
12
|
+
s.authors = ['Shane Emmons', 'Anthony Dmitriyev']
|
|
13
|
+
s.email = ['shane@emmons.io', 'anthony.dmitriyev@gmail.com']
|
|
12
14
|
s.homepage = 'https://rubymoney.github.io/money-heuristics'
|
|
13
|
-
s.summary = 'Heuristic module for
|
|
14
|
-
s.description = '
|
|
15
|
+
s.summary = 'Heuristic module for the money gem'
|
|
16
|
+
s.description = 'Heuristic module for analyzing currency information from strings for the money gem. It was formerly part of the money gem.'
|
|
15
17
|
s.license = 'MIT'
|
|
16
18
|
|
|
17
|
-
s.add_dependency 'money', '>= 6.8.2'
|
|
18
19
|
s.add_dependency 'sixarm_ruby_unaccent', ['>= 1.1.1', '< 2']
|
|
20
|
+
s.add_dependency 'money', '~> 7.0'
|
|
19
21
|
|
|
20
|
-
s.
|
|
21
|
-
s.add_development_dependency "rake"
|
|
22
|
-
s.add_development_dependency "rspec", "~> 3.4.0"
|
|
23
|
-
s.add_development_dependency "yard", "~> 0.8"
|
|
22
|
+
s.required_ruby_version = ">= 3.1"
|
|
24
23
|
|
|
25
|
-
s.files = `git ls-files`.split(
|
|
26
|
-
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
27
|
-
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
|
24
|
+
s.files = `git ls-files -z -- lib/* CHANGELOG.md LICENSE money-heuristics.gemspec README.md`.split("\x0")
|
|
28
25
|
s.require_paths = ["lib"]
|
|
26
|
+
|
|
27
|
+
if s.respond_to?(:metadata)
|
|
28
|
+
s.metadata["changelog_uri"] = "https://github.com/RubyMoney/money-heuristics/blob/main/CHANGELOG.md"
|
|
29
|
+
s.metadata["source_code_uri"] = "https://github.com/RubyMoney/money-heuristics/"
|
|
30
|
+
s.metadata["bug_tracker_uri"] = "https://github.com/RubyMoney/money-heuristics/issues"
|
|
31
|
+
s.metadata["rubygems_mfa_required"] = "true"
|
|
32
|
+
end
|
|
29
33
|
end
|
metadata
CHANGED
|
@@ -1,29 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: money-heuristics
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shane Emmons
|
|
8
|
-
|
|
8
|
+
- Anthony Dmitriyev
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: money
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - ">="
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: 6.8.2
|
|
20
|
-
type: :runtime
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - ">="
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: 6.8.2
|
|
27
13
|
- !ruby/object:Gem::Dependency
|
|
28
14
|
name: sixarm_ruby_unaccent
|
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -45,79 +31,31 @@ dependencies:
|
|
|
45
31
|
- !ruby/object:Gem::Version
|
|
46
32
|
version: '2'
|
|
47
33
|
- !ruby/object:Gem::Dependency
|
|
48
|
-
name:
|
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
|
50
|
-
requirements:
|
|
51
|
-
- - "~>"
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: '1.3'
|
|
54
|
-
type: :development
|
|
55
|
-
prerelease: false
|
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
-
requirements:
|
|
58
|
-
- - "~>"
|
|
59
|
-
- !ruby/object:Gem::Version
|
|
60
|
-
version: '1.3'
|
|
61
|
-
- !ruby/object:Gem::Dependency
|
|
62
|
-
name: rake
|
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
|
64
|
-
requirements:
|
|
65
|
-
- - ">="
|
|
66
|
-
- !ruby/object:Gem::Version
|
|
67
|
-
version: '0'
|
|
68
|
-
type: :development
|
|
69
|
-
prerelease: false
|
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
71
|
-
requirements:
|
|
72
|
-
- - ">="
|
|
73
|
-
- !ruby/object:Gem::Version
|
|
74
|
-
version: '0'
|
|
75
|
-
- !ruby/object:Gem::Dependency
|
|
76
|
-
name: rspec
|
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
|
78
|
-
requirements:
|
|
79
|
-
- - "~>"
|
|
80
|
-
- !ruby/object:Gem::Version
|
|
81
|
-
version: 3.4.0
|
|
82
|
-
type: :development
|
|
83
|
-
prerelease: false
|
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
85
|
-
requirements:
|
|
86
|
-
- - "~>"
|
|
87
|
-
- !ruby/object:Gem::Version
|
|
88
|
-
version: 3.4.0
|
|
89
|
-
- !ruby/object:Gem::Dependency
|
|
90
|
-
name: yard
|
|
34
|
+
name: money
|
|
91
35
|
requirement: !ruby/object:Gem::Requirement
|
|
92
36
|
requirements:
|
|
93
37
|
- - "~>"
|
|
94
38
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: '0
|
|
96
|
-
type: :
|
|
39
|
+
version: '7.0'
|
|
40
|
+
type: :runtime
|
|
97
41
|
prerelease: false
|
|
98
42
|
version_requirements: !ruby/object:Gem::Requirement
|
|
99
43
|
requirements:
|
|
100
44
|
- - "~>"
|
|
101
45
|
- !ruby/object:Gem::Version
|
|
102
|
-
version: '0
|
|
103
|
-
description:
|
|
104
|
-
gem. It was formerly part of the gem.
|
|
46
|
+
version: '7.0'
|
|
47
|
+
description: Heuristic module for analyzing currency information from strings for
|
|
48
|
+
the money gem. It was formerly part of the money gem.
|
|
105
49
|
email:
|
|
106
50
|
- shane@emmons.io
|
|
51
|
+
- anthony.dmitriyev@gmail.com
|
|
107
52
|
executables: []
|
|
108
53
|
extensions: []
|
|
109
54
|
extra_rdoc_files: []
|
|
110
55
|
files:
|
|
111
|
-
- ".coveralls.yml"
|
|
112
|
-
- ".gitignore"
|
|
113
|
-
- ".rspec"
|
|
114
|
-
- ".travis.yml"
|
|
115
56
|
- CHANGELOG.md
|
|
116
|
-
- CONTRIBUTING.md
|
|
117
|
-
- Gemfile
|
|
118
57
|
- LICENSE
|
|
119
58
|
- README.md
|
|
120
|
-
- Rakefile
|
|
121
59
|
- lib/money-heuristics.rb
|
|
122
60
|
- lib/money-heuristics/analyzer.rb
|
|
123
61
|
- lib/money-heuristics/heuristics.rb
|
|
@@ -125,13 +63,14 @@ files:
|
|
|
125
63
|
- lib/money-heuristics/string.rb
|
|
126
64
|
- lib/money-heuristics/version.rb
|
|
127
65
|
- money-heuristics.gemspec
|
|
128
|
-
- spec/heuristics_spec.rb
|
|
129
|
-
- spec/spec_helper.rb
|
|
130
66
|
homepage: https://rubymoney.github.io/money-heuristics
|
|
131
67
|
licenses:
|
|
132
68
|
- MIT
|
|
133
|
-
metadata:
|
|
134
|
-
|
|
69
|
+
metadata:
|
|
70
|
+
changelog_uri: https://github.com/RubyMoney/money-heuristics/blob/main/CHANGELOG.md
|
|
71
|
+
source_code_uri: https://github.com/RubyMoney/money-heuristics/
|
|
72
|
+
bug_tracker_uri: https://github.com/RubyMoney/money-heuristics/issues
|
|
73
|
+
rubygems_mfa_required: 'true'
|
|
135
74
|
rdoc_options: []
|
|
136
75
|
require_paths:
|
|
137
76
|
- lib
|
|
@@ -139,18 +78,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
139
78
|
requirements:
|
|
140
79
|
- - ">="
|
|
141
80
|
- !ruby/object:Gem::Version
|
|
142
|
-
version: '
|
|
81
|
+
version: '3.1'
|
|
143
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
83
|
requirements:
|
|
145
84
|
- - ">="
|
|
146
85
|
- !ruby/object:Gem::Version
|
|
147
86
|
version: '0'
|
|
148
87
|
requirements: []
|
|
149
|
-
|
|
150
|
-
rubygems_version: 2.6.8
|
|
151
|
-
signing_key:
|
|
88
|
+
rubygems_version: 4.0.0
|
|
152
89
|
specification_version: 4
|
|
153
|
-
summary: Heuristic module for
|
|
154
|
-
test_files:
|
|
155
|
-
- spec/heuristics_spec.rb
|
|
156
|
-
- spec/spec_helper.rb
|
|
90
|
+
summary: Heuristic module for the money gem
|
|
91
|
+
test_files: []
|
data/.coveralls.yml
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
repo_token: m7vyhHNz7HTqdYSL90YbygyYNMQ2JO9E2
|
data/.gitignore
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# Bundler
|
|
2
|
-
.bundle
|
|
3
|
-
Gemfile.lock
|
|
4
|
-
pkg/*
|
|
5
|
-
bin/
|
|
6
|
-
|
|
7
|
-
# Rubinius
|
|
8
|
-
*.rbc
|
|
9
|
-
|
|
10
|
-
# YARD
|
|
11
|
-
.yardoc
|
|
12
|
-
yardoc/
|
|
13
|
-
doc/
|
|
14
|
-
|
|
15
|
-
# Project
|
|
16
|
-
.rbenv-version
|
|
17
|
-
.rbx
|
|
18
|
-
.rvmrc
|
|
19
|
-
.ruby-version
|
|
20
|
-
.ruby-gemset
|
|
21
|
-
|
|
22
|
-
# Spec artifacts
|
|
23
|
-
/coverage
|
data/.rspec
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
--require spec_helper
|
data/.travis.yml
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
language: ruby
|
|
2
|
-
sudo: false
|
|
3
|
-
rvm:
|
|
4
|
-
- 2.0.0
|
|
5
|
-
- 2.1.10
|
|
6
|
-
- 2.2.5
|
|
7
|
-
- 2.3.1
|
|
8
|
-
- 2.4.0
|
|
9
|
-
- rbx-2
|
|
10
|
-
- jruby-9.0.5.0
|
|
11
|
-
- jruby-9.1.2.0
|
|
12
|
-
- ruby-head
|
|
13
|
-
- jruby-head
|
|
14
|
-
matrix:
|
|
15
|
-
allow_failures:
|
|
16
|
-
- rvm: ruby-head
|
|
17
|
-
- rvm: jruby-head
|
|
18
|
-
- rvm: rbx-2
|
|
19
|
-
fast_finish: true
|
|
20
|
-
script: bundle exec rspec spec
|
|
21
|
-
notifications:
|
|
22
|
-
email:
|
|
23
|
-
- semmons99@gmail.com
|
|
24
|
-
- andreas@aloop.org
|
|
25
|
-
- weppos@weppos.net
|
data/CONTRIBUTING.md
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# Contribution Guidelines
|
|
2
|
-
|
|
3
|
-
## Steps
|
|
4
|
-
|
|
5
|
-
1. Fork [the repo](https://github.com/RubyMoney/money-heuristics)
|
|
6
|
-
2. Grab dependencies: `bundle install`
|
|
7
|
-
3. Make sure everything is working: `bundle exec rake spec`
|
|
8
|
-
4. Make your changes
|
|
9
|
-
5. Test your changes
|
|
10
|
-
5. Create a Pull Request
|
|
11
|
-
6. Celebrate!!!!!
|
|
12
|
-
|
|
13
|
-
## Notes
|
|
14
|
-
|
|
15
|
-
When contributing, please make sure to update the CHANGELOG and AUTHORS files
|
|
16
|
-
when you submit your pull request. Upon merging of your first pull request,
|
|
17
|
-
you will be given commit access to the repository.
|
data/Gemfile
DELETED
data/Rakefile
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
require "bundler/gem_tasks"
|
|
2
|
-
require "rake/clean"
|
|
3
|
-
require "rspec/core/rake_task"
|
|
4
|
-
|
|
5
|
-
CLOBBER.include('doc', '.yardoc')
|
|
6
|
-
|
|
7
|
-
require "yard"
|
|
8
|
-
|
|
9
|
-
YARD::Rake::YardocTask.new do |t|
|
|
10
|
-
t.options << "--files" << "CHANGELOG.md,LICENSE"
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
|
14
|
-
t.fail_on_error = false
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
task default: :spec
|
data/spec/heuristics_spec.rb
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
describe MoneyHeuristics do
|
|
4
|
-
describe "#analyze_string" do
|
|
5
|
-
let(:it) { Money::Currency }
|
|
6
|
-
|
|
7
|
-
it "is not affected by blank characters and numbers" do
|
|
8
|
-
expect(it.analyze('123')).to eq []
|
|
9
|
-
expect(it.analyze('\n123 \t')).to eq []
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it "returns nothing when given nothing" do
|
|
13
|
-
expect(it.analyze('')).to eq []
|
|
14
|
-
expect(it.analyze(nil)).to eq []
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "finds a currency by use of its symbol" do
|
|
18
|
-
expect(it.analyze('zł')).to eq ['PLN']
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it "is not affected by trailing dot" do
|
|
22
|
-
expect(it.analyze('zł.')).to eq ['PLN']
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it "finds match even if has numbers after" do
|
|
26
|
-
expect(it.analyze('zł 123')).to eq ['PLN']
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "finds match even if has numbers before" do
|
|
30
|
-
expect(it.analyze('123 zł')).to eq ['PLN']
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it "find match even if symbol is next to number" do
|
|
34
|
-
expect(it.analyze('300zł')).to eq ['PLN']
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it "finds match even if has numbers with delimiters" do
|
|
38
|
-
expect(it.analyze('zł 123,000.50')).to eq ['PLN']
|
|
39
|
-
expect(it.analyze('zł123,000.50')).to eq ['PLN']
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it "finds currencies with dots in symbols" do
|
|
43
|
-
expect(it.analyze('L.E.')).to eq ['EGP']
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it "finds by name" do
|
|
47
|
-
expect(it.analyze('1900 bulgarian lev')).to eq ['BGN']
|
|
48
|
-
expect(it.analyze('Swedish Krona')).to eq ['SEK']
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it "Finds several currencies when several match" do
|
|
52
|
-
r = it.analyze('$400')
|
|
53
|
-
expect(r).to include("ARS")
|
|
54
|
-
expect(r).to include("USD")
|
|
55
|
-
expect(r).to include("NZD")
|
|
56
|
-
|
|
57
|
-
r = it.analyze('9000 £')
|
|
58
|
-
expect(r).to include("GBP")
|
|
59
|
-
expect(r).to include("SHP")
|
|
60
|
-
expect(r).to include("SYP")
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it "should use alternate symbols" do
|
|
64
|
-
expect(it.analyze('US$')).to eq ['USD']
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it "finds a currency by use of its iso code" do
|
|
68
|
-
expect(it.analyze('USD 200')).to eq ['USD']
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it "finds currencies in the middle of a sentence!" do
|
|
72
|
-
expect(it.analyze('It would be nice to have 10000 Albanian lek by tomorrow!')).to eq ['ALL']
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
it "finds several currencies in the same text!" do
|
|
76
|
-
expect(it.analyze("10EUR is less than 100:- but really, I want US$1")).to eq ['EUR', 'SEK', 'USD']
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
it "find currencies with normal characters in name using unaccent" do
|
|
80
|
-
expect(it.analyze("10 Nicaraguan Cordoba")).to eq ["NIO"]
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
it "find currencies with special characters in name using unaccent" do
|
|
84
|
-
expect(it.analyze("10 Nicaraguan Córdoba")).to eq ["NIO"]
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
it "find currencies with special symbols using unaccent" do
|
|
88
|
-
expect(it.analyze("ل.س")).not_to eq []
|
|
89
|
-
expect(it.analyze("R₣")).not_to eq []
|
|
90
|
-
expect(it.analyze("ரூ")).not_to eq []
|
|
91
|
-
expect(it.analyze("රු")).not_to eq []
|
|
92
|
-
expect(it.analyze("сом")).not_to eq []
|
|
93
|
-
expect(it.analyze("圓")).not_to eq []
|
|
94
|
-
expect(it.analyze("円")).not_to eq []
|
|
95
|
-
expect(it.analyze("৳")).not_to eq []
|
|
96
|
-
expect(it.analyze("૱")).not_to eq []
|
|
97
|
-
expect(it.analyze("௹")).not_to eq []
|
|
98
|
-
expect(it.analyze("रु")).not_to eq []
|
|
99
|
-
expect(it.analyze("ש״ח")).not_to eq []
|
|
100
|
-
expect(it.analyze("元")).not_to eq []
|
|
101
|
-
expect(it.analyze("¢")).not_to eq []
|
|
102
|
-
expect(it.analyze("£")).not_to eq []
|
|
103
|
-
expect(it.analyze("€")).not_to eq []
|
|
104
|
-
expect(it.analyze("¥")).not_to eq []
|
|
105
|
-
expect(it.analyze("د.إ")).not_to eq []
|
|
106
|
-
expect(it.analyze("؋")).not_to eq []
|
|
107
|
-
expect(it.analyze("դր.")).not_to eq []
|
|
108
|
-
expect(it.analyze("ƒ")).not_to eq []
|
|
109
|
-
expect(it.analyze("₼")).not_to eq []
|
|
110
|
-
expect(it.analyze("৳")).not_to eq []
|
|
111
|
-
expect(it.analyze("лв")).not_to eq []
|
|
112
|
-
expect(it.analyze("лев")).not_to eq []
|
|
113
|
-
expect(it.analyze("дин")).not_to eq []
|
|
114
|
-
expect(it.analyze("ب.د")).not_to eq []
|
|
115
|
-
expect(it.analyze("₡")).not_to eq []
|
|
116
|
-
expect(it.analyze("Kč")).not_to eq []
|
|
117
|
-
expect(it.analyze("د.ج")).not_to eq []
|
|
118
|
-
expect(it.analyze("ج.م")).not_to eq []
|
|
119
|
-
expect(it.analyze("ლ")).not_to eq []
|
|
120
|
-
expect(it.analyze("₵")).not_to eq []
|
|
121
|
-
expect(it.analyze("₪")).not_to eq []
|
|
122
|
-
expect(it.analyze("₹")).not_to eq []
|
|
123
|
-
expect(it.analyze("ع.د")).not_to eq []
|
|
124
|
-
expect(it.analyze("﷼")).not_to eq []
|
|
125
|
-
expect(it.analyze("د.ا")).not_to eq []
|
|
126
|
-
expect(it.analyze("៛")).not_to eq []
|
|
127
|
-
expect(it.analyze("₩")).not_to eq []
|
|
128
|
-
expect(it.analyze("د.ك")).not_to eq []
|
|
129
|
-
expect(it.analyze("〒")).not_to eq []
|
|
130
|
-
expect(it.analyze("₭")).not_to eq []
|
|
131
|
-
expect(it.analyze("ل.ل")).not_to eq []
|
|
132
|
-
expect(it.analyze("₨")).not_to eq []
|
|
133
|
-
expect(it.analyze("ل.د")).not_to eq []
|
|
134
|
-
expect(it.analyze("د.م.")).not_to eq []
|
|
135
|
-
expect(it.analyze("ден")).not_to eq []
|
|
136
|
-
expect(it.analyze("₮")).not_to eq []
|
|
137
|
-
expect(it.analyze("₦")).not_to eq []
|
|
138
|
-
expect(it.analyze("C$")).not_to eq []
|
|
139
|
-
expect(it.analyze("ر.ع.")).not_to eq []
|
|
140
|
-
expect(it.analyze("₱")).not_to eq []
|
|
141
|
-
expect(it.analyze("zł")).not_to eq []
|
|
142
|
-
expect(it.analyze("₲")).not_to eq []
|
|
143
|
-
expect(it.analyze("ر.ق")).not_to eq []
|
|
144
|
-
expect(it.analyze("РСД")).not_to eq []
|
|
145
|
-
expect(it.analyze("₽")).not_to eq []
|
|
146
|
-
expect(it.analyze("ر.س")).not_to eq []
|
|
147
|
-
expect(it.analyze("฿")).not_to eq []
|
|
148
|
-
expect(it.analyze("د.ت")).not_to eq []
|
|
149
|
-
expect(it.analyze("T$")).not_to eq []
|
|
150
|
-
expect(it.analyze("₺")).not_to eq []
|
|
151
|
-
expect(it.analyze("₴")).not_to eq []
|
|
152
|
-
expect(it.analyze("₫")).not_to eq []
|
|
153
|
-
expect(it.analyze("B⃦")).not_to eq []
|
|
154
|
-
expect(it.analyze("₤")).not_to eq []
|
|
155
|
-
expect(it.analyze("ރ")).not_to eq []
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
it "should function with unicode characters" do
|
|
159
|
-
expect(it.analyze("10 դր.")).to eq ["AMD"]
|
|
160
|
-
end
|
|
161
|
-
end
|
|
162
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
require "coveralls"
|
|
2
|
-
Coveralls.wear!
|
|
3
|
-
|
|
4
|
-
$LOAD_PATH.unshift File.dirname(__FILE__)
|
|
5
|
-
require "rspec"
|
|
6
|
-
require "money"
|
|
7
|
-
|
|
8
|
-
I18n.enforce_available_locales = false
|
|
9
|
-
|
|
10
|
-
RSpec.configure do |c|
|
|
11
|
-
c.order = :random
|
|
12
|
-
c.filter_run :focus
|
|
13
|
-
c.run_all_when_everything_filtered = true
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def reset_i18n
|
|
17
|
-
I18n.backend = I18n::Backend::Simple.new
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
RSpec.shared_context "with infinite precision", :infinite_precision do
|
|
21
|
-
before do
|
|
22
|
-
Money.infinite_precision = true
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
after do
|
|
26
|
-
Money.infinite_precision = false
|
|
27
|
-
end
|
|
28
|
-
end
|