re2 2.0.0.beta1-arm-linux → 2.1.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/Gemfile +1 -9
- data/LICENSE-DEPENDENCIES.txt +237 -0
- data/LICENSE.txt +1 -1
- data/README.md +73 -18
- data/Rakefile +1 -24
- data/dependencies.yml +3 -3
- data/ext/re2/extconf.rb +63 -9
- data/ext/re2/re2.cc +74 -23
- 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/version.rb +1 -1
- data/re2.gemspec +7 -6
- data/spec/kernel_spec.rb +3 -3
- data/spec/re2/match_data_spec.rb +24 -0
- data/spec/re2/regexp_spec.rb +6 -0
- data/spec/re2/scanner_spec.rb +76 -22
- data/spec/re2/set_spec.rb +41 -1
- data/spec/re2/string_spec.rb +7 -3
- data/spec/re2_spec.rb +104 -10
- data/spec/spec_helper.rb +10 -0
- metadata +11 -7
data/spec/re2/set_spec.rb
CHANGED
@@ -67,11 +67,17 @@ RSpec.describe RE2::Set do
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
it "raises an error if given a
|
70
|
+
it "raises an error if given a pattern that can't be coerced to a String" do
|
71
71
|
set = RE2::Set.new(:unanchored, :log_errors => false)
|
72
72
|
|
73
73
|
expect { set.add(0) }.to raise_error(TypeError)
|
74
74
|
end
|
75
|
+
|
76
|
+
it "accepts a pattern that can be coerced to a String" do
|
77
|
+
set = RE2::Set.new
|
78
|
+
|
79
|
+
expect(set.add(StringLike.new("abc"))).to eq(0)
|
80
|
+
end
|
75
81
|
end
|
76
82
|
|
77
83
|
describe "#compile" do
|
@@ -96,6 +102,24 @@ RSpec.describe RE2::Set do
|
|
96
102
|
expect(set.match("abcdefghi", :exception => false)).to eq([0, 1, 2])
|
97
103
|
end
|
98
104
|
|
105
|
+
it "returns an empty array if there is no match" do
|
106
|
+
set = RE2::Set.new
|
107
|
+
set.add("abc")
|
108
|
+
set.compile
|
109
|
+
|
110
|
+
expect(set.match("def", :exception => false)).to be_empty
|
111
|
+
end
|
112
|
+
|
113
|
+
it "returns an empty array if there is no match when :exception is true" do
|
114
|
+
skip "Underlying RE2::Set::Match does not output error information" unless RE2::Set.match_raises_errors?
|
115
|
+
|
116
|
+
set = RE2::Set.new
|
117
|
+
set.add("abc")
|
118
|
+
set.compile
|
119
|
+
|
120
|
+
expect(set.match("def")).to be_empty
|
121
|
+
end
|
122
|
+
|
99
123
|
it "raises an error if called before #compile by default" do
|
100
124
|
skip "Underlying RE2::Set::Match does not output error information" unless RE2::Set.match_raises_errors?
|
101
125
|
|
@@ -139,6 +163,22 @@ RSpec.describe RE2::Set do
|
|
139
163
|
|
140
164
|
expect { set.match("", 0) }.to raise_error(TypeError)
|
141
165
|
end
|
166
|
+
|
167
|
+
it "raises a Type Error if given input that can't be coerced to a String" do
|
168
|
+
set = RE2::Set.new
|
169
|
+
set.add("abc")
|
170
|
+
set.compile
|
171
|
+
|
172
|
+
expect { set.match(0, :exception => false) }.to raise_error(TypeError)
|
173
|
+
end
|
174
|
+
|
175
|
+
it "accepts input if it can be coerced to a String" do
|
176
|
+
set = RE2::Set.new
|
177
|
+
set.add("abc")
|
178
|
+
set.compile
|
179
|
+
|
180
|
+
expect(set.match(StringLike.new("abcdef"), :exception => false)).to contain_exactly(0)
|
181
|
+
end
|
142
182
|
end
|
143
183
|
|
144
184
|
def silence_stderr
|
data/spec/re2/string_spec.rb
CHANGED
@@ -12,7 +12,8 @@ RSpec.describe RE2::String do
|
|
12
12
|
|
13
13
|
it "doesn't perform an in-place replacement" do
|
14
14
|
string = "My name is Robert Paulson"
|
15
|
-
|
15
|
+
|
16
|
+
expect(string.re2_sub('Robert', 'Crobert')).not_to equal(string)
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
@@ -23,13 +24,15 @@ RSpec.describe RE2::String do
|
|
23
24
|
|
24
25
|
it "doesn't perform an in-place replacement" do
|
25
26
|
string = "My name is Robert Paulson"
|
26
|
-
|
27
|
+
|
28
|
+
expect(string.re2_gsub('a', 'e')).not_to equal(string)
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
30
32
|
describe "#re2_match" do
|
31
|
-
it "delegates to RE2::Regexp#match to perform matches" do
|
33
|
+
it "delegates to RE2::Regexp#match to perform matches", :aggregate_failures do
|
32
34
|
md = "My name is Robert Paulson".re2_match('My name is (\S+) (\S+)')
|
35
|
+
|
33
36
|
expect(md).to be_a(RE2::MatchData)
|
34
37
|
expect(md[0]).to eq("My name is Robert Paulson")
|
35
38
|
expect(md[1]).to eq("Robert")
|
@@ -38,6 +41,7 @@ RSpec.describe RE2::String do
|
|
38
41
|
|
39
42
|
it "supports limiting the number of matches" do
|
40
43
|
md = "My name is Robert Paulson".re2_match('My name is (\S+) (\S+)', 0)
|
44
|
+
|
41
45
|
expect(md).to eq(true)
|
42
46
|
end
|
43
47
|
end
|
data/spec/re2_spec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
RSpec.describe RE2 do
|
2
|
-
describe "
|
2
|
+
describe ".Replace" do
|
3
3
|
it "only replaces the first occurrence of the pattern" do
|
4
4
|
expect(RE2.Replace("woo", "o", "a")).to eq("wao")
|
5
5
|
end
|
@@ -15,29 +15,68 @@ RSpec.describe RE2 do
|
|
15
15
|
it "does not perform replacements in-place" do
|
16
16
|
name = "Robert"
|
17
17
|
replacement = RE2.Replace(name, "R", "Cr")
|
18
|
-
|
18
|
+
|
19
|
+
expect(name).not_to equal(replacement)
|
19
20
|
end
|
20
21
|
|
21
22
|
it "supports passing an RE2::Regexp as the pattern" do
|
22
23
|
re = RE2::Regexp.new('wo{2}')
|
24
|
+
|
23
25
|
expect(RE2.Replace("woo", re, "miaow")).to eq("miaow")
|
24
26
|
end
|
25
27
|
|
26
28
|
it "respects any passed RE2::Regexp's flags" do
|
27
29
|
re = RE2::Regexp.new('gOOD MORNING', :case_sensitive => false)
|
30
|
+
|
28
31
|
expect(RE2.Replace("Good morning", re, "hi")).to eq("hi")
|
29
32
|
end
|
30
33
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
it "supports passing something that can be coerced to a String as input" do
|
35
|
+
expect(RE2.Replace(StringLike.new("woo"), "oo", "ah")).to eq("wah")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "supports passing something that can be coerced to a String as a pattern" do
|
39
|
+
expect(RE2.Replace("woo", StringLike.new("oo"), "ah")).to eq("wah")
|
40
|
+
end
|
41
|
+
|
42
|
+
it "supports passing something that can be coerced to a String as a replacement" do
|
43
|
+
expect(RE2.Replace("woo", "oo", StringLike.new("ah"))).to eq("wah")
|
44
|
+
end
|
45
|
+
|
46
|
+
it "returns UTF-8 strings if the pattern is UTF-8" do
|
47
|
+
original = "Foo".encode("ISO-8859-1")
|
48
|
+
replacement = RE2.Replace(original, "oo", "ah")
|
49
|
+
|
50
|
+
expect(replacement.encoding).to eq(Encoding::UTF_8)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "returns ISO-8859-1 strings if the pattern is not UTF-8" do
|
54
|
+
original = "Foo"
|
55
|
+
replacement = RE2.Replace(original, RE2("oo", :utf8 => false), "ah")
|
56
|
+
|
57
|
+
expect(replacement.encoding).to eq(Encoding::ISO_8859_1)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "returns UTF-8 strings when given a String pattern" do
|
61
|
+
replacement = RE2.Replace("Foo", "oo".encode("ISO-8859-1"), "ah")
|
62
|
+
|
63
|
+
expect(replacement.encoding).to eq(Encoding::UTF_8)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "raises a Type Error for input that can't be converted to String" do
|
67
|
+
expect { RE2.Replace(0, "oo", "ah") }.to raise_error(TypeError)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "raises a Type Error for a non-RE2::Regexp pattern that can't be converted to String" do
|
71
|
+
expect { RE2.Replace("woo", 0, "ah") }.to raise_error(TypeError)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "raises a Type Error for a replacement that can't be converted to String" do
|
75
|
+
expect { RE2.Replace("woo", "oo", 0) }.to raise_error(TypeError)
|
37
76
|
end
|
38
77
|
end
|
39
78
|
|
40
|
-
describe "
|
79
|
+
describe ".GlobalReplace" do
|
41
80
|
it "replaces every occurrence of a pattern" do
|
42
81
|
expect(RE2.GlobalReplace("woo", "o", "a")).to eq("waa")
|
43
82
|
end
|
@@ -53,23 +92,78 @@ RSpec.describe RE2 do
|
|
53
92
|
it "does not perform replacement in-place" do
|
54
93
|
name = "Robert"
|
55
94
|
replacement = RE2.GlobalReplace(name, "(?i)R", "w")
|
56
|
-
|
95
|
+
|
96
|
+
expect(name).not_to equal(replacement)
|
57
97
|
end
|
58
98
|
|
59
99
|
it "supports passing an RE2::Regexp as the pattern" do
|
60
100
|
re = RE2::Regexp.new('wo{2,}')
|
101
|
+
|
61
102
|
expect(RE2.GlobalReplace("woowooo", re, "miaow")).to eq("miaowmiaow")
|
62
103
|
end
|
63
104
|
|
64
105
|
it "respects any passed RE2::Regexp's flags" do
|
65
106
|
re = RE2::Regexp.new('gOOD MORNING', :case_sensitive => false)
|
107
|
+
|
66
108
|
expect(RE2.GlobalReplace("Good morning Good morning", re, "hi")).to eq("hi hi")
|
67
109
|
end
|
110
|
+
|
111
|
+
it "supports passing something that can be coerced to a String as input" do
|
112
|
+
expect(RE2.GlobalReplace(StringLike.new("woo"), "o", "a")).to eq("waa")
|
113
|
+
end
|
114
|
+
|
115
|
+
it "supports passing something that can be coerced to a String as a pattern" do
|
116
|
+
expect(RE2.GlobalReplace("woo", StringLike.new("o"), "a")).to eq("waa")
|
117
|
+
end
|
118
|
+
|
119
|
+
it "supports passing something that can be coerced to a String as a replacement" do
|
120
|
+
expect(RE2.GlobalReplace("woo", "o", StringLike.new("a"))).to eq("waa")
|
121
|
+
end
|
122
|
+
|
123
|
+
it "returns UTF-8 strings if the pattern is UTF-8" do
|
124
|
+
original = "Foo".encode("ISO-8859-1")
|
125
|
+
replacement = RE2.GlobalReplace(original, "oo", "ah")
|
126
|
+
|
127
|
+
expect(replacement.encoding).to eq(Encoding::UTF_8)
|
128
|
+
end
|
129
|
+
|
130
|
+
it "returns ISO-8859-1 strings if the pattern is not UTF-8" do
|
131
|
+
original = "Foo"
|
132
|
+
replacement = RE2.GlobalReplace(original, RE2("oo", :utf8 => false), "ah")
|
133
|
+
|
134
|
+
expect(replacement.encoding).to eq(Encoding::ISO_8859_1)
|
135
|
+
end
|
136
|
+
|
137
|
+
it "returns UTF-8 strings when given a String pattern" do
|
138
|
+
replacement = RE2.GlobalReplace("Foo", "oo".encode("ISO-8859-1"), "ah")
|
139
|
+
|
140
|
+
expect(replacement.encoding).to eq(Encoding::UTF_8)
|
141
|
+
end
|
142
|
+
|
143
|
+
it "raises a Type Error for input that can't be converted to String" do
|
144
|
+
expect { RE2.GlobalReplace(0, "o", "a") }.to raise_error(TypeError)
|
145
|
+
end
|
146
|
+
|
147
|
+
it "raises a Type Error for a non-RE2::Regexp pattern that can't be converted to String" do
|
148
|
+
expect { RE2.GlobalReplace("woo", 0, "a") }.to raise_error(TypeError)
|
149
|
+
end
|
150
|
+
|
151
|
+
it "raises a Type Error for a replacement that can't be converted to String" do
|
152
|
+
expect { RE2.GlobalReplace("woo", "o", 0) }.to raise_error(TypeError)
|
153
|
+
end
|
68
154
|
end
|
69
155
|
|
70
156
|
describe "#QuoteMeta" do
|
71
157
|
it "escapes a string so it can be used as a regular expression" do
|
72
158
|
expect(RE2.QuoteMeta("1.5-2.0?")).to eq('1\.5\-2\.0\?')
|
73
159
|
end
|
160
|
+
|
161
|
+
it "raises a Type Error for input that can't be converted to String" do
|
162
|
+
expect { RE2.QuoteMeta(0) }.to raise_error(TypeError)
|
163
|
+
end
|
164
|
+
|
165
|
+
it "supports passing something that can be coerced to a String as input" do
|
166
|
+
expect(RE2.QuoteMeta(StringLike.new("1.5"))).to eq('1\.5')
|
167
|
+
end
|
74
168
|
end
|
75
169
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
require "re2"
|
2
2
|
|
3
|
+
# To test passing objects that can be coerced to a String.
|
4
|
+
class StringLike
|
5
|
+
attr_reader :str
|
6
|
+
alias_method :to_str, :str
|
7
|
+
|
8
|
+
def initialize(str)
|
9
|
+
@str = str
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
3
13
|
RSpec.configure do |config|
|
4
14
|
config.expect_with :rspec do |expectations|
|
5
15
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: re2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: arm-linux
|
6
6
|
authors:
|
7
7
|
- Paul Mucur
|
8
|
+
- Stan Hu
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
12
|
+
date: 2023-09-16 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rake-compiler
|
@@ -52,7 +53,8 @@ dependencies:
|
|
52
53
|
- - "~>"
|
53
54
|
- !ruby/object:Gem::Version
|
54
55
|
version: '3.2'
|
55
|
-
description: Ruby bindings to
|
56
|
+
description: Ruby bindings to RE2, "a fast, safe, thread-friendly alternative to backtracking
|
57
|
+
regular expression engines like those used in PCRE, Perl, and Python".
|
56
58
|
email:
|
57
59
|
executables: []
|
58
60
|
extensions: []
|
@@ -60,6 +62,7 @@ extra_rdoc_files: []
|
|
60
62
|
files:
|
61
63
|
- ".rspec"
|
62
64
|
- Gemfile
|
65
|
+
- LICENSE-DEPENDENCIES.txt
|
63
66
|
- LICENSE.txt
|
64
67
|
- README.md
|
65
68
|
- Rakefile
|
@@ -67,6 +70,7 @@ files:
|
|
67
70
|
- ext/re2/extconf.rb
|
68
71
|
- ext/re2/re2.cc
|
69
72
|
- ext/re2/recipes.rb
|
73
|
+
- lib/2.6/re2.so
|
70
74
|
- lib/2.7/re2.so
|
71
75
|
- lib/3.0/re2.so
|
72
76
|
- lib/3.1/re2.so
|
@@ -96,20 +100,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
100
|
requirements:
|
97
101
|
- - ">="
|
98
102
|
- !ruby/object:Gem::Version
|
99
|
-
version: '2.
|
103
|
+
version: '2.6'
|
100
104
|
- - "<"
|
101
105
|
- !ruby/object:Gem::Version
|
102
106
|
version: 3.3.dev
|
103
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
108
|
requirements:
|
105
|
-
- - "
|
109
|
+
- - ">="
|
106
110
|
- !ruby/object:Gem::Version
|
107
|
-
version:
|
111
|
+
version: '0'
|
108
112
|
requirements: []
|
109
113
|
rubygems_version: 3.3.26
|
110
114
|
signing_key:
|
111
115
|
specification_version: 4
|
112
|
-
summary: Ruby bindings to
|
116
|
+
summary: Ruby bindings to RE2.
|
113
117
|
test_files:
|
114
118
|
- spec/spec_helper.rb
|
115
119
|
- spec/re2_spec.rb
|