slide_rule 0.0.3 → 0.0.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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f11d8a365d8a650797e49fe64f89947e2b1f1926
|
4
|
+
data.tar.gz: 3d6742d9e39d545e6b9f569691ae36970882bc51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e94316418b33fcbadc4a596890837197052f13d863052a4bd9d581da06992b2234462d090fbad4397e791123d263b96151970c20244736286210f89018ad4f8a
|
7
|
+
data.tar.gz: 89d3aa4826f9663b8cdf92dc975dd473a4d052daa2c6b3ced8cb9cc3139731ab612a6ba1fcf197c4ebe6642320245505931f52f46ca44dfbde18d6db9a30f598
|
@@ -24,6 +24,11 @@ module SlideRule
|
|
24
24
|
matches(obj, array, threshold).sort { |match| match[:distance] }.first
|
25
25
|
end
|
26
26
|
|
27
|
+
def is_match?(obj_1, obj_2, threshold)
|
28
|
+
distance = calculate_distance(obj_1, obj_2)
|
29
|
+
distance < threshold
|
30
|
+
end
|
31
|
+
|
27
32
|
def matches(obj, array, threshold)
|
28
33
|
array.map do |item|
|
29
34
|
distance = calculate_distance(obj, item)
|
data/lib/slide_rule/version.rb
CHANGED
@@ -54,6 +54,35 @@ describe ::SlideRule::DistanceCalculator do
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
+
describe '#is_match?' do
|
58
|
+
let(:calculator) do
|
59
|
+
::SlideRule::DistanceCalculator.new(
|
60
|
+
description: {
|
61
|
+
weight: 0.80,
|
62
|
+
type: :levenshtein
|
63
|
+
},
|
64
|
+
date: {
|
65
|
+
weight: 0.90,
|
66
|
+
type: :day_of_month
|
67
|
+
}
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'returns true if there is a match' do
|
72
|
+
example_1 = ExampleTransaction.new(description: 'Wells Fargo Dealer SVC', date: '2015-06-17')
|
73
|
+
example_2 = ExampleTransaction.new(description: 'Wells Fargo Dealer SVC', date: '2015-06-17')
|
74
|
+
|
75
|
+
expect(calculator.is_match?(example_1, example_2, 0.2)).to be(true)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'returns false if there is a match' do
|
79
|
+
example_1 = ExampleTransaction.new(description: 'Wells Fargo Dealer SVC', date: '2015-06-17')
|
80
|
+
example_2 = ExampleTransaction.new(description: 'Taco Bell', date: '2015-06-17')
|
81
|
+
|
82
|
+
expect(calculator.is_match?(example_1, example_2, 0.2)).to be(false)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
57
86
|
describe '#calculate_distance' do
|
58
87
|
context 'uses built-in calculator' do
|
59
88
|
it 'should calculate perfect match' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slide_rule
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mattnichols
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-01-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
version: '0'
|
129
129
|
requirements: []
|
130
130
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.4.
|
131
|
+
rubygems_version: 2.4.8
|
132
132
|
signing_key:
|
133
133
|
specification_version: 4
|
134
134
|
summary: Ruby object distance calculator
|