fat_core 4.6.1 → 4.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fat_core/string.rb +6 -6
- data/lib/fat_core/version.rb +2 -2
- data/spec/lib/string_spec.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 881fe55c54af6a96acb9ff0875df33063f4598d800785e5c46a3e2f4cd317cff
|
4
|
+
data.tar.gz: 43bac870c480a6770a39640a61c51f236f891c648a109d4b85d70b1188150cff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45fc3d2e6e09e59ff14cc4acaa4d2a3794f990a55422b8d2b68186262b2971d566a1651075363600ac9defb03705ddff971bf0b1eb09bf1ab7cb030ab6250910
|
7
|
+
data.tar.gz: 95bc26f296c51bfcf25b15ab2e4c70f0e1ef28d053d36ee8f9917b6008e09ddbcd469dc2ab0e33e5da15809fb9ab8d749ba8e2250515e6515ecefea56e125a5f
|
data/lib/fat_core/string.rb
CHANGED
@@ -226,12 +226,12 @@ module FatCore
|
|
226
226
|
# @return [String] the matched portion of self, with punctuation stripped in
|
227
227
|
# case of #fuzzy_match
|
228
228
|
# @see #fuzzy_match #fuzzy_match for the specifics of string matching
|
229
|
-
# @see #
|
229
|
+
# @see #as_regexp #as_regexp for conversion of `matcher` to regular expression
|
230
230
|
def matches_with(matcher)
|
231
231
|
if matcher.nil?
|
232
232
|
nil
|
233
233
|
elsif matcher =~ %r{^\s*/}
|
234
|
-
re = matcher.
|
234
|
+
re = matcher.as_regexp
|
235
235
|
$& if to_s =~ re
|
236
236
|
else
|
237
237
|
to_s.fuzzy_match(matcher)
|
@@ -282,12 +282,12 @@ module FatCore
|
|
282
282
|
# it to a Regexp with Regexp.new.
|
283
283
|
#
|
284
284
|
# @example
|
285
|
-
# '/Hello/'.
|
286
|
-
# '/Hello/I'.
|
287
|
-
# 'Hello'.
|
285
|
+
# '/Hello/'.as_regexp #=> /Hello/i
|
286
|
+
# '/Hello/I'.as_regexp #=> /Hello/
|
287
|
+
# 'Hello'.as_regexp #=> /Hello/
|
288
288
|
#
|
289
289
|
# @return [Regexp]
|
290
|
-
def
|
290
|
+
def as_regexp
|
291
291
|
if self =~ %r{^\s*/([^/]*)/([Iixm]*)\s*$}
|
292
292
|
body = $1
|
293
293
|
opts = $2
|
data/lib/fat_core/version.rb
CHANGED
data/spec/lib/string_spec.rb
CHANGED
@@ -150,20 +150,20 @@ the people, for the people, shall not perish from the earth."
|
|
150
150
|
end
|
151
151
|
|
152
152
|
it 'should be able to convert a string to a regular expression' do
|
153
|
-
re = "/hello((\s+)(world))?/".
|
153
|
+
re = "/hello((\s+)(world))?/".as_regexp
|
154
154
|
expect(re.class).to eq Regexp
|
155
155
|
expect(re.casefold?).to be true
|
156
156
|
expect(re.multiline?).to be false
|
157
157
|
expect(re.match?('Hello WorlD')).to be true
|
158
158
|
|
159
|
-
re = "/hello((\s+)(world))?/Im".
|
159
|
+
re = "/hello((\s+)(world))?/Im".as_regexp
|
160
160
|
expect(re.class).to eq Regexp
|
161
161
|
expect(re.casefold?).to be false
|
162
162
|
expect(re.multiline?).to be true
|
163
163
|
expect(re.match?('Hello WorlD')).to be false
|
164
164
|
|
165
165
|
# Works without /../ but no options possible
|
166
|
-
re = "hello((\s+)(world))?".
|
166
|
+
re = "hello((\s+)(world))?".as_regexp
|
167
167
|
expect(re.class).to eq Regexp
|
168
168
|
expect(re.casefold?).to be false
|
169
169
|
expect(re.multiline?).to be false
|
@@ -172,7 +172,7 @@ the people, for the people, shall not perish from the earth."
|
|
172
172
|
|
173
173
|
it 'should be able to convert metacharacters into Regexp' do
|
174
174
|
"\\$()*+.<>?[]^{|}".chars.each do |c|
|
175
|
-
re = c.
|
175
|
+
re = c.as_regexp
|
176
176
|
expect(re.class).to eq Regexp
|
177
177
|
end
|
178
178
|
end
|
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: 4.
|
4
|
+
version: 4.7.0
|
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: 2019-10-
|
11
|
+
date: 2019-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simplecov
|