fat_core 7.0.1 → 7.1.1

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
  SHA256:
3
- metadata.gz: 2e8f4f5a7755b961eefa799f5450586a9e3f008110c6dc179fd90e56a12557f3
4
- data.tar.gz: fe9a35502b6f1453f5d0f2afdf8b83f91b3a43b4bf0f19b00baae2e38eac37e0
3
+ metadata.gz: e41b6857fb2c0b81125ed588ea89a53fa65d794e462336d96186692de9f369b3
4
+ data.tar.gz: 3ab1379a55487b58400c971dd81eb81d08aafe2500e4743e9402b646a6daddab
5
5
  SHA512:
6
- metadata.gz: 9ae1381cbb8d46700dc0258dd6eabcc68f50949d7ca7f878bb4013939ca43c88d365bebbb9c32f232f030c2baf7a962a69b7df1579836425ad748c07e9617dab
7
- data.tar.gz: c76f9b88fb4f5d705091c8f0d5aeb206ef89efafebaabff067b6421cf957f58695c6c8d3a670f6fdaad0aaa5a2260683fcb7b7bc509810c62f3269326d3e5aa7
6
+ metadata.gz: 9da3d3dd996a3ffe907e618ee9f4ee550c3e720b8a27e8790d4f027c5e11b187417832e41bfe3d6d3c513c2315482302ed784dd61c87c98a2647483f838ea953
7
+ data.tar.gz: e5862ca6b225780f8152611064e2c4af9550a7351f2fc44a4aae20c991d6802fc4261c605afbb5d8b99f6c3790934330571219a60ef4c7f93bf613935d83cc71
data/CHANGELOG.org CHANGED
@@ -1,3 +1,15 @@
1
+ * Version 7.1.1
2
+ ** String
3
+ - =String#fuzzy_match= make period, comma, asterisk, and apostrophes optional
4
+ in matcher instead of just deleting them and in the subject string replace
5
+ periods and commas with spaces so they still act as word separators.
6
+
7
+ Before ='WWW.WOLFRAM.COM'.fuzzy_match('www:wolfram')= would not match because
8
+ the periods were just eliminated so the matcher was looking for a word
9
+ starting with 'wolfram' but the subject string was converted to
10
+ 'WWWWOLFRAMCOM' so no match. Now it is converted to 'WWW WOLFRAM COM' so
11
+ the match succeeds.
12
+
1
13
  * Version 7.0.0 from Version 6.0.0
2
14
  ** Enumerable
3
15
  - Remove =#groups_of= as duplicative of =each_slice=
data/README.org CHANGED
@@ -801,22 +801,26 @@ matcher both the space and colon ':' have special meaning as shown below.
801
801
 
802
802
  1. Remove leading and trailing whitespace in the subject and the matcher
803
803
  and collapse its internal whitespace to a single space,
804
- 2. Remove all periods, commas, apostrophes, and asterisks (the
805
- punctuation characters) from both self and `matcher`,
806
- 3. Treat internal ':stuff' or ' :stuff' in the matcher as the equivalent
804
+ 2. In the subject string replace periods and commas with a space (so
805
+ they still act as word separators) but remove apostrophes, and
806
+ asterisks so the user need not remember whether they were used when
807
+ forming the matcher.
808
+ 3. In the matcher, make any period, comma, asterisk, or apostrophe
809
+ optional for the same reason.
810
+ 4. Treat internal ':stuff' or ' :stuff' in the matcher as the equivalent
807
811
  of /\bstuff.*/ in a regular expression, that is, match any word
808
812
  starting with stuff in self,
809
- 4. Treat internal 'stuff: ' in the matcher as the equivalent of /.*stuff\b/ in
813
+ 5. Treat internal 'stuff: ' in the matcher as the equivalent of /.*stuff\b/ in
810
814
  a regular expression, that is, match any word ending with stuff in self,
