will_scan_string 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -16,7 +16,7 @@ module WillScanString
|
|
16
16
|
protected
|
17
17
|
def get_match_and_replacement( m )
|
18
18
|
m = m.to_a.tap{ |m| m.shift }
|
19
|
-
i = m.find_index{ |v| v.
|
19
|
+
i = m.find_index{ |v| !v.nil? }
|
20
20
|
r = find_replacement_by_index(i)
|
21
21
|
cps = [0] + (r[0].is_a?(Regexp) ? r[0].capture_groups : [])
|
22
22
|
m = m[i, cps.length]
|
@@ -38,4 +38,8 @@ describe WillScanString::RegexpTraits do
|
|
38
38
|
/(?:\s*(?:([a-z0-9_-]+)|^)\s*[:=]\s*)?("[^"\\]*(?:\\[\s\S][^"\\]*)*"|'[^'\\]*(?:\\[\s\S][^'\\]*)*'|[^\]\s,]+|(?<=,)(?=\s*,))\s*,?/i.capture_groups.should \
|
39
39
|
eql [ 1, 2 ]
|
40
40
|
end
|
41
|
+
|
42
|
+
it "should handle a regexp matching newlines" do
|
43
|
+
/(?:\r\n|\r|\n)/.capture_groups.should eql []
|
44
|
+
end
|
41
45
|
end
|
@@ -29,4 +29,10 @@ describe WillScanString::StringScanner do
|
|
29
29
|
ss.register_replacement /(c)(d)/, "CD"
|
30
30
|
ss.replace("abcd").should eql "ABCD"
|
31
31
|
end
|
32
|
+
|
33
|
+
it "should match newlines" do
|
34
|
+
ss = WillScanString::StringScanner.new
|
35
|
+
ss.register_replacement /(?:\r\n)/, "<br>"
|
36
|
+
ss.replace("\r\n").should eql("<br>")
|
37
|
+
end
|
32
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: will_scan_string
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-11-04 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70219591827400 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '2.6'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70219591827400
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &70219591826540 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.0.9
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70219591826540
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: i18n
|
38
|
-
requirement: &
|
38
|
+
requirement: &70219591826060 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 0.5.0
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70219591826060
|
47
47
|
description: Gem for string replacements using multiple regular expressions in a single
|
48
48
|
pass.
|
49
49
|
email:
|