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 +4 -4
- data/lib/pattern_patch/patch.rb +17 -1
- data/lib/pattern_patch/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7208eb762a3339cb1061097f2a7bd10f139b24814f7ac9f515054f23f1d5e00c
|
4
|
+
data.tar.gz: 8dadfa1274c3819a7eac94b9678b407437271f20a19423e3f89cfcdbdd387ec9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 859c503f96f968212b1f37f6a38e9c748a37e7553d549ab744e472ef1458ec87f2adbfe4828970b927432ab1415ee203927da391a6b5fcd2180267fb3f9b9e3c
|
7
|
+
data.tar.gz: '083d46106952f952674ecd09c4a43e03b1aa722d5d14936250959fcf3071221544228c62165db3f5fa500bcff43b39d73250bc0173b42fac3a8261609f61e2c7'
|
data/lib/pattern_patch/patch.rb
CHANGED
@@ -17,7 +17,23 @@ module PatternPatch
|
|
17
17
|
# Adjust string fields from YAML
|
18
18
|
|
19
19
|
if hash[:regexp].kind_of? String
|
20
|
-
|
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
|