811
- 5. A colon with no spaces around it is treated as belonging to the
815
+ 6. A colon with no spaces around it is treated as belonging to the
812
816
  following word, requiring it to start with it, so 'some:stuff'
813
817
  requires 'some' anywhere followed by a word beginning with 'stuff',
814
818
  i.e., /some.*\bstuff/i,
815
- 6. Treat leading ':' in the matcher as anchoring the match to the
819
+ 7. Treat leading ':' in the matcher as anchoring the match to the
816
820
  beginning of the target string,
817
- 7. Treat ending ':' in the matcher as anchoring the match to the
821
+ 8. Treat ending ':' in the matcher as anchoring the match to the
818
822
  end of the target string,
819
- 8. Require each component to match some part of self, and
823
+ 9. Require each component to match some part of self, and
820
824
 
821
825
  #+begin_src ruby
822
826
  require_relative './lib/fat_core/string'
@@ -825,7 +829,7 @@ matcher both the space and colon ':' have special meaning as shown below.
825
829
  result << ['Self', 'Matcher', 'Match']
826
830
  result << nil
827
831
  subj = "St. Luke's Hospital"
828
- matchers = ['st lukes', 'luk:hosp', 'st:spital', 'uk spital', 'st:laks', ':lukes', 's lukes', 'lukes:hospital']
832
+ matchers = ['st lukes', 'st. luke\'s', 'luk:hosp', 'st:spital', 'uk spital', 'st:laks', ':lukes', 's lukes', 'lukes:hospital']
829
833
  matchers.each do |m|
830
834
  result << [subj, m, subj.fuzzy_match(m)]
831
835
  end
@@ -836,6 +840,7 @@ matcher both the space and colon ':' have special meaning as shown below.
836
840
  | Self | Matcher | Match |
837
841
  |---------------------+----------------+----------------|
838
842
  | St. Luke's Hospital | st lukes | St Lukes |
843
+ | St. Luke's Hospital | st. luke's | St Lukes |
839
844
  | St. Luke's Hospital | luk:hosp | Lukes Hosp |
840
845
  | St. Luke's Hospital | st:spital | nil |
841
846
  | St. Luke's Hospital | uk spital | ukes Hospital |
data/Rakefile CHANGED
@@ -21,7 +21,7 @@ YARD::Rake::YardocTask.new do |t|
21
21
  end
22
22
 
23
23
  RSpec::Core::RakeTask.new(:spec, :tag) do |t|
24
- t.rspec_opts = '--tag ~online -f p'
24
+ t.rspec_opts = '--tag ~online -f d'
25
25
  end
26
26
 
27
27
  ########################################################################
data/fat_core.gemspec CHANGED
@@ -10,15 +10,15 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ['ded@ddoherty.net']
11
11
  spec.summary = 'some useful core extensions'
12
12
  spec.description = <<~DESC
13
- Useful extensions to Date, String, Range and other classes
14
- including useful Date extensions for dealing with US Federal
15
- and New York Stock Exchange holidays and working days, a useful
13
+ Useful extensions to Enumerable and String, Range and other classes. A
16
14
  Enumerable#each_with_flags for flagging first and last items in the
17
- iteration, (also for Hash), set operations on Ranges
15
+ iteration, operations on Ranges for testing contiguity, gaps in sets of
16
+ Ranges, and performing set operations on Ranges. String#fuzzy_match
17
+ for user-friendly matchers to test for matching.
18
18
  DESC
19
19
  spec.homepage = 'https://github.com/ddoherty03/fat_core.git'
20
20
  spec.license = 'MIT'
21
- spec.required_ruby_version = '>= 2.2.2'
21
+ spec.required_ruby_version = '>= 3.2.2'
22
22
  spec.metadata['yard.run'] = 'yri' # use "yard" to build full HTML docs.
23
23
 
24
24
  spec.files = %x[git ls-files -z].split("\x0")
