fat_core 7.3.0 → 7.5.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
  SHA256:
3
- metadata.gz: 3aced327c9c27abf23f852ce1db5e3347cb1b26558d9c4c337937db9773d1dde
4
- data.tar.gz: 4cb7f01cae67351e9865476ab40f87ddf37375b1dec7a14e725633288c3b78eb
3
+ metadata.gz: 6f4b84a879ef64ab6054af28511bf9c87975baeef65d006008d4351cbed07be4
4
+ data.tar.gz: 27cc94fe92188194ef68ab18c7dab74e5f80440b321df848b494405c17ea0f46
5
5
  SHA512:
6
- metadata.gz: d90173d7c849ca52ab67e1ccb14af60e7171c16c39b5b482d3df08d6f080e8b2ebdf1f18b89122c3554186cc35d6ae572b84d06d584f3a9a01f674ef9a2f5b8a
7
- data.tar.gz: 895eeef8c783f150bb1cb28283c1ff4e4ffdec5ab94cb6889ad1fcbe60e4475ac7326d2c45b3cd5b50b76bb518a52c1866ed70c42c525c1c8d76facab7780e32
6
+ metadata.gz: f4ad4228b75766b03a30719ce23531f60bec37db7753db4153deb21f8eb0b84629346571119b737835be5bd479ed1a0a4e414cafc2f4d3c3630a2fb3a1fa3d64
7
+ data.tar.gz: 7b217c20aa7fa970ea8b44faa85c94692d3307c518bef0f93e2fde59559a220bebadf1cf81649e21e60bb56e43fb2fb8a683633384570868ac1c7b5489035975
@@ -14,12 +14,15 @@ on:
14
14
  jobs:
15
15
  test:
16
16
  runs-on: ubuntu-24.04
17
+ continue-on-error: ${{ matrix.ruby == 'ruby-head' }}
17
18
  strategy:
19
+ fail-fast: false
18
20
  matrix:
19
- ruby: [3.2.2, 3.3.0, 3.4.0]
21
+ # Minor versions select the latest patch; ruby-head is experimental.
22
+ ruby: ['3.2', '3.3', '3.4', '4.0', 'ruby-head']
20
23
  steps:
21
24
  - name: Check out code
22
- uses: actions/checkout@v4
25
+ uses: actions/checkout@v6
23
26
 
24
27
  - name: Install build dependencies (needed if Ruby must be compiled)
25
28
  run: |
data/.gitignore CHANGED
@@ -3,7 +3,6 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
- Gemfile.lock
7
6
  InstalledFiles
8
7
  _yardoc
9
8
  coverage
@@ -24,3 +23,4 @@ tmp
24
23
  /.idea/
25
24
  /TAGS
26
25
  /.tangle-stamp
