fat_core 7.3.0 → 7.4.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 +4 -4
- data/.gitignore +1 -1
- data/Gemfile.lock +173 -0
- data/README.md +2 -2
- data/README.org +7 -4
- data/fat_core.gemspec +0 -1
- data/lib/fat_core/string.rb +5 -5
- data/lib/fat_core/version.rb +1 -1
- data/spec/lib/string_spec.rb +15 -1
- metadata +4 -20
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ab67f4ddf21be6773a44d0361acdc01257e4f390222c0a5da8434dadc80b108c
|
|
4
|
+
data.tar.gz: 33f3e511b3d2e1262d979f9909d8ad5a0a3c8b638756fb1a25dddaf302dcef65
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2e78ef4bf3001f91e8c43b7dd6216f5edc65aa8945db4dd79e77d75506a8233d30fafdc01e5e27099f53ee01daffe12fdeb06d7da04cbc9f28d5bce65005e502
|
|
7
|
+
data.tar.gz: a6dcf793b1d698e667570d40d89d2cced098b08d81d70d42e7a908eed1f787bfffcbd8cd0e1d6c1c732fe3472f2f84f9cf5d5fc2aa51c9e69b2a2417ce1a6497
|
data/.gitignore
CHANGED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
GIT
|
|
2
|
+
remote: https://github.com/ddoherty03/rubocop-ddoherty.git
|
|
3
|
+
revision: 6b28e9614f18f94b684179c488acca8ac6cabdc6
|
|
4
|
+
branch: master
|
|
5
|
+
specs:
|
|
6
|
+
rubocop-ddoherty (0.1.2)
|
|
7
|
+
rubocop-performance (~> 1.0)
|
|
8
|
+
rubocop-rake (>= 0.7)
|
|
9
|
+
rubocop-rspec (~> 3.0)
|
|
10
|
+
rubocop-shopify (~> 2.0)
|
|
11
|
+
|
|
12
|
+
PATH
|
|
13
|
+
remote: .
|
|
14
|
+
specs:
|
|
15
|
+
fat_core (7.4.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.2.0)
|
|
51
|
+
rake
|
|
52
|
+
yard
|
|
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.3.1)
|
|
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
|
+
rubocop-shopify (2.18.0)
|
|
135
|
+
rubocop (~> 1.62)
|
|
136
|
+
ruby-progressbar (1.13.0)
|
|
137
|
+
securerandom (0.4.1)
|
|
138
|
+
simplecov (0.22.0)
|
|
139
|
+
docile (~> 1.1)
|
|
140
|
+
simplecov-html (~> 0.11)
|
|
141
|
+
simplecov_json_formatter (~> 0.1)
|
|
142
|
+
simplecov-html (0.13.2)
|
|
143
|
+
simplecov_json_formatter (0.1.4)
|
|
144
|
+
stringio (3.2.0)
|
|
145
|
+
tsort (0.2.0)
|
|
146
|
+
tzinfo (2.0.6)
|
|
147
|
+
concurrent-ruby (~> 1.0)
|
|
148
|
+
unicode-display_width (3.2.0)
|
|
149
|
+
unicode-emoji (~> 4.1)
|
|
150
|
+
unicode-emoji (4.2.0)
|
|
151
|
+
uri (1.1.1)
|
|
152
|
+
yard (0.9.38)
|
|
153
|
+
|
|
154
|
+
PLATFORMS
|
|
155
|
+
ruby
|
|
156
|
+
x86_64-linux
|
|
157
|
+
|
|
158
|
+
DEPENDENCIES
|
|
159
|
+
bundler
|
|
160
|
+
debug (>= 1.0.0)
|
|
161
|
+
fat_core!
|
|
162
|
+
gem_docs (>= 0.2.0)
|
|
163
|
+
pry
|
|
164
|
+
pry-doc
|
|
165
|
+
rake
|
|
166
|
+
redcarpet
|
|
167
|
+
rspec
|
|
168
|
+
rubocop
|
|
169
|
+
rubocop-ddoherty!
|
|
170
|
+
simplecov
|
|
171
|
+
|
|
172
|
+
BUNDLED WITH
|
|
173
|
+
2.6.7
|
data/README.md
CHANGED
|
@@ -768,7 +768,7 @@ result
|
|
|
768
768
|
|
|
769
769
|
## String
|
|
770
770
|
|
|
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
|
|
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 Levenshtein distance between strings (`#distance`). And several others.
|
|
772
772
|
|
|
773
773
|
|
|
774
774
|
<a id="org63111cb"></a>
|
|
@@ -883,7 +883,7 @@ result
|
|
|
883
883
|
|
|
884
884
|
### Method `#distance`
|
|
885
885
|
|
|
886
|
-
`FatCore` provides `distance` as a simple wrapper around the
|
|
886
|
+
`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
887
|
|
|
888
888
|
```ruby
|
|
889
889
|
result = []
|
data/README.org
CHANGED
|
@@ -175,7 +175,8 @@ Array are included in the result /unless/ they also appear in any of the
|
|
|
175
175
|
| hammers | glue | bolts | hammers |
|
|
176
176
|
#+end_example
|
|
177
177
|
|
|
178
|
-
** BigDecimal
|
|
178
|
+
** BigDecimal
|
|
179
|
+
*** Method ~#inspect~
|
|
179
180
|
~FatCore~ provides nothing but a better ~#inspect~ method for the ~BigDecimal~
|
|
180
181
|
class since the default inspect method is not very readable.
|
|
181
182
|
|
|
@@ -718,7 +719,7 @@ FatCore::String has methods for performing matching of one string with another
|
|
|
718
719
|
might by used in the title of a book (~#entitle~), for converting a String
|
|
719
720
|
into a useable Symbol (~#as_sym~) and vice-versa (~#as_str~ also
|
|
720
721
|
~Symbol#as_str~), for wrapping with an optional hanging indent (~#wrap~),
|
|
721
|
-
cleaning up errant spaces (~#clean~), and computing the
|
|
722
|
+
cleaning up errant spaces (~#clean~), and computing the Levenshtein
|
|
722
723
|
distance between strings (~#distance~). And several others.
|
|
723
724
|
|
|
724
725
|
*** Method ~#fuzzy_match~
|
|
@@ -851,8 +852,10 @@ something like "In the Heat of the Night".
|
|
|
851
852
|
|
|
852
853
|
*** Method ~#distance~
|
|
853
854
|
~FatCore~ provides ~distance~ as a simple wrapper around the
|
|
854
|
-
|
|
855
|
-
|
|
855
|
+
Levenshtein distance function in Ruby's bundled ~DidYouMean~ library.
|
|
856
|
+
Insertions, deletions, and substitutions each count as one edit; swapping
|
|
857
|
+
adjacent letters counts as two. Distances above 10 return 11, preserving
|
|
858
|
+
the existing ceiling. No native extension is needed.
|
|
856
859
|
|
|
857
860
|
#+begin_src ruby
|
|
858
861
|
result = []
|
data/fat_core.gemspec
CHANGED
data/lib/fat_core/string.rb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require 'bigdecimal'
|
|
4
4
|
require 'fat_core/patches'
|
|
5
|
-
require '
|
|
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
|
|
219
|
-
#
|
|
220
|
-
#
|
|
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
|
-
|
|
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,
|
data/lib/fat_core/version.rb
CHANGED
data/spec/lib/string_spec.rb
CHANGED
|
@@ -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
|
|
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')
|
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.
|
|
4
|
+
version: 7.4.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-
|
|
10
|
+
date: 2026-10-07 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.
|
|
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: []
|