re2 2.15.0 → 2.16.0
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 +6 -3
- data/Rakefile +2 -1
- data/dependencies.yml +4 -4
- data/ext/re2/extconf.rb +18 -0
- data/ext/re2/re2.cc +37 -0
- data/lib/re2/version.rb +1 -1
- data/ports/archives/20250127.1.tar.gz +0 -0
- data/ports/archives/re2-2025-06-26b.tar.gz +0 -0
- data/re2.gemspec +1 -1
- data/spec/re2/set_spec.rb +44 -0
- metadata +12 -12
- data/ports/archives/20240722.0.tar.gz +0 -0
- data/ports/archives/re2-2024-07-02.tar.gz +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5dda47249dece471c693d3947867757b29d48f654833de543d4d4bfb53cda23b
|
4
|
+
data.tar.gz: 171046cf40fbd75522368fa4107919d343fdfead96b97f532c9d69bf863c48c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e08a30136b82117f1b367afcdd18a16cc979772f9dc5913c80fa0822a891b2af9c975b36aee54d1d874af6ca4c395de9e9b1e9373cd45588f6ef35b8b83d4e34
|
7
|
+
data.tar.gz: 860c87853862bffb37405d6d878ccb407caa21db65ae4e3ef40ffb5689573b8f43a4a83a19cb905ed9b36c42f9c4003aa487a998076defaf06bf521583e96f83
|
data/README.md
CHANGED
@@ -6,8 +6,8 @@ Python".
|
|
6
6
|
|
7
7
|
[](https://github.com/mudge/re2/actions)
|
8
8
|
|
9
|
-
**Current version:** 2.
|
10
|
-
**Bundled RE2 version:** libre2.11 (
|
9
|
+
**Current version:** 2.16.0
|
10
|
+
**Bundled RE2 version:** libre2.11 (2025-06-26b)
|
11
11
|
|
12
12
|
```ruby
|
13
13
|
RE2('h.*o').full_match?("hello") #=> true
|
@@ -224,12 +224,15 @@ the set. After all patterns have been added, the set can be compiled using
|
|
224
224
|
and then
|
225
225
|
[`RE2::Set#match`](https://mudge.name/re2/RE2/Set.html#match-instance_method)
|
226
226
|
will return an array containing the indices of all the patterns that matched.
|
227
|
+
[`RE2::Set#size`](https://mudge.name/re2/RE2/Set.html#size-instance_method)
|
228
|
+
will return the number of patterns in the set.
|
227
229
|
|
228
230
|
```ruby
|
229
231
|
set = RE2::Set.new
|
230
232
|
set.add("abc") #=> 0
|
231
233
|
set.add("def") #=> 1
|
232
234
|
set.add("ghi") #=> 2
|
235
|
+
set.size #=> 3
|
233
236
|
set.compile #=> true
|
234
237
|
set.match("abcdefghi") #=> [0, 1, 2]
|
235
238
|
set.match("ghidefabc") #=> [2, 1, 0]
|
@@ -261,7 +264,7 @@ This gem requires the following to run:
|
|
261
264
|
|
262
265
|
It supports the following RE2 ABI versions:
|
263
266
|
|
264
|
-
* libre2.0 (prior to release 2020-03-02) to libre2.11 (2023-07-01 to
|
267
|
+
* libre2.0 (prior to release 2020-03-02) to libre2.11 (2023-07-01 to 2025-06-26b)
|
265
268
|
|
266
269
|
### Native gems
|
267
270
|
|
data/Rakefile
CHANGED
@@ -33,7 +33,7 @@ cross_platforms = %w[
|
|
33
33
|
x86_64-linux-musl
|
34
34
|
].freeze
|
35
35
|
|
36
|
-
|
36
|
+
RakeCompilerDock.set_ruby_cc_version("~> 2.6", "~> 3.0")
|
37
37
|
|
38
38
|
Gem::PackageTask.new(re2_gemspec).define
|
39
39
|
|
@@ -70,6 +70,7 @@ namespace :gem do
|
|
70
70
|
desc "Compile and build native gem for #{platform} platform"
|
71
71
|
task platform do
|
72
72
|
RakeCompilerDock.sh <<~SCRIPT, platform: platform, verbose: true
|
73
|
+
rbenv shell 3.1.6 &&
|
73
74
|
gem install bundler --no-document &&
|
74
75
|
bundle &&
|
75
76
|
bundle exec rake native:#{platform} pkg/#{re2_gemspec.full_name}-#{Gem::Platform.new(platform)}.gem PATH="/usr/local/bin:$PATH"
|
data/dependencies.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
libre2:
|
3
|
-
version:
|
4
|
-
sha256:
|
3
|
+
version: 2025-06-26b
|
4
|
+
sha256: 641a3ca337814a6c3676a389ea065812e00ff796f31a427038bc010bae0b86e3
|
5
5
|
abseil:
|
6
|
-
version: '
|
7
|
-
sha256:
|
6
|
+
version: '20250127.1'
|
7
|
+
sha256: b396401fd29e2e679cace77867481d388c807671dc2acc602a0259eeb79b7811
|
data/ext/re2/extconf.rb
CHANGED
@@ -217,6 +217,24 @@ module RE2
|
|
217
217
|
$defs.push("-DHAVE_ERROR_INFO_ARGUMENT")
|
218
218
|
end
|
219
219
|
end
|
220
|
+
|
221
|
+
checking_for("RE2::Set::Size()") do
|
222
|
+
test_re2_set_size = <<~SRC
|
223
|
+
#include <re2/re2.h>
|
224
|
+
#include <re2/set.h>
|
225
|
+
|
226
|
+
int main() {
|
227
|
+
RE2::Set s(RE2::DefaultOptions, RE2::UNANCHORED);
|
228
|
+
s.Size();
|
229
|
+
|
230
|
+
return 0;
|
231
|
+
}
|
232
|
+
SRC
|
233
|
+
|
234
|
+
if try_compile(test_re2_set_size, compile_options)
|
235
|
+
$defs.push("-DHAVE_SET_SIZE")
|
236
|
+
end
|
237
|
+
end
|
220
238
|
end
|
221
239
|
|
222
240
|
def static_pkg_config(pc_file, pkg_config_paths)
|
data/ext/re2/re2.cc
CHANGED
@@ -1962,6 +1962,26 @@ static VALUE re2_set_compile(VALUE self) {
|
|
1962
1962
|
return BOOL2RUBY(s->set->Compile());
|
1963
1963
|
}
|
1964
1964
|
|
1965
|
+
/*
|
1966
|
+
* Returns the size of the {RE2::Set}.
|
1967
|
+
*
|
1968
|
+
* @return [Integer] the number of patterns in the set
|
1969
|
+
* @example
|
1970
|
+
* set = RE2::Set.new
|
1971
|
+
* set.add("abc")
|
1972
|
+
* set.size #=> 1
|
1973
|
+
*/
|
1974
|
+
static VALUE re2_set_size(VALUE self) {
|
1975
|
+
#ifdef HAVE_SET_SIZE
|
1976
|
+
re2_set *s;
|
1977
|
+
TypedData_Get_Struct(self, re2_set, &re2_set_data_type, s);
|
1978
|
+
|
1979
|
+
return INT2FIX(s->set->Size());
|
1980
|
+
#else
|
1981
|
+
rb_raise(re2_eSetUnsupportedError, "current version of RE2::Set does not have Size method");
|
1982
|
+
#endif
|
1983
|
+
}
|
1984
|
+
|
1965
1985
|
/*
|
1966
1986
|
* Returns whether the underlying RE2 version outputs error information from
|
1967
1987
|
* {https://github.com/google/re2/blob/bc0faab533e2b27b85b8ad312abf061e33ed6b5d/re2/set.h#L62-L65
|
@@ -1978,6 +1998,19 @@ static VALUE re2_set_match_raises_errors_p(VALUE) {
|
|
1978
1998
|
#endif
|
1979
1999
|
}
|
1980
2000
|
|
2001
|
+
/*
|
2002
|
+
* Returns whether the underlying RE2 version has a Set::Size method.
|
2003
|
+
*
|
2004
|
+
* @return [Boolean] whether the underlying RE2 has a Set::Size method
|
2005
|
+
*/
|
2006
|
+
static VALUE re2_set_size_p(VALUE) {
|
2007
|
+
#ifdef HAVE_SET_SIZE
|
2008
|
+
return Qtrue;
|
2009
|
+
#else
|
2010
|
+
return Qfalse;
|
2011
|
+
#endif
|
2012
|
+
}
|
2013
|
+
|
1981
2014
|
/*
|
1982
2015
|
* Matches the given text against patterns in the set, returning an array of
|
1983
2016
|
* integer indices of the matching patterns if matched or an empty array if
|
@@ -2208,11 +2241,15 @@ extern "C" void Init_re2(void) {
|
|
2208
2241
|
|
2209
2242
|
rb_define_singleton_method(re2_cSet, "match_raises_errors?",
|
2210
2243
|
RUBY_METHOD_FUNC(re2_set_match_raises_errors_p), 0);
|
2244
|
+
rb_define_singleton_method(re2_cSet, "size?",
|
2245
|
+
RUBY_METHOD_FUNC(re2_set_size_p), 0);
|
2211
2246
|
rb_define_method(re2_cSet, "initialize",
|
2212
2247
|
RUBY_METHOD_FUNC(re2_set_initialize), -1);
|
2213
2248
|
rb_define_method(re2_cSet, "add", RUBY_METHOD_FUNC(re2_set_add), 1);
|
2214
2249
|
rb_define_method(re2_cSet, "compile", RUBY_METHOD_FUNC(re2_set_compile), 0);
|
2215
2250
|
rb_define_method(re2_cSet, "match", RUBY_METHOD_FUNC(re2_set_match), -1);
|
2251
|
+
rb_define_method(re2_cSet, "size", RUBY_METHOD_FUNC(re2_set_size), 0);
|
2252
|
+
rb_define_method(re2_cSet, "length", RUBY_METHOD_FUNC(re2_set_size), 0);
|
2216
2253
|
|
2217
2254
|
rb_define_module_function(re2_mRE2, "Replace",
|
2218
2255
|
RUBY_METHOD_FUNC(re2_Replace), 3);
|
data/lib/re2/version.rb
CHANGED
Binary file
|
Binary file
|
data/re2.gemspec
CHANGED
@@ -41,7 +41,7 @@ Gem::Specification.new do |s|
|
|
41
41
|
"spec/re2/scanner_spec.rb"
|
42
42
|
]
|
43
43
|
s.add_development_dependency("rake-compiler", "~> 1.2.7")
|
44
|
-
s.add_development_dependency("rake-compiler-dock", "~> 1.
|
44
|
+
s.add_development_dependency("rake-compiler-dock", "~> 1.9.1")
|
45
45
|
s.add_development_dependency("rspec", "~> 3.2")
|
46
46
|
s.add_runtime_dependency("mini_portile2", "~> 2.8.7") # keep version in sync with extconf.rb
|
47
47
|
end
|
data/spec/re2/set_spec.rb
CHANGED
@@ -204,6 +204,50 @@ RSpec.describe RE2::Set do
|
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
207
|
+
describe "#size" do
|
208
|
+
it "returns the number of patterns added to the set", :aggregate_failures do
|
209
|
+
skip "Underlying RE2::Set has no Size method" unless RE2::Set.size?
|
210
|
+
|
211
|
+
set = RE2::Set.new
|
212
|
+
|
213
|
+
expect(set.size).to eq(0)
|
214
|
+
|
215
|
+
set.add("abc")
|
216
|
+
|
217
|
+
expect(set.size).to eq(1)
|
218
|
+
|
219
|
+
set.add("def")
|
220
|
+
|
221
|
+
expect(set.size).to eq(2)
|
222
|
+
end
|
223
|
+
|
224
|
+
it "raises an error if RE2 does not support Set::Size" do
|
225
|
+
skip "Underlying RE2::Set has a Size method" if RE2::Set.size?
|
226
|
+
|
227
|
+
set = RE2::Set.new
|
228
|
+
|
229
|
+
expect { set.size }.to raise_error(RE2::Set::UnsupportedError)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
describe "#length" do
|
234
|
+
it "is an alias for size" do
|
235
|
+
skip "Underlying RE2::Set has no Size method" unless RE2::Set.size?
|
236
|
+
|
237
|
+
set = RE2::Set.new
|
238
|
+
|
239
|
+
expect(set.length).to eq(0)
|
240
|
+
|
241
|
+
set.add("abc")
|
242
|
+
|
243
|
+
expect(set.length).to eq(1)
|
244
|
+
|
245
|
+
set.add("def")
|
246
|
+
|
247
|
+
expect(set.length).to eq(2)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
207
251
|
def silence_stderr
|
208
252
|
original_stream = STDERR
|
209
253
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: re2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Mucur
|
8
8
|
- Stan Hu
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.9.1
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
40
|
+
version: 1.9.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,8 +88,8 @@ files:
|
|
88
88
|
- lib/re2/scanner.rb
|
89
89
|
- lib/re2/string.rb
|
90
90
|
- lib/re2/version.rb
|
91
|
-
- ports/archives/
|
92
|
-
- ports/archives/re2-
|
91
|
+
- ports/archives/20250127.1.tar.gz
|
92
|
+
- ports/archives/re2-2025-06-26b.tar.gz
|
93
93
|
- re2.gemspec
|
94
94
|
- spec/kernel_spec.rb
|
95
95
|
- spec/re2/match_data_spec.rb
|
@@ -117,16 +117,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: '0'
|
119
119
|
requirements: []
|
120
|
-
rubygems_version: 3.6.
|
120
|
+
rubygems_version: 3.6.7
|
121
121
|
specification_version: 4
|
122
122
|
summary: Ruby bindings to RE2.
|
123
123
|
test_files:
|
124
124
|
- ".rspec"
|
125
|
-
- spec/spec_helper.rb
|
126
|
-
- spec/re2_spec.rb
|
127
125
|
- spec/kernel_spec.rb
|
128
|
-
- spec/re2/regexp_spec.rb
|
129
126
|
- spec/re2/match_data_spec.rb
|
130
|
-
- spec/re2/
|
131
|
-
- spec/re2/set_spec.rb
|
127
|
+
- spec/re2/regexp_spec.rb
|
132
128
|
- spec/re2/scanner_spec.rb
|
129
|
+
- spec/re2/set_spec.rb
|
130
|
+
- spec/re2/string_spec.rb
|
131
|
+
- spec/re2_spec.rb
|
132
|
+
- spec/spec_helper.rb
|
Binary file
|
Binary file
|