26
+ /AGENTS.*
data/Gemfile.lock ADDED
@@ -0,0 +1,171 @@
1
+ GIT
2
+ remote: https://github.com/ddoherty03/rubocop-ddoherty.git
3
+ revision: e20a30ef08d9b8ded242cf6b66fa20500c8045c6
4
+ branch: master
5
+ specs:
6
+ rubocop-ddoherty (0.1.3)
7
+ rubocop (~> 1.62)
8
+ rubocop-performance (~> 1.0)
9
+ rubocop-rake (>= 0.7)
10
+ rubocop-rspec (~> 3.0)
11
+
12
+ PATH
13
+ remote: .
14
+ specs:
15
+ fat_core (7.5.0)
16
+ activesupport
17
+ ostruct
18
+ stringio (>= 3.1.2)
19
+
20
+ GEM
21
+ remote: https://rubygems.org/
22
+ specs:
23
+ activesupport (8.1.1)
24
+ base64
25
+ bigdecimal
26
+ concurrent-ruby (~> 1.0, >= 1.3.1)
27
+ connection_pool (>= 2.2.5)
28
+ drb
29
+ i18n (>= 1.6, < 2)
30
+ json
31
+ logger (>= 1.4.2)
32
+ minitest (>= 5.1)
33
+ securerandom (>= 0.3)
34
+ tzinfo (~> 2.0, >= 2.0.5)
35
+ uri (>= 0.13.1)
36
+ ast (2.4.3)
37
+ base64 (0.3.0)
38
+ bigdecimal (4.0.1)
39
+ coderay (1.1.3)
40
+ concurrent-ruby (1.3.6)
41
+ connection_pool (3.0.2)
42
+ date (3.5.1)
43
+ debug (1.11.1)
44
+ irb (~> 1.10)
45
+ reline (>= 0.3.8)
46
+ diff-lcs (1.6.2)
47
+ docile (1.4.1)
48
+ drb (2.2.3)
49
+ erb (6.0.1)
50
+ gem_docs (0.4.0)
51
+ rake
52
+ yard (>= 0.9.28)
53
+ i18n (1.14.8)
54
+ concurrent-ruby (~> 1.0)
55
+ io-console (0.8.2)
56
+ irb (1.16.0)
57
+ pp (>= 0.6.0)
58
+ rdoc (>= 4.0.0)
59
+ reline (>= 0.4.2)
60
+ json (2.18.0)
61
+ language_server-protocol (3.17.0.5)
62
+ lint_roller (1.1.0)
63
+ logger (1.7.0)
64
+ method_source (1.1.0)
65
+ minitest (6.0.1)
66
+ prism (~> 1.5)
67
+ ostruct (0.6.3)
68
+ parallel (1.27.0)
69
+ parser (3.3.10.0)
70
+ ast (~> 2.4.1)
71
+ racc
72
+ pp (0.6.3)
73
+ prettyprint
74
+ prettyprint (0.2.0)
75
+ prism (1.7.0)
76
+ pry (0.16.0)
77
+ coderay (~> 1.1)
78
+ method_source (~> 1.0)
79
+ reline (>= 0.6.0)
80
+ pry-doc (1.6.0)
81
+ pry (~> 0.11)
82
+ yard (~> 0.9.11)
83
+ psych (5.3.1)
84
+ date
85
+ stringio
86
+ racc (1.8.1)
87
+ rainbow (3.1.1)
88
+ rake (13.4.2)
89
+ rdoc (7.0.3)
90
+ erb
91
+ psych (>= 4.0.0)
92
+ tsort
93
+ redcarpet (3.6.1)
94
+ regexp_parser (2.11.3)
95
+ reline (0.6.3)
96
+ io-console (~> 0.5)
97
+ rspec (3.13.2)
98
+ rspec-core (~> 3.13.0)
99
+ rspec-expectations (~> 3.13.0)
100
+ rspec-mocks (~> 3.13.0)
101
+ rspec-core (3.13.6)
102
+ rspec-support (~> 3.13.0)
103
+ rspec-expectations (3.13.5)
104
+ diff-lcs (>= 1.2.0, < 2.0)
105
+ rspec-support (~> 3.13.0)
106
+ rspec-mocks (3.13.7)
107
+ diff-lcs (>= 1.2.0, < 2.0)
108
+ rspec-support (~> 3.13.0)
109
+ rspec-support (3.13.6)
110
+ rubocop (1.82.1)
111
+ json (~> 2.3)
112
+ language_server-protocol (~> 3.17.0.2)
113
+ lint_roller (~> 1.1.0)
114
+ parallel (~> 1.10)
115
+ parser (>= 3.3.0.2)
116
+ rainbow (>= 2.2.2, < 4.0)
117
+ regexp_parser (>= 2.9.3, < 3.0)
118
+ rubocop-ast (>= 1.48.0, < 2.0)
119
+ ruby-progressbar (~> 1.7)
120
+ unicode-display_width (>= 2.4.0, < 4.0)
121
+ rubocop-ast (1.48.0)
122
+ parser (>= 3.3.7.2)
123
+ prism (~> 1.4)
124
+ rubocop-performance (1.26.1)
125
+ lint_roller (~> 1.1)
126
+ rubocop (>= 1.75.0, < 2.0)
127
+ rubocop-ast (>= 1.47.1, < 2.0)
128
+ rubocop-rake (0.7.1)
129
+ lint_roller (~> 1.1)
130
+ rubocop (>= 1.72.1)
131
+ rubocop-rspec (3.8.0)
132
+ lint_roller (~> 1.1)
133
+ rubocop (~> 1.81)
134
+ ruby-progressbar (1.13.0)
135
+ securerandom (0.4.1)
136
+ simplecov (0.22.0)
137
+ docile (~> 1.1)
138
+ simplecov-html (~> 0.11)
139
+ simplecov_json_formatter (~> 0.1)
140
+ simplecov-html (0.13.2)
141
+ simplecov_json_formatter (0.1.4)
142
+ stringio (3.2.0)
143
+ tsort (0.2.0)
144
+ tzinfo (2.0.6)
145
+ concurrent-ruby (~> 1.0)
146
+ unicode-display_width (3.2.0)
147
+ unicode-emoji (~> 4.1)
148
+ unicode-emoji (4.2.0)
149
+ uri (1.1.1)
150
+ yard (0.9.45)
151
+
152
+ PLATFORMS
153
+ ruby
154
+ x86_64-linux
155
+
156
+ DEPENDENCIES
157
+ bundler
158
+ debug (>= 1.0.0)
159
+ fat_core!
160
+ gem_docs (>= 0.2.0)
161
+ pry
162
+ pry-doc
163
+ rake
164
+ redcarpet
165
+ rspec
166
+ rubocop
167
+ rubocop-ddoherty!
168
+ simplecov
169
+
170
+ BUNDLED WITH
171
+ 4.0.17
data/README.md CHANGED
@@ -1,50 +1,56 @@
1
- - [Version](#org706993f)
2
- - [Introduction](#org8e3de1e)
3
- - [Installation](#orge71ccdc)
4
- - [Usage](#org1ef61a0)
5
- - [Array](#orgfc24a05)
6
- - [Method `#comma_join(sep: nil, last_sep: nil, two_sep: nil)`](#org779ed95)
7
- - [Method `#last_i`](#org07f787c)
8
- - [Method `#intersect_with_dups`](#org0d2857b)
9
- - [Method `diff_with_dups`](#org83423fa)
10
- - [BigDecimal `#inspect`](#orgf77f8a1)
11
- - [Enumerable](#orgdce8ffe)
12
- - [Method `#each_with_flags`](#org166e57c)
13
- - [Hash](#org1e11773)
14
- - [Method `#each_pair_with_flags`](#org0bd20b9)
15
- - [Method `#delete_with_value` and `#delete_with_value!`](#org4dc0aa1)
16
- - [Method `#keys_with_value`](#org605ad55)
17
- - [Method `#remap_keys`](#orgdde4b0b)
18
- - [Method `#replace_keys`](#org7603809)
19
- - [Alias `#merge` to `<<`](#orgadf50ea)
20
- - [Numeric](#org3918509)
21
- - [Method `#signum`](#org6abf375)
22
- - [Method `#commas(places = nil)`](#org00c3e90)
23
- - [Methods `#whole?` and `#int_if_whole`](#orgb844d6f)
24
- - [Method `#secs_to_hms`](#orgfd1b851)
25
- - [Range](#org7a70260)
26
- - [Methods `#contiguous`, `#left_contiguous`, `#right_contiguous`](#orgdd06e2c)
27
- - [Method `#join(other)`](#org28a7d95)
28
- - [Method `#spanned_by?(others)`](#org5d367a6)
29
- - [Methods `#gaps(others)`, `#overlaps(others)`](#orga33fd47)
30
- - [String](#orgbd1bd5e)
31
- - [Method `#fuzzy_match`](#org63111cb)
32
- - [Method `#matches_with`](#orgdae93bf)
33
- - [Method `#entitle`](#org1a5d1e4)
34
- - [Method `#distance`](#orgd671ee5)
35
- - [Method `#commas(places)`](#orgfdd51bd)
36
- - [Method `#wrap(width, hang)`](#org826950e)
37
- - [Method `#as_sym`](#orgc017d90)
38
- - [Method `gut`](#org3459d99)
39
- - [Symbol](#org2241c53)
40
- - [Method `#as_str`](#orgf2478cc)
41
- - [TeX Quoting](#org5620bc3)
42
- - [Contributing](#orgfe2e72b)
1
+ <!-- Generated by gem_docs -->
2
+
3
+ - [Version](#org787cea4)
4
+ - [Introduction](#org70c35ee)
5
+ - [Installation](#org090e9a8)
6
+ - [Usage](#orgb94112e)
7
+ - [Array](#orgae8577a)
8
+ - [Method `#comma_join(sep: nil, last_sep: nil, two_sep: nil)`](#orgd8a835f)
9
+ - [Method `#last_i`](#org79540b4)
10
+ - [Method `#intersect_with_dups`](#orgb9df212)
11
+ - [Method `diff_with_dups`](#orgc551cb3)
12
+ - [BigDecimal](#org677499e)
13
+ - [Method `#inspect`](#org0d67a84)
14
+ - [Enumerable](#org3cbe0cd)
15
+ - [Method `#each_with_flags`](#org69aa600)
16
+ - [Hash](#org50ebe3a)
17
+ - [Method `#each_pair_with_flags`](#orgd73a8ff)
18
+ - [Method `#delete_with_value` and `#delete_with_value!`](#orgbfb1b2d)
19
+ - [Method `#keys_with_value`](#orgeb6b146)
20
+ - [Method `#remap_keys`](#orgd790229)
21
+ - [Method `#replace_keys`](#org1518994)
22
+ - [Alias `#merge` to `<<`](#orgccb5427)
23
+ - [Numeric](#org8796af2)
24
+ - [Method `#signum`](#org8788ba9)
25
+ - [Method `#commas(places = nil)`](#orga054f52)
26
+ - [Methods `#whole?` and `#int_if_whole`](#orgc67ff25)
27
+ - [Method `#secs_to_hms`](#orgd1d5330)
28
+ - [Range](#org23fcfd6)
29
+ - [Methods `#contiguous`, `#left_contiguous`, `#right_contiguous`](#org9c96e6a)
30
+ - [Method `#join(other)`](#org7ce66d2)
31
+ - [Method `#spanned_by?(others)`](#org84b3a46)
32
+ - [Methods `#gaps(others)`, `#overlaps(others)`](#org7873f20)
33
+ - [String](#org185182e)
34
+ - [Inspecting compiled matchers](#org5aface9)
35
+ - [Method `#fuzzy_match`](#org48e4298)
36
+ - [Method `#matches_with`](#org6d57e8b)
37
+ - [Method `#entitle`](#org52ff40e)
38
+ - [Method `#distance`](#org3c83e29)
39
+ - [Method `#commas(places)`](#org55c0282)
40
+ - [Method `#wrap(width, hang)`](#org7e7e1fe)
41
+ - [Method `#as_sym`](#orgedcd6ea)
42
+ - [Method `gut`](#org5bbf8f0)
43
+ - [Symbol](#orgb31753f)
44
+ - [Method `#as_str`](#orgfff0afa)
45
+ - [TeX Quoting](#org49836ae)
46
+ - [Contributing](#orga6d91af)
47
+
48
+ Version: 7.5.0
43
49
 
44
50
  [![CI](https://github.com/ddoherty03/fat_core/actions/workflows/ruby.yml/badge.svg?branch=master)](https://github.com/ddoherty03/fat_core/actions/workflows/ruby.yml)
45
51
 
46
52
 
47
- <a id="org706993f"></a>
53
+ <a id="org787cea4"></a>
48
54
 
49
55
  # Version
50
56
 
@@ -53,18 +59,18 @@
53
59
  ```
54
60
 
55
61
  ```
56
- Current version is: 7.1.3
62
+ Current version is: 7.5.0
57
63
  ```
58
64
 
59
65
 
60
- <a id="org8e3de1e"></a>
66
+ <a id="org70c35ee"></a>
61
67
 
62
68
  # Introduction
63
69
 
64
70
  `fat-core` is somewhat of a grab bag of core class extensions that I have found useful across several projects. It's higgeldy-piggeldy nature reflects the fact that none of them are important enough to deserve a gem of their own, but nonetheless need to be collected in one place to reduce redundancy across projects and provide a focused place to develop and test them.
65
71
 
66
72
 
67
- <a id="orge71ccdc"></a>
73
+ <a id="org090e9a8"></a>
68
74
 
69
75
  # Installation
70
76
 
@@ -87,7 +93,7 @@ $ gem install fat_core
87
93
  ```
88
94
 
89
95
 
90
- <a id="org1ef61a0"></a>
96
+ <a id="orgb94112e"></a>
91
97
 
92
98
  # Usage
93
99
 
@@ -118,12 +124,12 @@ false
118
124
  Many of these have little that is of general interest, but there are a few goodies.
119
125
 
120
126
 
121
- <a id="orgfc24a05"></a>
127
+ <a id="orgae8577a"></a>
122
128
 
123
129
  ## Array
124
130
 
125
131
 
126
- <a id="org779ed95"></a>
132
+ <a id="orgd8a835f"></a>
127
133
 
128
134
  ### Method `#comma_join(sep: nil, last_sep: nil, two_sep: nil)`
129
135
 
@@ -166,7 +172,7 @@ hammers, nails, glue and bolts
166
172
  ```
167
173
 
168
174
 
169
- <a id="org07f787c"></a>
175
+ <a id="org79540b4"></a>
170
176
 
171
177
  ### Method `#last_i`
172
178
 
@@ -181,7 +187,7 @@ Return the index of the last element of the Array.
181
187
  ```
182
188
 
183
189
 
184
- <a id="org0d2857b"></a>
190
+ <a id="orgb9df212"></a>
185
191
 
186
192
  ### Method `#intersect_with_dups`
187
193
 
@@ -198,7 +204,7 @@ a.intersect_with_dups(b)
198
204
  ```
199
205
 
200
206
 
201
- <a id="org83423fa"></a>
207
+ <a id="orgc551cb3"></a>
202
208
 
203
209
  ### Method `diff_with_dups`
204
210
 
@@ -215,9 +221,14 @@ a.diff_with_dups(b)
215
221
  ```
216
222
 
217
223
 
218
- <a id="orgf77f8a1"></a>
224
+ <a id="org677499e"></a>
219
225
 
220
- ## BigDecimal `#inspect`
226
+ ## BigDecimal
227
+
228
+
229
+ <a id="org0d67a84"></a>
230
+
231
+ ### Method `#inspect`
221
232
 
222
233
  `FatCore` provides nothing but a better `#inspect` method for the `BigDecimal` class since the default inspect method is not very readable.
223
234
 
@@ -232,12 +243,12 @@ BigDecimal('2.1718281828').inspect
232
243
  Without `FatCore`, the result is "0.2718281828e1", forcing you to interpret the exponent to understand where the decimal place is.
233
244
 
234
245
 
235
- <a id="orgdce8ffe"></a>
246
+ <a id="org3cbe0cd"></a>
236
247
 
237
248
  ## Enumerable
238
249
 
239
250
 
240
- <a id="org166e57c"></a>
251
+ <a id="org69aa600"></a>
241
252
 
242
253
  ### Method `#each_with_flags`
243
254
 
@@ -271,14 +282,14 @@ result
271
282
  ```
272
283
 
273
284
 
274
- <a id="org1e11773"></a>
285
+ <a id="org50ebe3a"></a>
275
286
 
276
287
  ## Hash
277
288
 
278
289
  FatCore::Hash extends the Hash class with some useful methods.
279
290
 
280
291
 
281
- <a id="org0bd20b9"></a>
292
+ <a id="orgd73a8ff"></a>
282
293
 
283
294
  ### Method `#each_pair_with_flags`
284
295
 
@@ -316,7 +327,7 @@ result
316
327
  ```
317
328
 
318
329
 
319
- <a id="org4dc0aa1"></a>
330
+ <a id="orgbfb1b2d"></a>
320
331
 
321
332
  ### Method `#delete_with_value` and `#delete_with_value!`
322
333
 
@@ -329,7 +340,7 @@ puts h
329
340
  ```
330
341
 
331
342
  ```
332
- {:a=>1, :c=>3, :e=>1}
343
+ {a: 1, c: 3, e: 1}
333
344
  ```
334
345
 
335
346
  You can supply multiple values for deletion:
@@ -341,7 +352,7 @@ puts h
341
352
  ```
342
353
 
343
354
  ```
344
- {:b=>2, :d=>2}
355
+ {b: 2, d: 2}
345
356
  ```
346
357
 
347
358
  The non-bang method returns a clone of the Hash with the given deletions made:
@@ -354,12 +365,12 @@ puts h2
354
365
  ```
355
366
 
356
367
  ```
357
- {:a=>1, :b=>2, :c=>3, :d=>2, :e=>1}
358
- {:b=>2, :d=>2}
368
+ {a: 1, b: 2, c: 3, d: 2, e: 1}
369
+ {b: 2, d: 2}
359
370
  ```
360
371
 
361
372
 
362
- <a id="org605ad55"></a>
373
+ <a id="orgeb6b146"></a>
363
374
 
364
375
  ### Method `#keys_with_value`
365
376
 
@@ -384,7 +395,7 @@ h.keys_with_value(2, 3).inspect
384
395
  ```
385
396
 
386
397
 
387
- <a id="orgdde4b0b"></a>
398
+ <a id="orgd790229"></a>
388
399
 
389
400
  ### Method `#remap_keys`
390
401
 
@@ -398,7 +409,7 @@ h.remap_keys({:a => :A, :b => :B}).inspect
398
409
  ```
399
410
 
400
411
  ```
401
- "{:A=>1, :B=>2, :c=>3, :d=>2, :e=>1}"
412
+ "{A: 1, B: 2, c: 3, d: 2, e: 1}"
402
413
  ```
403
414
 
404
415
  These days, a more systematic job could be done with `#transform_keys`:
@@ -409,11 +420,11 @@ h.transform_keys { |k| k.to_s.upcase.to_sym }.inspect
409
420
  ```
410
421
 
411
422
  ```
412
- "{:A=>1, :B=>2, :C=>3, :D=>2, :E=>1}"
423
+ "{A: 1, B: 2, C: 3, D: 2, E: 1}"
413
424
  ```
414
425
 
415
426
 
416
- <a id="org7603809"></a>
427
+ <a id="org1518994"></a>
417
428
 
418
429
  ### Method `#replace_keys`
419
430
 
@@ -425,11 +436,11 @@ h.replace_keys([:z, :y, :x, :w, :v]).inspect
425
436
  ```
426
437
 
427
438
  ```
428
- "{:z=>1, :y=>2, :x=>3, :w=>2, :v=>1}"
439
+ "{z: 1, y: 2, x: 3, w: 2, v: 1}"
429
440
  ```
430
441
 
431
442
 
432
- <a id="orgadf50ea"></a>
443
+ <a id="orgccb5427"></a>
433
444
 
434
445
  ### Alias `#merge` to `<<`
435
446
 
@@ -440,7 +451,7 @@ Finally, `FatCore` adds the "shovel" operator as an alias for `#merge` to provid
440
451
  ```
441
452
 
442
453
  ```
443
- {:a=>"A", :b=>"B", :c=>"CC", :d=>"DDD", :e=>"EEE"}
454
+ {a: "A", b: "B", c: "CC", d: "DDD", e: "EEE"}
444
455
  ```
445
456
 
446
457
  It groups values into pairs and applies the `#to_h` method to the right-hand argument if it is an `Enumerable`, so it also works if the right-hand argument is an `Array` or `Enumerable`:
@@ -464,18 +475,18 @@ h
464
475
  ```
465
476
 
466
477
  ```
467
- {:a=>"A", :b=>"B", :c=>"CC", :d=>"DDD", :e=>"EEE", "f"=>"FFFF", "g"=>"GGGG", :h=>"HHHHH", :j=>"JJJJJ"}
478
+ {a: "A", b: "B", c: "CC", d: "DDD", e: "EEE", "f" => "FFFF", "g" => "GGGG", h: "HHHHH", j: "JJJJJ"}
468
479
  ```
469
480
 
470
481
 
471
- <a id="org3918509"></a>
482
+ <a id="org8796af2"></a>
472
483
 
473
484
  ## Numeric
474
485
 
475
486
  FatCore::Numeric has methods for inserting grouping commas into a number (`#commas` and `#group`), for converting seconds to HH:MM:SS.dd format (`#secs_to_hms`), for testing for integrality (`#whole?` and `#int_if_whole`), and testing for sign (`#signum`).
476
487
 
477
488
 
478
- <a id="org6abf375"></a>
489
+ <a id="org8788ba9"></a>
479
490
 
480
491
  ### Method `#signum`
481
492
 
@@ -490,7 +501,7 @@ Return `-1` for negative numbers, `0` for zero, and `+1` for positive numbers. T
490
501
  ```
491
502
 
492
503
 
493
- <a id="org00c3e90"></a>
504
+ <a id="orga054f52"></a>
494
505
 
495
506
  ### Method `#commas(places = nil)`
496
507
 
@@ -531,7 +542,7 @@ result
531
542
  ```
532
543
 
533
544
 
534
- <a id="orgb844d6f"></a>
545
+ <a id="orgc67ff25"></a>
535
546
 
536
547
  ### Methods `#whole?` and `#int_if_whole`
537
548
 
@@ -559,7 +570,7 @@ result
559
570
  ```
560
571
 
561
572
 
562
- <a id="orgfd1b851"></a>
573
+ <a id="orgd1d5330"></a>
563
574
 
564
575
  ### Method `#secs_to_hms`
565
576
 
@@ -587,14 +598,14 @@ result
587
598
  ```
588
599
 
589
600
 
590
- <a id="org7a70260"></a>
601
+ <a id="org23fcfd6"></a>
591
602
 
592
603
  ## Range
593
604
 
594
605
  `FatCore` can also extend the Range class with several useful methods that emphasize coverage of one range by one or more others (`#spanned_by?` and `#gaps`), contiguity of Ranges to one another (`#contiguous?`, `#left_contiguous?`, and `#right_contiguous?`, `#join`), and the testing of overlaps between ranges (`#overlaps?`, `#overlaps_among?`). These are put to good use in the 'fat\_period' (<https://github.com/ddoherty03/fat_period>) gem, which combines fat\_core's extended Range class with its extended Date class to make a useful Period class for date ranges, and you may find fat\_core's extended Range class likewise useful.
595
606
 
596
607
 
597
- <a id="orgdd06e2c"></a>
608
+ <a id="org9c96e6a"></a>
598
609
 
599
610
  ### Methods `#contiguous`, `#left_contiguous`, `#right_contiguous`
600
611
 
@@ -633,12 +644,12 @@ result
633
644
  | 3.146..12.3 | 0.5..3.145 | false | false | false |
634
645
  | a..q | r..z | true | true | false |
635
646
  | a..q | s..z | false | false | false |
636
- | 1963-11-22..1964-11-03 | 1964-11-04..2026-05-29 | true | true | false |
637
- | 1963-11-22..1964-11-03 | 1964-11-28..2026-05-29 | false | false | false |
647
+ | 1963-11-22..1964-11-03 | 1964-11-04..2026-11-28 | true | true | false |
648
+ | 1963-11-22..1964-11-03 | 1964-11-28..2026-11-28 | false | false | false |
638
649
  ```
639
650
 
640
651
 
641
- <a id="org28a7d95"></a>
652
+ <a id="org7ce66d2"></a>
642
653
 
643
654
  ### Method `#join(other)`
644
655
 
@@ -677,12 +688,12 @@ result
677
688
  | 3.146..12.3 | 0.5..3.145 | false | |
678
689
  | a..q | r..z | true | a..z |
679
690
  | a..q | s..z | false | |
680
- | 1963-11-22..1964-11-03 | 1964-11-04..2026-05-29 | true | 1963-11-22..2026-05-29 |
681
- | 1963-11-22..1964-11-03 | 1964-11-28..2026-05-29 | false | |
691
+ | 1963-11-22..1964-11-03 | 1964-11-04..2026-11-28 | true | 1963-11-22..2026-11-28 |
692
+ | 1963-11-22..1964-11-03 | 1964-11-28..2026-11-28 | false | |
682
693
  ```
683
694
 
684
695
 
685
- <a id="org5d367a6"></a>
696
+ <a id="org84b3a46"></a>
686
697
 
687
698
  ### Method `#spanned_by?(others)`
688
699
 
@@ -722,7 +733,7 @@ result
722
733
  ```
723
734
 
724
735
 
725
- <a id="orga33fd47"></a>
736
+ <a id="org7873f20"></a>
726
737
 
727
738
  ### Methods `#gaps(others)`, `#overlaps(others)`
728
739
 
@@ -764,14 +775,21 @@ result
764
775
  ```
765
776
 
766
777
 
767
- <a id="orgbd1bd5e"></a>
778
+ <a id="org185182e"></a>
768
779
 
769
780
  ## String
770
781
 
771
- FatCore::String has methods for performing matching of one string with another (`#matches_with`, `#fuzzy_match`), for converting a string to title-case as might by used in the title of a book (`#entitle`), for converting a String into a useable Symbol (`#as_sym`) and vice-versa (`#as_str` also `Symbol#as_str`), for wrapping with an optional hanging indent (`#wrap`), cleaning up errant spaces (`#clean`), and computing the Damerau-Levenshtein distance between strings (`#distance`). And several others.
782
+ FatCore::String has methods for performing matching of one string with another (`#matches_with`, `#fuzzy_match`), for converting a string to title-case as might by used in the title of a book (`#entitle`), for converting a String into a useable Symbol (`#as_sym`) and vice-versa (`#as_str` also `Symbol#as_str`), for wrapping with an optional hanging indent (`#wrap`), cleaning up errant spaces (`#clean`), and computing the Levenshtein distance between strings (`#distance`). And several others.
783
+
784
+
785
+ <a id="org5aface9"></a>
786
+
787
+ ### Inspecting compiled matchers
788
+
789
+ `pattern.matcher_regexp` returns the exact Ruby Regexp used by `subject.matches_with(pattern)`. For example, `'st:lukes'.matcher_regexp` returns `/st.*\blukes/i`. Explicit slash-delimited regex flags are preserved. For ordinary fuzzy patterns, apply this regex to the same punctuation- and whitespace-normalized subject used by `fuzzy_match`, not to the raw name. Use `pattern.fuzzy_regexp` for the regex specifically used by `fuzzy_match`. These methods expose compilation for diagnostics without performing a match.
772
790
 
773
791
 
774
- <a id="org63111cb"></a>
792
+ <a id="org48e4298"></a>
775
793
 
776
794
  ### Method `#fuzzy_match`
777
795
 
@@ -818,7 +836,7 @@ result
818
836
  ```
819
837
 
820
838
 
821
- <a id="orgdae93bf"></a>
839
+ <a id="org6d57e8b"></a>
822
840
 
823
841
  ### Method `#matches_with`
824
842
 
@@ -850,7 +868,7 @@ result
850
868
  ```
851
869
 
852
870
 
853
- <a id="org1a5d1e4"></a>
871
+ <a id="org52ff40e"></a>
854
872
 
855
873
  ### Method `#entitle`
856
874
 
@@ -879,11 +897,11 @@ result
879
897
  ```
880
898
 
881
899
 
882
- <a id="orgd671ee5"></a>
900
+ <a id="org3c83e29"></a>
883
901
 
884
902
  ### Method `#distance`
885
903
 
886
- `FatCore` provides `distance` as a simple wrapper around the Damerau-Levenshtein distance function in `damerau-levenshtein` gem, using a block size of 1 and a max distance of 10.
904
+ `FatCore` provides `distance` as a simple wrapper around the Levenshtein distance function in Ruby's bundled `DidYouMean` library. Insertions, deletions, and substitutions each count as one edit; swapping adjacent letters counts as two. Distances above 10 return 11, preserving the existing ceiling. No native extension is needed.
887
905
 
888
906
  ```ruby
889
907
  result = []
@@ -907,7 +925,7 @@ result
907
925
  ```
908
926
 
909
927
 
910
- <a id="orgfdd51bd"></a>
928
+ <a id="org55c0282"></a>
911
929
 
912
930
  ### Method `#commas(places)`
913
931
 
@@ -938,7 +956,7 @@ result
938
956
  ```
939
957
 
940
958
 
941
- <a id="org826950e"></a>
959
+ <a id="org7e7e1fe"></a>
942
960
 
943
961
  ### Method `#wrap(width, hang)`
944
962
 
@@ -1042,7 +1060,7 @@ Four score and seven years ago our
1042
1060
  ```
1043
1061
 
1044
1062
 
1045
- <a id="orgc017d90"></a>
1063
+ <a id="orgedcd6ea"></a>
1046
1064
 
1047
1065
  ### Method `#as_sym`
1048
1066
 
@@ -1057,7 +1075,7 @@ Convert a `String` to a `Symbol` by converting all letters to lower-case, replac
1057
1075
  ```
1058
1076
 
1059
1077
 
1060
- <a id="org3459d99"></a>
1078
+ <a id="org5bbf8f0"></a>
1061
1079
 
1062
1080
  ### Method `gut`
1063
1081
 
@@ -1118,12 +1136,12 @@ ClassAComonStock
1118
1136
  ```
1119
1137
 
1120
1138
 
1121
- <a id="org2241c53"></a>
1139
+ <a id="orgb31753f"></a>
1122
1140
 
1123
1141
  ## Symbol
1124
1142
 
1125
1143
 
1126
- <a id="orgf2478cc"></a>
1144
+ <a id="orgfff0afa"></a>
1127
1145
 
1128
1146
  ### Method `#as_str`
1129
1147
 
@@ -1138,7 +1156,7 @@ hello-to-the-world
1138
1156
  ```
1139
1157
 
1140
1158
 
1141
- <a id="org5620bc3"></a>
1159
+ <a id="org49836ae"></a>
1142
1160
 
1143
1161
  ## TeX Quoting
1144
1162
 
@@ -1181,14 +1199,14 @@ result
1181
1199
  | Complex | 5.0+3.0i | "$5+3i$" |
1182
1200
  | Rational | 5/3 | "$\\frac{5}{3}$" |
1183
1201
  | Rational | 8/17 | "$\\frac{8}{17}$" |
1184
- | Range | 2020-09-22..2026-05-29 | "(2020-09-22..2026-05-29)" |
1202
+ | Range | 2020-09-22..2026-11-28 | "(2020-09-22..2026-11-28)" |
1185
1203
  | Range | 2.718281828459045..3.141592653589793 | "($e$..$\\pi$)" |
1186
1204
  | Symbol | four_score_and_7_years | "four\\_score\\_and\\_7\\_years" |
1187
1205
  | NilClass | | "" |
1188
1206
  ```
1189
1207
 
1190
1208
 
1191
- <a id="orgfe2e72b"></a>
1209
+ <a id="orga6d91af"></a>
1192
1210
 
1193
1211
  # Contributing
1194
1212
 
data/README.org CHANGED
@@ -7,6 +7,11 @@
7
7
  #+PROPERTY: header-args:sh :exports code :eval no
8
8
  #+PROPERTY: header-args:bash :exports code :eval no
9
9
 
10
+ # gem_docs:version begin
11
+ Version: 7.5.0
12
+ # gem_docs:version end
13
+
14
+
10
15
  #+BEGIN_EXPORT markdown
11
16
  [![CI](https://github.com/ddoherty03/fat_core/actions/workflows/ruby.yml/badge.svg?branch=master)](https://github.com/ddoherty03/fat_core/actions/workflows/ruby.yml)
12
17
  #+END_EXPORT
@@ -18,7 +23,7 @@
18
23
 
19
24
  #+RESULTS:
20
25
  #+begin_example
21
- Current version is: 7.1.3
26
+ Current version is: 7.5.0
22
27
  #+end_example
23
28
 
24
29
  * Introduction
@@ -175,7 +180,8 @@ Array are included in the result /unless/ they also appear in any of the
175
180
  | hammers | glue | bolts | hammers |
176
181
  #+end_example
177
182
 
178
- ** BigDecimal ~#inspect~
183
+ ** BigDecimal
184
+ *** Method ~#inspect~
179
185
  ~FatCore~ provides nothing but a better ~#inspect~ method for the ~BigDecimal~
180
186
  class since the default inspect method is not very readable.
181
187
 
@@ -279,7 +285,7 @@ equals the given value or values:
279
285
 
280
286
  #+RESULTS:
281
287
  #+begin_example
282
- {:a=>1, :c=>3, :e=>1}
288
+ {a: 1, c: 3, e: 1}
283
289
  #+end_example
284
290
 
285
291
  You can supply multiple values for deletion:
@@ -292,7 +298,7 @@ You can supply multiple values for deletion:
292
298
 
293
299
  #+RESULTS:
294
300
  #+begin_example
295
- {:b=>2, :d=>2}
301
+ {b: 2, d: 2}
296
302
  #+end_example
297
303
 
298
304
  The non-bang method returns a clone of the Hash with the given deletions made:
@@ -306,8 +312,8 @@ The non-bang method returns a clone of the Hash with the given deletions made:
306
312
 
307
313
  #+RESULTS:
308
314
  #+begin_example
309
- {:a=>1, :b=>2, :c=>3, :d=>2, :e=>1}
310
- {:b=>2, :d=>2}
315
+ {a: 1, b: 2, c: 3, d: 2, e: 1}
316
+ {b: 2, d: 2}
311
317
  #+end_example
312
318
 
313
319
  *** Method ~#keys_with_value~
@@ -349,7 +355,7 @@ original ~Hash~ is not effected.
349
355
 
350
356
  #+RESULTS:
351
357
  #+begin_example
352
- "{:A=>1, :B=>2, :c=>3, :d=>2, :e=>1}"
358
+ "{A: 1, B: 2, c: 3, d: 2, e: 1}"
353
359
  #+end_example
354
360
 
355
361
  These days, a more systematic job could be done with ~#transform_keys~:
@@ -360,7 +366,7 @@ These days, a more systematic job could be done with ~#transform_keys~:
360
366
 
361
367
  #+RESULTS:
362
368
  #+begin_example
363
- "{:A=>1, :B=>2, :C=>3, :D=>2, :E=>1}"
369
+ "{A: 1, B: 2, C: 3, D: 2, E: 1}"
364
370
  #+end_example
365
371
 
366
372
  *** Method ~#replace_keys~
@@ -373,7 +379,7 @@ A wholesale replacement of the existing keys can be done with this method:
373
379
 
374
380
  #+RESULTS:
375
381
  #+begin_example
376
- "{:z=>1, :y=>2, :x=>3, :w=>2, :v=>1}"
382
+ "{z: 1, y: 2, x: 3, w: 2, v: 1}"
377
383
  #+end_example
378
384
 
379
385
  *** Alias ~#merge~ to ~<<~
@@ -387,7 +393,7 @@ provide a pretty way to represent the merger of the right ~Hash~ into the left
387
393
 
388
394
  #+RESULTS:
389
395
  #+begin_example
390
- {:a=>"A", :b=>"B", :c=>"CC", :d=>"DDD", :e=>"EEE"}
396
+ {a: "A", b: "B", c: "CC", d: "DDD", e: "EEE"}
391
397
  #+end_example
392
398
 
393
399
  It groups values into pairs and applies the ~#to_h~ method to the right-hand
@@ -414,7 +420,7 @@ is an ~Array~ or ~Enumerable~:
414
420
 
415
421
  #+RESULTS:
416
422
  #+begin_example
417
- {:a=>"A", :b=>"B", :c=>"CC", :d=>"DDD", :e=>"EEE", "f"=>"FFFF", "g"=>"GGGG", :h=>"HHHHH", :j=>"JJJJJ"}
423
+ {a: "A", b: "B", c: "CC", d: "DDD", e: "EEE", "f" => "FFFF", "g" => "GGGG", h: "HHHHH", j: "JJJJJ"}
418
424
  #+end_example
419
425
 
420
426
  ** Numeric
@@ -582,8 +588,8 @@ the max value of the left ~Range~ must equal the min value of the right
582
588
  | 3.146..12.3 | 0.5..3.145 | false | false | false |
583
589
  | a..q | r..z | true | true | false |
584
590
  | a..q | s..z | false | false | false |
585
- | 1963-11-22..1964-11-03 | 1964-11-04..2026-05-29 | true | true | false |
586
- | 1963-11-22..1964-11-03 | 1964-11-28..2026-05-29 | false | false | false |
591
+ | 1963-11-22..1964-11-03 | 1964-11-04..2026-11-28 | true | true | false |
592
+ | 1963-11-22..1964-11-03 | 1964-11-28..2026-11-28 | false | false | false |
587
593
  #+end_example
588
594
 
589
595
  *** Method ~#join(other)~
@@ -624,8 +630,8 @@ two ~Range~s into one ~Range~.
624
630
  | 3.146..12.3 | 0.5..3.145 | false | |
625
631
  | a..q | r..z | true | a..z |
626
632
  | a..q | s..z | false | |
627
- | 1963-11-22..1964-11-03 | 1964-11-04..2026-05-29 | true | 1963-11-22..2026-05-29 |
628
- | 1963-11-22..1964-11-03 | 1964-11-28..2026-05-29 | false | |
633
+ | 1963-11-22..1964-11-03 | 1964-11-04..2026-11-28 | true | 1963-11-22..2026-11-28 |
634
+ | 1963-11-22..1964-11-03 | 1964-11-28..2026-11-28 | false | |
629
635
  #+end_example
630
636
 
631
637
  *** Method ~#spanned_by?(others)~
@@ -718,9 +724,18 @@ FatCore::String has methods for performing matching of one string with another
718
724
  might by used in the title of a book (~#entitle~), for converting a String
719
725
  into a useable Symbol (~#as_sym~) and vice-versa (~#as_str~ also
720
726
  ~Symbol#as_str~), for wrapping with an optional hanging indent (~#wrap~),
721
- cleaning up errant spaces (~#clean~), and computing the Damerau-Levenshtein
727
+ cleaning up errant spaces (~#clean~), and computing the Levenshtein
722
728
  distance between strings (~#distance~). And several others.
723
729
 
730
+ *** Inspecting compiled matchers
731
+ ~pattern.matcher_regexp~ returns the exact Ruby Regexp used by
732
+ ~subject.matches_with(pattern)~. For example, ~'st:lukes'.matcher_regexp~
733
+ returns ~/st.*\blukes/i~. Explicit slash-delimited regex flags are preserved.
734
+ For ordinary fuzzy patterns, apply this regex to the same punctuation- and
735
+ whitespace-normalized subject used by ~fuzzy_match~, not to the raw name.
736
+ Use ~pattern.fuzzy_regexp~ for the regex specifically used by ~fuzzy_match~.
737
+ These methods expose compilation for diagnostics without performing a match.
738
+
724
739
  *** Method ~#fuzzy_match~
725
740
  The ~#fuzzy_match~ method determines whether the subject string matches the
726
741
  given "matcher" string, which provides a simple syntax that allows a limited
@@ -851,8 +866,10 @@ something like "In the Heat of the Night".
851
866
 
852
867
  *** Method ~#distance~
853
868
  ~FatCore~ provides ~distance~ as a simple wrapper around the
854
- Damerau-Levenshtein distance function in ~damerau-levenshtein~ gem, using a
855
- block size of 1 and a max distance of 10.
869
+ Levenshtein distance function in Ruby's bundled ~DidYouMean~ library.
870
+ Insertions, deletions, and substitutions each count as one edit; swapping
871
+ adjacent letters counts as two. Distances above 10 return 11, preserving
872
+ the existing ceiling. No native extension is needed.
856
873
 
857
874
  #+begin_src ruby
858
875
  result = []
@@ -1152,7 +1169,7 @@ deploys TeX notation when special notation is available, for example, a
1152
1169
  | Complex | 5.0+3.0i | "$5+3i$" |
1153
1170
  | Rational | 5/3 | "$\\frac{5}{3}$" |
1154
1171
  | Rational | 8/17 | "$\\frac{8}{17}$" |
1155
- | Range | 2020-09-22..2026-05-29 | "(2020-09-22..2026-05-29)" |
1172
+ | Range | 2020-09-22..2026-11-28 | "(2020-09-22..2026-11-28)" |
1156
1173
  | Range | 2.718281828459045..3.141592653589793 | "($e$..$\\pi$)" |
1157
1174
  | Symbol | four_score_and_7_years | "four\\_score\\_and\\_7\\_years" |
1158
1175
  | NilClass | | "" |
data/fat_core.gemspec CHANGED
@@ -27,7 +27,6 @@ Gem::Specification.new do |spec|
27
27
  spec.require_paths = ['lib']
28
28
 
29
29
  spec.add_dependency 'activesupport'
30
- spec.add_dependency 'damerau-levenshtein'
31
30
  spec.add_dependency 'ostruct'
32
31
  spec.add_dependency 'stringio', '>=3.1.2'
33
32
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'bigdecimal'
4
4
  require 'fat_core/patches'
5
- require 'damerau-levenshtein'
5
+ require 'did_you_mean/levenshtein'
6
6
  require 'active_support/core_ext/regexp'
7
7
  require_relative 'numeric'
8
8
 
@@ -215,14 +215,14 @@ module FatCore
215
215
  # @group Matching
216
216
  # :section: Matching
217
217
 
218
- # Return the Damerau-Levenshtein distance between self an another string
219
- # using a transposition block size of 1 and quitting if a max distance of 10
220
- # is reached.
218
+ # Return the Levenshtein distance between self and another string.
219
+ # Distances above 10 return 11, preserving the existing ceiling.
220
+ # Swapping adjacent characters counts as two edits.
221
221
  #
222
222
  # @param other [#to_s] string to compute self's distance from
223
223
  # @return [Integer] the distance between self and other
224
224
  def distance(other)
225
- DamerauLevenshtein.distance(self, other.to_s, 1, 10)
225
+ [DidYouMean::Levenshtein.distance(self, other.to_s), 11].min
226
226
  end
227
227
 
228
228
  # Return the matched portion of self, with fuzzy-match punctuation normalized,
@@ -267,19 +267,30 @@ module FatCore
267
267
  # @return [String] the portion of the subject that matched
268
268
  # @return [nil] if the subject did not match
269
269
  def fuzzy_match(matcher)
270
- if matcher.match?(%r{\A/.*/\z})
271
- regexp = Regexp.new(matcher[1...-1], Regexp::IGNORECASE)
272
- subject = self
270
+ subject = matcher.match?(%r{\A/.*/\z}) ? self : fuzzy_match_clean(self)
271
+ match = matcher.fuzzy_regexp.match(subject)
272
+ match[0] if match
273
+ end
274
+
275
+ # Compile self as a fuzzy matcher. Ordinary patterns match normalized
276
+ # subjects (see #fuzzy_match); slash-wrapped regexes match original text.
277
+ # @return [Regexp]
278
+ def fuzzy_regexp
279
+ if match?(%r{\A/.*/\z})
280
+ Regexp.new(self[1...-1], Regexp::IGNORECASE)
273
281
  else
274
- subject = fuzzy_match_clean(self)
275
- matcher = fuzzy_match_clean(matcher)
276
- regexp = Regexp.new(fuzzy_match_regexp(matcher), Regexp::IGNORECASE)
282
+ Regexp.new(fuzzy_match_regexp(fuzzy_match_clean(self)), Regexp::IGNORECASE)
277
283
  end
278
- matched_text =
279
- if (match = regexp.match(subject))
280
- match[0]
281
- end
282
- matched_text
284
+ end
285
+
286
+ # Return the exact regex used when self is passed to #matches_with.
287
+ # Explicit regex modifiers are preserved; fuzzy regexes operate on
288
+ # punctuation/whitespace-normalized subjects, not the original text.
289
+ # @example
290
+ # 'st:lukes'.matcher_regexp #=> /st.*\\blukes/i
291
+ # @return [Regexp]
292
+ def matcher_regexp
293
+ match?(%r{^\s*/}) ? as_regexp : fuzzy_regexp
283
294
  end
284
295
 
285
296
  # Test whether self matches the `matcher` treating `matcher` as a
@@ -295,13 +306,9 @@ module FatCore
295
306
  def matches_with(matcher)
296
307
  return if matcher.nil?
297
308
 
298
- if matcher.match?(%r{^\s*/})
299
- re = matcher.as_regexp
300
- md = match(re)
301
- md[0] if md
302
- else
303
- fuzzy_match(matcher)
304
- end
309
+ subject = matcher.match?(%r{^\s*/}) ? self : fuzzy_match_clean(self)
310
+ match = matcher.matcher_regexp.match(subject)
311
+ match[0] if match
305
312
  end
306
313
 
307
314
  # Convert a string of the form '/.../Iixm' to a regular
@@ -377,8 +384,6 @@ module FatCore
377
384
  to_f.commas(places)
378
385
  end
379
386
 
380
- private
381
-
382
387
  def fuzzy_match_regexp(matcher)
383
388
  start_anchor = matcher.start_with?(':')
384
389
  end_anchor = matcher.end_with?(':')
@@ -2,7 +2,7 @@
2
2
 
3
3
  module FatCore
4
4
  MAJOR = 7
5
- MINOR = 3
5
+ MINOR = 5
6
6
  PATCH = 0
7
7
 
8
8
  # FatCore version number
@@ -246,7 +246,7 @@ the people, for the people, shall not perish from the earth."
246
246
  end
247
247
 
248
248
  it 'computes its Levenshtein distance from another string' do
249
- expect('Something'.distance('Smoething')).to eq 1
249
+ expect('Something'.distance('Smoething')).to eq 2
250
250
  expect('Something'.distance('meSothing')).to eq 4
251
251
  expect('SomethingElse'.distance('Encyclopedia')).to eq 11
252
252
  expect('SomethingElseUnrelated'.distance('EncyclopediaBritanica'))
@@ -254,6 +254,20 @@ the people, for the people, shall not perish from the earth."
254
254
  expect('SomethingElseUnrelated'.distance('EncyclopediaBritanica')).to eq 11
255
255
  end
256
256
 
257
+ it 'handles identical, empty, Unicode, and non-string inputs' do
258
+ expect('same'.distance('same')).to eq 0
259
+ expect(''.distance('abc')).to eq 3
260
+ expect('abc'.distance('')).to eq 3
261
+ expect('café'.distance('cafe')).to eq 1
262
+ expect('123'.distance(123)).to eq 0
263
+ expect(''.distance(nil)).to eq 0
264
+ end
265
+
266
+ it 'caps distances above ten at eleven' do
267
+ expect(('a' * 10).distance('')).to eq 10
268
+ expect(('a' * 12).distance('')).to eq 11
269
+ end
270
+
257
271
  describe 'Quoting' do
258
272
  it 'quotes special TeX characters' do
259
273
  expect('$10,000'.tex_quote).to eq('\\$10,000')
@@ -447,5 +461,23 @@ the people, for the people, shall not perish from the earth."
447
461
  expect("St. Luke's Hospital".matches_with('/LUKE/I')).to be_nil
448
462
  end
449
463
  end
464
+
465
+ describe 'compiled string matchers' do
466
+ it 'exposes the fuzzy word-boundary pattern' do
467
+ expect('st:lukes'.matcher_regexp).to eq(/st.*\blukes/i)
468
+ expect("St. Luke's Hospital".matches_with('st:lukes')).to eq('St Lukes')
469
+ end
470
+
471
+ it 'preserves anchoring and normalized punctuation' do
472
+ expect(':Amazon.com:'.matcher_regexp).to eq(/\AAmazon.*com\z/i)
473
+ expect('Amazon.com'.matches_with(':Amazon.com:')).to eq('Amazon com')
474
+ end
475
+
476
+ it 'preserves explicit regex flags and matches original punctuation' do
477
+ expect('/Luke/I'.matcher_regexp).to eq(/Luke/)
478
+ expect('luke'.matches_with('/Luke/I')).to be_nil
479
+ expect("St. Luke's".matches_with('/St\\./')).to eq('St.')
480
+ end
481
+ end
450
482
  end
451
483
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fat_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.3.0
4
+ version: 7.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel E. Doherty
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-08-11 00:00:00.000000000 Z
10
+ date: 2026-11-28 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -24,20 +23,6 @@ dependencies:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
25
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: damerau-levenshtein
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
26
  - !ruby/object:Gem::Dependency
42
27
  name: ostruct
43
28
  requirement: !ruby/object:Gem::Requirement
@@ -89,6 +74,7 @@ files:
89
74
  - CHANGELOG.md
90
75
  - CHANGELOG.org
91
76
  - Gemfile
77
+ - Gemfile.lock
92
78
  - LICENSE.txt
93
79
  - README.md
94
80
  - README.org
@@ -125,7 +111,6 @@ licenses:
125
111
  - MIT
126
112
  metadata:
127
113
  yard.run: yri
128
- post_install_message:
129
114
  rdoc_options: []
130
115
  require_paths:
131
116
  - lib
@@ -140,8 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
125
  - !ruby/object:Gem::Version
141
126
  version: '0'
142
127
  requirements: []
143
- rubygems_version: 3.5.23
144
- signing_key:
128
+ rubygems_version: 3.6.2
145
129
  specification_version: 4
146
130
  summary: some useful core extensions
147
131
  test_files: []