wilderpeople 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26c48edebe245cbafc5148e4cee8a83b7cd5bba4
4
- data.tar.gz: 9839aeaf707ef84954a9388e6f7b92beb652c38f
3
+ metadata.gz: 414d56969ee67956445264eba64cd7621b607ca1
4
+ data.tar.gz: 9b68bcbd6acedaa13c49fbd69c9d11bdc1bc843e
5
5
  SHA512:
6
- metadata.gz: 415c1bf9ec3c123e1bc41370898418aa283e5a20b65867322da03b900a88d0bb851d3a15e2c9fad74912d98596ae9dbaf91c361fb536a5f70df96b6e18f0a514
7
- data.tar.gz: 3888ea7c8becd071d831534af1419346b6db62aa1f91bb0b87b30f01a78d2175ef3279a6bd7cd4e3f36ba4fb736ab0a0ab265edbfbe35bb186802f59663fdbd4
6
+ metadata.gz: 59cad0a1693fdac011b4d6a4fbc97e33b2120f9a7219cee559794ae412d3b9928294a5ec4ad0d14eaf6f5769fe36fb0113400cbfdc9a86f626fb5314fc0b0d21
7
+ data.tar.gz: db6898c8e76acfb7c57a366406fe62c050f1df28f2b9f1921a3c88272c8415f7f10a3cfacbfa213ce8411aeeced53d6a4b84a75b6677d4366d2c01f4473253c6
@@ -56,6 +56,13 @@ module Wilderpeople
56
56
  exact *[a,b].collect{|x| x.chars.sort}
57
57
  end
58
58
 
59
+ # All the right letters but not necessarily in the right order
60
+ # and ignoring spaces
61
+ def spaceless_transposed
62
+ return true if exact
63
+ exact *[a,b].collect{|x| remove_white_space(x).chars.sort}
64
+ end
65
+
59
66
  # Designed for matching street names, so don't have to worry about
60
67
  # Road/Rb and Street/St.
61
68
  # Note that if matching one word, just that word is matched
@@ -74,12 +81,13 @@ module Wilderpeople
74
81
  # Match 'Foo bar' with 'Foobar'
75
82
  def exact_no_space
76
83
  return true if exact
77
- exact *[a,b].collect{|x| x.gsub(/\s/, '')}
84
+ exact *[a,b].collect{|x| remove_white_space(x)}
78
85
  end
79
86
 
80
87
  # Match English first names with alternative forms
81
88
  # So 'Robert' matches 'Rob'
82
89
  def hypocorism
90
+ return true if exact
83
91
  Hypocorism.match(a,b)
84
92
  end
85
93
 
@@ -108,7 +116,7 @@ module Wilderpeople
108
116
  # one word into the other.
109
117
  # See https://github.com/tliff/levenshtein
110
118
  def fuzzy(threshold = self.class.levenshtein_threshold)
111
- exact
119
+ return true if exact
112
120
  return false if a.empty? || b.empty?
113
121
  !!Levenshtein.normalized_distance(a,b, threshold)
114
122
  end
@@ -149,5 +157,9 @@ module Wilderpeople
149
157
  def try_proper_format(string)
150
158
  Date.strptime string, "%d/%m/%Y"
151
159
  end
160
+
161
+ def remove_white_space(string)
162
+ string.gsub(/\s/, '')
163
+ end
152
164
  end
153
165
  end
@@ -1,17 +1,22 @@
1
1
  module Wilderpeople
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
4
4
 
5
5
  # History
6
6
  # =======
7
7
  #
8
- # 0.1.0: Initial release
9
- # ----------------------
10
- # Basic functionality working that allows unique items to be retrieved from
11
- # a data set based on a set of criteria and a matching dataset.
8
+ # 0.3.0: Add spaceless_transposed matcher
9
+ # ---------------------------------------
10
+ # Add method to match transposed strings and ignoring spaces. For example,
11
+ # to match WR10 2NB with WR102BN
12
12
  #
13
13
  # 0.2.0: Add select to return matching items
14
14
  # ------------------------------------------
15
15
  # Added a `select` method to search, that will return all the matching items
16
16
  #
17
+ # 0.1.0: Initial release
18
+ # ----------------------
19
+ # Basic functionality working that allows unique items to be retrieved from
20
+ # a data set based on a set of criteria and a matching dataset.
21
+ #
17
22
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wilderpeople
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Nichols
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-10 00:00:00.000000000 Z
11
+ date: 2017-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hypocorism