re2 2.4.3-arm-linux → 2.5.0-arm-linux
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/README.md +236 -192
- data/ext/re2/extconf.rb +6 -70
- data/ext/re2/re2.cc +450 -263
- data/ext/re2/recipes.rb +8 -0
- data/lib/2.6/re2.so +0 -0
- data/lib/2.7/re2.so +0 -0
- data/lib/3.0/re2.so +0 -0
- data/lib/3.1/re2.so +0 -0
- data/lib/3.2/re2.so +0 -0
- data/lib/re2/regexp.rb +69 -0
- data/lib/re2/scanner.rb +8 -0
- data/lib/re2/string.rb +9 -59
- data/lib/re2/version.rb +9 -1
- data/lib/re2.rb +7 -3
- data/re2.gemspec +1 -0
- data/spec/kernel_spec.rb +2 -2
- data/spec/re2/match_data_spec.rb +64 -25
- data/spec/re2/regexp_spec.rb +492 -113
- data/spec/re2/scanner_spec.rb +3 -8
- data/spec/re2/set_spec.rb +18 -18
- data/spec/re2_spec.rb +4 -4
- metadata +3 -2
data/spec/re2/scanner_spec.rb
CHANGED
@@ -43,7 +43,7 @@ RSpec.describe RE2::Scanner do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it "returns ISO-8859-1 matches if the pattern is not UTF-8" do
|
46
|
-
r = RE2::Regexp.new('(\w+)', :
|
46
|
+
r = RE2::Regexp.new('(\w+)', utf8: false)
|
47
47
|
scanner = r.scan("It")
|
48
48
|
matches = scanner.scan
|
49
49
|
|
@@ -75,7 +75,7 @@ RSpec.describe RE2::Scanner do
|
|
75
75
|
end
|
76
76
|
|
77
77
|
it "returns nil if the regexp is invalid" do
|
78
|
-
r = RE2::Regexp.new('???', :
|
78
|
+
r = RE2::Regexp.new('???', log_errors: false)
|
79
79
|
scanner = r.scan("Foo bar")
|
80
80
|
|
81
81
|
expect(scanner.scan).to be_nil
|
@@ -173,12 +173,7 @@ RSpec.describe RE2::Scanner do
|
|
173
173
|
r = RE2::Regexp.new('(\d)')
|
174
174
|
scanner = r.scan("There are 1 some 2 numbers 3")
|
175
175
|
|
176
|
-
|
177
|
-
if defined?(Enumerator)
|
178
|
-
expect(scanner.each).to be_a(Enumerator)
|
179
|
-
elsif defined?(Enumerable::Enumerator)
|
180
|
-
expect(scanner.each).to be_a(Enumerable::Enumerator)
|
181
|
-
end
|
176
|
+
expect(scanner.each).to be_a(Enumerator)
|
182
177
|
end
|
183
178
|
end
|
184
179
|
|
data/spec/re2/set_spec.rb
CHANGED
@@ -25,7 +25,7 @@ RSpec.describe RE2::Set do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it "returns an instance given an anchor and options" do
|
28
|
-
set = RE2::Set.new(:unanchored, :
|
28
|
+
set = RE2::Set.new(:unanchored, case_sensitive: false)
|
29
29
|
|
30
30
|
expect(set).to be_a(RE2::Set)
|
31
31
|
end
|
@@ -42,7 +42,7 @@ RSpec.describe RE2::Set do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it "raises an error if given an invalid anchor and options" do
|
45
|
-
expect { RE2::Set.new(:not_a_valid_anchor, :
|
45
|
+
expect { RE2::Set.new(:not_a_valid_anchor, case_sensitive: false) }.to raise_error(
|
46
46
|
ArgumentError,
|
47
47
|
"anchor should be one of: :unanchored, :anchor_start, :anchor_both"
|
48
48
|
)
|
@@ -59,19 +59,19 @@ RSpec.describe RE2::Set do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it "rejects invalid patterns when added" do
|
62
|
-
set = RE2::Set.new(:unanchored, :
|
62
|
+
set = RE2::Set.new(:unanchored, log_errors: false)
|
63
63
|
|
64
64
|
expect { set.add("???") }.to raise_error(ArgumentError, /str rejected by RE2::Set->Add\(\)/)
|
65
65
|
end
|
66
66
|
|
67
67
|
it "truncates error messages to 100 characters" do
|
68
|
-
set = RE2::Set.new(:unanchored, :
|
68
|
+
set = RE2::Set.new(:unanchored, log_errors: false)
|
69
69
|
|
70
70
|
expect { set.add("(?P<#{'o' * 200}") }.to raise_error(ArgumentError, "str rejected by RE2::Set->Add(): invalid named capture group: (?P<oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo")
|
71
71
|
end
|
72
72
|
|
73
73
|
it "raises an error if called after #compile" do
|
74
|
-
set = RE2::Set.new(:unanchored, :
|
74
|
+
set = RE2::Set.new(:unanchored, log_errors: false)
|
75
75
|
set.add("abc")
|
76
76
|
set.compile
|
77
77
|
|
@@ -81,7 +81,7 @@ RSpec.describe RE2::Set do
|
|
81
81
|
end
|
82
82
|
|
83
83
|
it "raises an error if given a pattern that can't be coerced to a String" do
|
84
|
-
set = RE2::Set.new(:unanchored, :
|
84
|
+
set = RE2::Set.new(:unanchored, log_errors: false)
|
85
85
|
|
86
86
|
expect { set.add(0) }.to raise_error(TypeError)
|
87
87
|
end
|
@@ -112,7 +112,7 @@ RSpec.describe RE2::Set do
|
|
112
112
|
set.add("ghi")
|
113
113
|
set.compile
|
114
114
|
|
115
|
-
expect(set.match("abcdefghi", :
|
115
|
+
expect(set.match("abcdefghi", exception: false)).to eq([0, 1, 2])
|
116
116
|
end
|
117
117
|
|
118
118
|
it "returns an empty array if there is no match" do
|
@@ -120,7 +120,7 @@ RSpec.describe RE2::Set do
|
|
120
120
|
set.add("abc")
|
121
121
|
set.compile
|
122
122
|
|
123
|
-
expect(set.match("def", :
|
123
|
+
expect(set.match("def", exception: false)).to be_empty
|
124
124
|
end
|
125
125
|
|
126
126
|
it "returns an empty array if there is no match when :exception is true" do
|
@@ -136,7 +136,7 @@ RSpec.describe RE2::Set do
|
|
136
136
|
it "raises an error if called before #compile by default" do
|
137
137
|
skip "Underlying RE2::Set::Match does not output error information" unless RE2::Set.match_raises_errors?
|
138
138
|
|
139
|
-
set = RE2::Set.new(:unanchored, :
|
139
|
+
set = RE2::Set.new(:unanchored, log_errors: false)
|
140
140
|
|
141
141
|
silence_stderr do
|
142
142
|
expect { set.match("") }.to raise_error(RE2::Set::MatchError)
|
@@ -146,28 +146,28 @@ RSpec.describe RE2::Set do
|
|
146
146
|
it "raises an error if called before #compile when :exception is true" do
|
147
147
|
skip "Underlying RE2::Set::Match does not output error information" unless RE2::Set.match_raises_errors?
|
148
148
|
|
149
|
-
set = RE2::Set.new(:unanchored, :
|
149
|
+
set = RE2::Set.new(:unanchored, log_errors: false)
|
150
150
|
|
151
151
|
silence_stderr do
|
152
|
-
expect { set.match("", :
|
152
|
+
expect { set.match("", exception: true) }.to raise_error(RE2::Set::MatchError)
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
156
|
it "returns an empty array if called before #compile when :exception is false" do
|
157
|
-
set = RE2::Set.new(:unanchored, :
|
157
|
+
set = RE2::Set.new(:unanchored, log_errors: false)
|
158
158
|
|
159
159
|
silence_stderr do
|
160
|
-
expect(set.match("", :
|
160
|
+
expect(set.match("", exception: false)).to be_empty
|
161
161
|
end
|
162
162
|
end
|
163
163
|
|
164
|
-
it "raises an error if :exception is true and
|
164
|
+
it "raises an error if :exception is true and RE2 does not support it" do
|
165
165
|
skip "Underlying RE2::Set::Match outputs error information" if RE2::Set.match_raises_errors?
|
166
166
|
|
167
|
-
set = RE2::Set.new(:unanchored, :
|
167
|
+
set = RE2::Set.new(:unanchored, log_errors: false)
|
168
168
|
|
169
169
|
silence_stderr do
|
170
|
-
expect { set.match("", :
|
170
|
+
expect { set.match("", exception: true) }.to raise_error(RE2::Set::UnsupportedError)
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
@@ -182,7 +182,7 @@ RSpec.describe RE2::Set do
|
|
182
182
|
set.add("abc")
|
183
183
|
set.compile
|
184
184
|
|
185
|
-
expect { set.match(0, :
|
185
|
+
expect { set.match(0, exception: false) }.to raise_error(TypeError)
|
186
186
|
end
|
187
187
|
|
188
188
|
it "accepts input if it can be coerced to a String" do
|
@@ -190,7 +190,7 @@ RSpec.describe RE2::Set do
|
|
190
190
|
set.add("abc")
|
191
191
|
set.compile
|
192
192
|
|
193
|
-
expect(set.match(StringLike.new("abcdef"), :
|
193
|
+
expect(set.match(StringLike.new("abcdef"), exception: false)).to contain_exactly(0)
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
data/spec/re2_spec.rb
CHANGED
@@ -27,7 +27,7 @@ RSpec.describe RE2 do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it "respects any passed RE2::Regexp's flags" do
|
30
|
-
re = RE2::Regexp.new('gOOD MORNING', :
|
30
|
+
re = RE2::Regexp.new('gOOD MORNING', case_sensitive: false)
|
31
31
|
|
32
32
|
expect(RE2.Replace("Good morning", re, "hi")).to eq("hi")
|
33
33
|
end
|
@@ -53,7 +53,7 @@ RSpec.describe RE2 do
|
|
53
53
|
|
54
54
|
it "returns ISO-8859-1 strings if the pattern is not UTF-8" do
|
55
55
|
original = "Foo"
|
56
|
-
replacement = RE2.Replace(original, RE2("oo", :
|
56
|
+
replacement = RE2.Replace(original, RE2("oo", utf8: false), "ah")
|
57
57
|
|
58
58
|
expect(replacement.encoding).to eq(Encoding::ISO_8859_1)
|
59
59
|
end
|
@@ -105,7 +105,7 @@ RSpec.describe RE2 do
|
|
105
105
|
end
|
106
106
|
|
107
107
|
it "respects any passed RE2::Regexp's flags" do
|
108
|
-
re = RE2::Regexp.new('gOOD MORNING', :
|
108
|
+
re = RE2::Regexp.new('gOOD MORNING', case_sensitive: false)
|
109
109
|
|
110
110
|
expect(RE2.GlobalReplace("Good morning Good morning", re, "hi")).to eq("hi hi")
|
111
111
|
end
|
@@ -131,7 +131,7 @@ RSpec.describe RE2 do
|
|
131
131
|
|
132
132
|
it "returns ISO-8859-1 strings if the pattern is not UTF-8" do
|
133
133
|
original = "Foo"
|
134
|
-
replacement = RE2.GlobalReplace(original, RE2("oo", :
|
134
|
+
replacement = RE2.GlobalReplace(original, RE2("oo", utf8: false), "ah")
|
135
135
|
|
136
136
|
expect(replacement.encoding).to eq(Encoding::ISO_8859_1)
|
137
137
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: re2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: arm-linux
|
6
6
|
authors:
|
7
7
|
- Paul Mucur
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-
|
12
|
+
date: 2023-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake-compiler
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- lib/3.1/re2.so
|
77
77
|
- lib/3.2/re2.so
|
78
78
|
- lib/re2.rb
|
79
|
+
- lib/re2/regexp.rb
|
79
80
|
- lib/re2/scanner.rb
|
80
81
|
- lib/re2/string.rb
|
81
82
|
- lib/re2/version.rb
|