fat_core 7.4.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: ab67f4ddf21be6773a44d0361acdc01257e4f390222c0a5da8434dadc80b108c
4
- data.tar.gz: 33f3e511b3d2e1262d979f9909d8ad5a0a3c8b638756fb1a25dddaf302dcef65
3
+ metadata.gz: 6f4b84a879ef64ab6054af28511bf9c87975baeef65d006008d4351cbed07be4
4
+ data.tar.gz: 27cc94fe92188194ef68ab18c7dab74e5f80440b321df848b494405c17ea0f46
5
5
  SHA512:
6
- metadata.gz: 2e78ef4bf3001f91e8c43b7dd6216f5edc65aa8945db4dd79e77d75506a8233d30fafdc01e5e27099f53ee01daffe12fdeb06d7da04cbc9f28d5bce65005e502
7
- data.tar.gz: a6dcf793b1d698e667570d40d89d2cced098b08d81d70d42e7a908eed1f787bfffcbd8cd0e1d6c1c732fe3472f2f84f9cf5d5fc2aa51c9e69b2a2417ce1a6497
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/Gemfile.lock CHANGED
@@ -1,18 +1,18 @@
1
1
  GIT
2
2
  remote: https://github.com/ddoherty03/rubocop-ddoherty.git
3
- revision: 6b28e9614f18f94b684179c488acca8ac6cabdc6
3
+ revision: e20a30ef08d9b8ded242cf6b66fa20500c8045c6
4
4
  branch: master
5
5
  specs:
6
- rubocop-ddoherty (0.1.2)
6
+ rubocop-ddoherty (0.1.3)
7
+ rubocop (~> 1.62)
7
8
  rubocop-performance (~> 1.0)
8
9
  rubocop-rake (>= 0.7)
9
10
  rubocop-rspec (~> 3.0)
10
- rubocop-shopify (~> 2.0)
11
11
 
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- fat_core (7.4.0)
15
+ fat_core (7.5.0)
16
16
  activesupport
17
17
  ostruct
18
18
  stringio (>= 3.1.2)
@@ -47,9 +47,9 @@ GEM
47
47
  docile (1.4.1)
48
48
  drb (2.2.3)
49
49
  erb (6.0.1)
50
- gem_docs (0.2.0)
50
+ gem_docs (0.4.0)
51
51
  rake
52
- yard
52
+ yard (>= 0.9.28)
53
53
  i18n (1.14.8)
54
54
  concurrent-ruby (~> 1.0)
55
55
  io-console (0.8.2)
@@ -85,7 +85,7 @@ GEM
85
85
  stringio
86
86
  racc (1.8.1)
87
87
  rainbow (3.1.1)
88
- rake (13.3.1)
88
+ rake (13.4.2)
89
89
  rdoc (7.0.3)
90
90
  erb
91
91
  psych (>= 4.0.0)
@@ -131,8 +131,6 @@ GEM
131
131
  rubocop-rspec (3.8.0)
132
132
  lint_roller (~> 1.1)
133
133
  rubocop (~> 1.81)
134
- rubocop-shopify (2.18.0)
135
- rubocop (~> 1.62)
136
134
  ruby-progressbar (1.13.0)
137
135
  securerandom (0.4.1)
138
136
  simplecov (0.22.0)
@@ -149,7 +147,7 @@ GEM
149
147
  unicode-emoji (~> 4.1)
150
148
  unicode-emoji (4.2.0)
151
149
  uri (1.1.1)
152
- yard (0.9.38)
150
+ yard (0.9.45)
153
151
 
154
152
  PLATFORMS
155
153
  ruby
@@ -170,4 +168,4 @@ DEPENDENCIES
170
168
  simplecov
171
169
 
172
170
  BUNDLED WITH
173
- 2.6.7
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
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.
772
783
 
773
784
 
774
- <a id="org63111cb"></a>
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.
790
+
791
+
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,7 +897,7 @@ 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
 
@@ -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
@@ -280,7 +285,7 @@ equals the given value or values:
280
285
 
281
286
  #+RESULTS:
282
287
  #+begin_example
283
- {:a=>1, :c=>3, :e=>1}
288
+ {a: 1, c: 3, e: 1}
284
289
  #+end_example
285
290
 
286
291
  You can supply multiple values for deletion:
@@ -293,7 +298,7 @@ You can supply multiple values for deletion:
293
298
 
294
299
  #+RESULTS:
295
300
  #+begin_example
296
- {:b=>2, :d=>2}
301
+ {b: 2, d: 2}
297
302
  #+end_example
298
303
 
299
304
  The non-bang method returns a clone of the Hash with the given deletions made:
@@ -307,8 +312,8 @@ The non-bang method returns a clone of the Hash with the given deletions made:
307
312
 
308
313
  #+RESULTS:
309
314
  #+begin_example
310
- {:a=>1, :b=>2, :c=>3, :d=>2, :e=>1}
311
- {:b=>2, :d=>2}
315
+ {a: 1, b: 2, c: 3, d: 2, e: 1}
316
+ {b: 2, d: 2}
312
317
  #+end_example
