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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc3a564ad53b3eb5945f32545fdf8af8366ef7ce240e7e1ebe03945f415537cf
4
- data.tar.gz: 2ad4dfa0741f1c2aa5fc2784847f0cbafb1424813c4015695f73f6197f1bfc7e
3
+ metadata.gz: b161f218bc83618131c95a438b303dd1169359eeedbb31bef0dfee3b50b313fd
4
+ data.tar.gz: 30545b767e399b8187cbbef762684326715a0d59b68e01d19d898ba026bdf322
5
5
  SHA512:
6
- metadata.gz: 25f26b8dfc6ccfb532827ddd2462d535ae77e55077cc77ab99f3c651ebba23cc888effb5889563e35d88a4b58f17cf175193ada2a47ae908c44cf67fc47b9a59
7
- data.tar.gz: 2c89a1274845159bec563b658f820921d95af07c058103df51c411db78c06c4b6d2a10629fe027ef6137c129a7e4157c35dd77db047b0b07c543f8d29f17f230
6
+ metadata.gz: a065cdb749407abc3df8cad6f8ba964667741aaabee37faa79af31d9c067b200af0e22f89f987f8039f155e6f94401effb9ba8e2af67742e26556b1e8e23f9cc
7
+ data.tar.gz: eb7cd350bdd4fb72172a8dffcd90d3a90a44799b361e0c68ccf7c5da68dfdedde0911994c43d27040b1057741442809449a7b5eff0ff3683aafd481f42e59f17
@@ -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
- Regexp.new(self)
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
 
@@ -1,7 +1,7 @@
1
1
  module FatCore
2
2
  MAJOR = 4
3
3
  MINOR = 6
4
- PATCH = 0
4
+ PATCH = 1
5
5
 
6
6
  # FatCore version number
7
7
  VERSION = [MAJOR, MINOR, PATCH].compact.join('.')
@@ -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.0
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-07-23 00:00:00.000000000 Z
11
+ date: 2019-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simplecov