@@ -243,24 +243,28 @@ module FatCore
243
243
  #
244
244
  # 1. Remove leading and trailing whitespace in the subject and the matcher
245
245
  # and collapse its internal whitespace to a single space,
246
- # 2. Remove all periods, commas, apostrophes, and asterisks (the
247
- # punctuation characters) from both self and `matcher`,
248
- # 3. Treat internal ':stuff' or ' :stuff' in the matcher as the equivalent
246
+ # 2. In the subject string replace periods and commas with a space (so
247
+ # they still act as word separators) but remove apostrophes, and
248
+ # asterisks so the user need not remember whether they were used when
249
+ # forming the matcher.
250
+ # 3. In the matcher, make any period, comma, asterisk, or apostrophe
251
+ # optional for the same reason.
252
+ # 4. Treat internal ':stuff' or ' :stuff' in the matcher as the equivalent
249
253
  # of /\bstuff.*/ in a regular expression, that is, match any word
250
254
  # starting with stuff in self,
251
- # 4. Treat internal 'stuff: ' in the matcher as the equivalent
255
+ # 5. Treat internal 'stuff: ' in the matcher as the equivalent
252
256
  # of /.*stuff\b/ in a regular expression, that is, match any word
253
257
  # ending with stuff in self,
254
- # 5. A colon with no spaces around it is treated as belonging to the
258
+ # 6. A colon with no spaces around it is treated as belonging to the
255
259
  # following word, requiring it to start with it, so 'some:stuff'
256
260
  # requires 'some' anywhere followed by a word beginning with 'stuff',
257
261
  # i.e., /some.*\bstuff/i,
258
- # 6. Treat leading ':' in the matcher as anchoring the match to the
262
+ # 7. Treat leading ':' in the matcher as anchoring the match to the
259
263
  # beginning of the target string,
260
- # 7. Treat ending ':' in the matcher as anchoring the match to the
264
+ # 8. Treat ending ':' in the matcher as anchoring the match to the
261
265
  # end of the target string,
262
- # 8. Require each component to match some part of self, and
263
- # 9. Ignore case in the match
266
+ # 9. Require each component to match some part of self, and
267
+ # 10. Ignore case in the match
264
268
  #
265
269
  # @example
266
270
  # "St. Luke's Hospital".fuzzy_match('st lukes') #=> 'St Lukes'
@@ -275,9 +279,12 @@ module FatCore
275
279
  # @return [String] the unpunctuated part of self that matched
276
280
  # @return [nil] if self did not match matcher
277
281
  def fuzzy_match(matcher)
