fat_core 4.6.0 → 4.6.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 +4 -4
- data/lib/fat_core/string.rb +8 -1
- data/lib/fat_core/version.rb +1 -1
- data/spec/lib/string_spec.rb +10 -0
- 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: b161f218bc83618131c95a438b303dd1169359eeedbb31bef0dfee3b50b313fd
|
4
|
+
data.tar.gz: 30545b767e399b8187cbbef762684326715a0d59b68e01d19d898ba026bdf322
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a065cdb749407abc3df8cad6f8ba964667741aaabee37faa79af31d9c067b200af0e22f89f987f8039f155e6f94401effb9ba8e2af67742e26556b1e8e23f9cc
|
7
|
+
data.tar.gz: eb7cd350bdd4fb72172a8dffcd90d3a90a44799b361e0c68ccf7c5da68dfdedde0911994c43d27040b1057741442809449a7b5eff0ff3683aafd481f42e59f17
|
data/lib/fat_core/string.rb
CHANGED
@@ -273,6 +273,8 @@ module FatCore
|
|
273
273
|
matched_text
|
274
274
|
end
|
275
275
|
|
276
|
+
REGEXP_META_CHARACTERS = "\\$()*+.<>?[]^{|}".chars
|
277
|
+
|
276
278
|
# Convert a string of the form '/.../Iixm' to a regular expression. However,
|
277
279
|
# make the regular expression case-insensitive by default and extend the
|
278
280
|
# modifier syntax to allow '/I' to indicate case-sensitive. Without the
|
@@ -297,9 +299,14 @@ module FatCore
|
|
297
299
|
flags |= Regexp::MULTILINE if opts.include?('m')
|
298
300
|
end
|
299
301
|
flags = nil if flags.zero?
|
302
|
+
body = Regexp.quote(body) if REGEXP_META_CHARACTERS.include?(body)
|
300
303
|
Regexp.new(body, flags)
|
301
304
|
else
|
302
|
-
|
305
|
+
if REGEXP_META_CHARACTERS.include?(self)
|
306
|
+
Regexp.new(Regexp.quote(self))
|
307
|
+
else
|
308
|
+
Regexp.new(self)
|
309
|
+
end
|
303
310
|
end
|
304
311
|
end
|
305
312
|
|
data/lib/fat_core/version.rb
CHANGED
data/spec/lib/string_spec.rb
CHANGED
@@ -154,17 +154,27 @@ the people, for the people, shall not perish from the earth."
|
|
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
|
+
expect(re.match?('Hello WorlD')).to be true
|
157
158
|
|
158
159
|
re = "/hello((\s+)(world))?/Im".to_regexp
|
159
160
|
expect(re.class).to eq Regexp
|
160
161
|
expect(re.casefold?).to be false
|
161
162
|
expect(re.multiline?).to be true
|
163
|
+
expect(re.match?('Hello WorlD')).to be false
|
162
164
|
|
163
165
|
# Works without /../ but no options possible
|
164
166
|
re = "hello((\s+)(world))?".to_regexp
|
165
167
|
expect(re.class).to eq Regexp
|
166
168
|
expect(re.casefold?).to be false
|
167
169
|
expect(re.multiline?).to be false
|
170
|
+
expect(re.match?('hello world')).to be true
|
171
|
+
end
|
172
|
+
|
173
|
+
it 'should be able to convert metacharacters into Regexp' do
|
174
|
+
"\\$()*+.<>?[]^{|}".chars.each do |c|
|
175
|
+
re = c.to_regexp
|
176
|
+
expect(re.class).to eq Regexp
|
177
|
+
end
|
168
178
|
end
|
169
179
|
|
170
180
|
it 'should be able to convert itself to a sym' do
|
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.6.
|
4
|
+
version: 4.6.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: 2019-
|
11
|
+
date: 2019-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simplecov
|