313
318
 
314
319
  *** Method ~#keys_with_value~
@@ -350,7 +355,7 @@ original ~Hash~ is not effected.
350
355
 
351
356
  #+RESULTS:
352
357
  #+begin_example
353
- "{:A=>1, :B=>2, :c=>3, :d=>2, :e=>1}"
358
+ "{A: 1, B: 2, c: 3, d: 2, e: 1}"
354
359
  #+end_example
355
360
 
356
361
  These days, a more systematic job could be done with ~#transform_keys~:
@@ -361,7 +366,7 @@ These days, a more systematic job could be done with ~#transform_keys~:
361
366
 
362
367
  #+RESULTS:
363
368
  #+begin_example
364
- "{:A=>1, :B=>2, :C=>3, :D=>2, :E=>1}"
369
+ "{A: 1, B: 2, C: 3, D: 2, E: 1}"
365
370
  #+end_example
366
371
 
367
372
  *** Method ~#replace_keys~
@@ -374,7 +379,7 @@ A wholesale replacement of the existing keys can be done with this method:
374
379
 
375
380
  #+RESULTS:
376
381
  #+begin_example
377
- "{:z=>1, :y=>2, :x=>3, :w=>2, :v=>1}"
382
+ "{z: 1, y: 2, x: 3, w: 2, v: 1}"
378
383
  #+end_example
379
384
 
380
385
  *** Alias ~#merge~ to ~<<~
@@ -388,7 +393,7 @@ provide a pretty way to represent the merger of the right ~Hash~ into the left
388
393
 
389
394
  #+RESULTS:
390
395
  #+begin_example
391
- {:a=>"A", :b=>"B", :c=>"CC", :d=>"DDD", :e=>"EEE"}
396
+ {a: "A", b: "B", c: "CC", d: "DDD", e: "EEE"}
392
397
  #+end_example
393
398
 
394
399
  It groups values into pairs and applies the ~#to_h~ method to the right-hand
@@ -415,7 +420,7 @@ is an ~Array~ or ~Enumerable~:
415
420
 
416
421
  #+RESULTS:
417
422
  #+begin_example
418
- {: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"}
419
424
  #+end_example
420
425
 
421
426
  ** Numeric
@@ -583,8 +588,8 @@ the max value of the left ~Range~ must equal the min value of the right
583
588
  | 3.146..12.3 | 0.5..3.145 | false | false | false |
584
589
  | a..q | r..z | true | true | false |
585
590
  | a..q | s..z | false | false | false |
586
- | 1963-11-22..1964-11-03 | 1964-11-04..2026-05-29 | true | true | false |
587
- | 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 |
588
593
  #+end_example
589
594
 
590
595
  *** Method ~#join(other)~
@@ -625,8 +630,8 @@ two ~Range~s into one ~Range~.
625
630
  | 3.146..12.3 | 0.5..3.145 | false | |
626
631
  | a..q | r..z | true | a..z |
627
632
  | a..q | s..z | false | |
628
- | 1963-11-22..1964-11-03 | 1964-11-04..2026-05-29 | true | 1963-11-22..2026-05-29 |
629
- | 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 | |
630
635
  #+end_example
631
636
 
632
637
  *** Method ~#spanned_by?(others)~
@@ -722,6 +727,15 @@ into a useable Symbol (~#as_sym~) and vice-versa (~#as_str~ also
722
727
  cleaning up errant spaces (~#clean~), and computing the Levenshtein
723
728
  distance between strings (~#distance~). And several others.
724
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
+
725
739
  *** Method ~#fuzzy_match~
726
740
  The ~#fuzzy_match~ method determines whether the subject string matches the
727
741
  given "matcher" string, which provides a simple syntax that allows a limited
@@ -1155,7 +1169,7 @@ deploys TeX notation when special notation is available, for example, a
1155
1169
  | Complex | 5.0+3.0i | "$5+3i$" |
1156
1170
  | Rational | 5/3 | "$\\frac{5}{3}$" |
1157
1171
  | Rational | 8/17 | "$\\frac{8}{17}$" |
1158
- | 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)" |
1159
1173
  | Range | 2.718281828459045..3.141592653589793 | "($e$..$\\pi$)" |
1160
1174
  | Symbol | four_score_and_7_years | "four\\_score\\_and\\_7\\_years" |
1161
1175
  | NilClass | | "" |
@@ -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 = 4
5
+ MINOR = 5
6
6
  PATCH = 0
7
7
 
8
8
  # FatCore version number
@@ -461,5 +461,23 @@ the people, for the people, shall not perish from the earth."
461
461
  expect("St. Luke's Hospital".matches_with('/LUKE/I')).to be_nil
462
462
  end
463
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
464
482
  end
465
483
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fat_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.4.0
4
+ version: 7.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel E. Doherty
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-10-07 00:00:00.000000000 Z
10
+ date: 2026-11-28 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activesupport