278
- # Remove periods, asterisks, commas, and apostrophes
279
- matcher = matcher.clean.strip.gsub(/[\*.,']/, '')
280
- target = clean.gsub(/[\*.,']/, '')
282
+ # Make asterisks, periods, commas, and apostrophes optional
283
+ matcher = matcher.clean.gsub(/[\*.,']/, '\0?')
284
+ # Replace periods and commas with a space (so they are still word
285
+ # separators, e.g. 'WWW.WOLFRAM' -> 'WWW WOLFRAM' and 'AMZON,INC.' ->
286
+ # 'AMAZON INC') and remove asterisks and apostrophes
287
+ target = gsub(/[.,]/, ' ').gsub(/[\*']/, '').clean
281
288
  regexp_string =
282
289
  if matcher.match?(/[: ]/)
283
290
  matcher.sub(/\A:/, "\\A").sub(/:\z/, "\\z")
@@ -2,7 +2,7 @@
2
2
 
3
3
  module FatCore
4
4
  MAJOR = 7
5
- MINOR = 0
5
+ MINOR = 1
6
6
  PATCH = 1
7
7
 
8
8
  # FatCore version number
@@ -261,9 +261,24 @@ the people, for the people, shall not perish from the earth."
261
261
  expect('Hello, world'.fuzzy_match('ox')).to be_falsy
262
262
  end
263
263
 
264
- it 'fuzzy matches space-separated parts' do
264
+ it 'replaces periods and commas with a space so they are still word separators' do
265
+ expect('WWW.WOLFRAM.COM'.fuzzy_match('wolf')).to be_truthy
266
+ expect('AMAZON,INC'.fuzzy_match('amazon inc')).to be_truthy
267
+ end
268
+
269
+ it 'modifies self by removing asterisks and apostrophes' do
270
+ expect('WWW*WOLFRAM*COM'.fuzzy_match('wolf')).to be_truthy
271
+ expect('E*TRADE'.fuzzy_match('etrade')).to be_truthy
272
+ expect('WWW*WOLFRAM*COM'.fuzzy_match(':wolf')).to be_falsy
273
+ expect('WWW.WOLFRAM.COM'.fuzzy_match('wolf')).to be_truthy
274
+ expect('AMAZON,INC'.fuzzy_match('amazon inc')).to be_truthy
275
+ end
276
+
277
+ it 'treats internal space as dot-star' do
265
278
  expect('Hello world'.fuzzy_match('hel wor')).to be_truthy
279
+ expect('Hello, world'.fuzzy_match('el or')).to be_truthy
266
280
  expect('Hello, world'.fuzzy_match('hel ox')).to be_falsy
281
+ expect('Hello, what is with the world?'.fuzzy_match('at wi or')).to be_truthy
267
282
  end
268
283
 
269
284
  it 'fuzzy matches colon-separated parts' do
@@ -311,10 +326,12 @@ the people, for the people, shall not perish from the earth."
311
326
  expect('Hello:world'.matches_with('/^h.*r/')).to eq('Hello:wor')
312
327
  end
313
328
 
314
- it 'ignores periods, commas, and apostrophes when matching' do
329
+ it 'make periods, commas, and apostrophes optional when matching' do
315
330
  expect("St. Luke's".fuzzy_match('st lukes')).to eq('St Lukes')
316
- expect('St Lukes'.fuzzy_match('st. luke\'s')).to eq('St Lukes')
331
+ expect("St. Luke's".fuzzy_match('st. luke\'s')).to eq('St Lukes')
332
+ expect("St Lukes".fuzzy_match('st. luke\'s')).to eq('St Lukes')
317
333
  expect('St Lukes, Inc.'.fuzzy_match('st luke inc')).to eq('St Lukes Inc')
334
+ expect('St Lukes, Inc.'.fuzzy_match('st lukes, inc')).to eq('St Lukes Inc')
318
335
  expect('E*TRADE'.fuzzy_match('etrade')).to eq('ETRADE')
319
336
  # Does not recognize non-alphanumerics as start of string.
320
337
  expect('The 1 Dollar Store'.fuzzy_match('1 stor')).to be_truthy
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fat_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.1
4
+ version: 7.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel E. Doherty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-11-25 00:00:00.000000000 Z
11
+ date: 2025-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -67,11 +67,11 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: 3.1.2
69
69
  description: |
70
- Useful extensions to Date, String, Range and other classes
71
- including useful Date extensions for dealing with US Federal
72
- and New York Stock Exchange holidays and working days, a useful
70
+ Useful extensions to Enumerable and String, Range and other classes. A
73
71
  Enumerable#each_with_flags for flagging first and last items in the
74
- iteration, (also for Hash), set operations on Ranges
72
+ iteration, operations on Ranges for testing contiguity, gaps in sets of
73
+ Ranges, and performing set operations on Ranges. String#fuzzy_match
74
+ for user-friendly matchers to test for matching.
75
75
  email:
76
76
  - ded@ddoherty.net
77
77
  executables: []
@@ -131,7 +131,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
131
  requirements:
132
132
  - - ">="
133
133
  - !ruby/object:Gem::Version
134
- version: 2.2.2
134
+ version: 3.2.2
135
135
  required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - ">="