pattern_patch 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac52acbe5d2cbcea1cf92737af537c6ade5e6f8bd6dbfc018379b775525a29c7
4
- data.tar.gz: 956aef3784a209327d24f96c400ceeef0058308d35495ddcf78cafa715d0bbe3
3
+ metadata.gz: 7208eb762a3339cb1061097f2a7bd10f139b24814f7ac9f515054f23f1d5e00c
4
+ data.tar.gz: 8dadfa1274c3819a7eac94b9678b407437271f20a19423e3f89cfcdbdd387ec9
5
5
  SHA512:
6
- metadata.gz: 39f90a02313d5534c608b8df06d244ed17e353e9faeb413f62607f3e54aaafb475f072be1999a1ef596e23dfe58efe3e56b4b4fa7cdee6386721a806778c1b75
7
- data.tar.gz: 18282ce5b40fb449f8156517e6e9a154c792acaccc9e692e02cf9cc302e2f75c24c4723475864024d685ed9f6e604aea56c91990246ea91c5cd6026642943162
6
+ metadata.gz: 859c503f96f968212b1f37f6a38e9c748a37e7553d549ab744e472ef1458ec87f2adbfe4828970b927432ab1415ee203927da391a6b5fcd2180267fb3f9b9e3c
7
+ data.tar.gz: '083d46106952f952674ecd09c4a43e03b1aa722d5d14936250959fcf3071221544228c62165db3f5fa500bcff43b39d73250bc0173b42fac3a8261609f61e2c7'
@@ -17,7 +17,23 @@ module PatternPatch
17
17
  # Adjust string fields from YAML
18
18
 
19
19
  if hash[:regexp].kind_of? String
20
- hash[:regexp] = /#{hash[:regexp]}/
20
+ regexp_string = hash[:regexp]
21
+ if (matches = %r{^/(.+)/([imx]*)$}.match regexp_string)
22
+ flags = 0
23
+ if matches[2] =~ /i/
24
+ flags |= Regexp::IGNORECASE
25
+ end
26
+ if matches[2] =~ /x/
27
+ flags |= Regexp::EXTENDED
28
+ end
29
+ if matches[2] =~ /m/
30
+ flags |= Regexp::MULTILINE
31
+ end
32
+ hash[:regexp] = Regexp.new matches[1], flags
33
+ puts "Regexp from YAML: #{hash[:regexp].inspect}"
34
+ else
35
+ hash[:regexp] = /#{regexp_string}/
36
+ end
21
37
  end
22
38
 
23
39
  if hash[:mode].kind_of? String
@@ -1,3 +1,3 @@
1
1
  module PatternPatch
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pattern_patch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmy Dee