re2 2.0.0.beta1-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6af553e90ae7dd8f360388c62058afe65758c71caa8f986eed2af5f802bcd9a3
4
+ data.tar.gz: 0c3067432988a7bd5b67049b322383a75a0c4f29912f0f1c8aa1c250dc494627
5
+ SHA512:
6
+ metadata.gz: 572dfdb377795f9548aa849c7d38db7896eaea546e5c960288b4016239585e7c5cffb9cc673b4f129458cb592303cc22e122a7a07b786558102a7171a790bc77
7
+ data.tar.gz: 600ff5ec472c9ccae15c8543d7e6df5923cac925683735ff228dea30f2fb84822604895ee10b95e66a1403409f6d4412b13db2c61b020f8fa1e45495ccb97ba9
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ rake_constraint = if RUBY_VERSION < "1.9.3"
6
+ "< 11.0.0"
7
+ elsif RUBY_VERSION < "2.0.0"
8
+ "< 12.0.0"
9
+ else
10
+ "> 12.3.2"
11
+ end
12
+
13
+ gem "rake", rake_constraint
data/LICENSE.txt ADDED
@@ -0,0 +1,28 @@
1
+ Copyright (c) 2010-2014, Paul Mucur.
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+
10
+ * Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation
12
+ and/or other materials provided with the distribution.
13
+
14
+ * Neither the name of Paul Mucur, nor the names of its contributors may be
15
+ used to endorse or promote products derived from this software without
16
+ specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+
data/README.md ADDED
@@ -0,0 +1,239 @@
1
+ re2 [![Build Status](https://github.com/mudge/re2/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/mudge/re2/actions)
2
+ ===
3
+
4
+ A Ruby binding to [re2][], an "efficient, principled regular expression
5
+ library".
6
+
7
+ **Current version:** 1.7.0
8
+ **Supported Ruby versions:** 1.8.7, 1.9.3, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2
9
+ **Supported re2 versions:** libre2.0 (< 2020-03-02), libre2.1 (2020-03-02), libre2.6 (2020-03-03), libre2.7 (2020-05-01), libre2.8 (2020-07-06), libre2.9 (2020-11-01), libre2.10 (2022-12-01), libre2.11 (2023-07-01)
10
+
11
+ Installation
12
+ ------------
13
+
14
+ You will need [re2][] installed as well as a C++ compiler such as [gcc][] (on
15
+ Debian and Ubuntu, this is provided by the [build-essential][] package). If
16
+ you are using Mac OS X, I recommend installing re2 with [Homebrew][] by
17
+ running the following:
18
+
19
+ $ brew install re2
20
+
21
+ If you are using Debian, you can install the [libre2-dev][] package like so:
22
+
23
+ $ sudo apt-get install libre2-dev
24
+
25
+ Recent versions of re2 require a compiler with C++14 support such as [clang](http://clang.llvm.org/) 3.4 or [gcc](https://gcc.gnu.org/) 5.
26
+
27
+ If you are using a packaged Ruby distribution, make sure you also have the
28
+ Ruby header files installed such as those provided by the [ruby-dev][] package
29
+ on Debian and Ubuntu.
30
+
31
+ You can then install the library via RubyGems with `gem install re2` or `gem
32
+ install re2 -- --with-re2-dir=/path/to/re2/prefix` if re2 is not installed in
33
+ any of the following default locations:
34
+
35
+ * `/usr/local`
36
+ * `/opt/homebrew`
37
+ * `/usr`
38
+
39
+ Documentation
40
+ -------------
41
+
42
+ Full documentation automatically generated from the latest version is
43
+ available at <http://mudge.name/re2/>.
44
+
45
+ Note that re2's regular expression syntax differs from PCRE and Ruby's
46
+ built-in [`Regexp`][Regexp] library, see the [official syntax page][] for more
47
+ details.
48
+
49
+ Usage
50
+ -----
51
+
52
+ While re2 uses the same naming scheme as Ruby's built-in regular expression
53
+ library (with [`Regexp`](http://mudge.name/re2/RE2/Regexp.html) and
54
+ [`MatchData`](http://mudge.name/re2/RE2/MatchData.html)), its API is slightly
55
+ different:
56
+
57
+ ```console
58
+ $ irb -rubygems
59
+ > require 're2'
60
+ > r = RE2::Regexp.new('w(\d)(\d+)')
61
+ => #<RE2::Regexp /w(\d)(\d+)/>
62
+ > m = r.match("w1234")
63
+ => #<RE2::MatchData "w1234" 1:"1" 2:"234">
64
+ > m[1]
65
+ => "1"
66
+ > m.string
67
+ => "w1234"
68
+ > m.begin(1)
69
+ => 1
70
+ > m.end(1)
71
+ => 2
72
+ > r =~ "w1234"
73
+ => true
74
+ > r !~ "bob"
75
+ => true
76
+ > r.match("bob")
77
+ => nil
78
+ ```
79
+
80
+ As
81
+ [`RE2::Regexp.new`](http://mudge.name/re2/RE2/Regexp.html#initialize-instance_method)
82
+ (or `RE2::Regexp.compile`) can be quite verbose, a helper method has been
83
+ defined against `Kernel` so you can use a shorter version to create regular
84
+ expressions:
85
+
86
+ ```console
87
+ > RE2('(\d+)')
88
+ => #<RE2::Regexp /(\d+)/>
89
+ ```
90
+
91
+ Note the use of *single quotes* as double quotes will interpret `\d` as `d` as
92
+ in the following example:
93
+
94
+ ```console
95
+ > RE2("(\d+)")
96
+ => #<RE2::Regexp /(d+)/>
97
+ ```
98
+
99
+ As of 0.3.0, you can use named groups:
100
+
101
+ ```console
102
+ > r = RE2::Regexp.new('(?P<name>\w+) (?P<age>\d+)')
103
+ => #<RE2::Regexp /(?P<name>\w+) (?P<age>\d+)/>
104
+ > m = r.match("Bob 40")
105
+ => #<RE2::MatchData "Bob 40" 1:"Bob" 2:"40">
106
+ > m[:name]
107
+ => "Bob"
108
+ > m["age"]
109
+ => "40"
110
+ ```
111
+
112
+ As of 0.6.0, you can use `RE2::Regexp#scan` to incrementally scan text for
113
+ matches (similar in purpose to Ruby's
114
+ [`String#scan`](http://ruby-doc.org/core-2.0.0/String.html#method-i-scan)).
115
+ Calling `scan` will return an `RE2::Scanner` which is
116
+ [enumerable](http://ruby-doc.org/core-2.0.0/Enumerable.html) meaning you can
117
+ use `each` to iterate through the matches (and even use
118
+ [`Enumerator::Lazy`](http://ruby-doc.org/core-2.0/Enumerator/Lazy.html)):
119
+
120
+ ```ruby
121
+ re = RE2('(\w+)')
122
+ scanner = re.scan("It is a truth universally acknowledged")
123
+ scanner.each do |match|
124
+ puts match
125
+ end
126
+
127
+ scanner.rewind
128
+
129
+ enum = scanner.to_enum
130
+ enum.next #=> ["It"]
131
+ enum.next #=> ["is"]
132
+ ```
133
+
134
+ As of 1.5.0, you can use `RE2::Set` to match multiple patterns against a
135
+ string. Calling `RE2::Set#add` with a pattern will return an integer index of
136
+ the pattern. After all patterns have been added, the set can be compiled using
137
+ `RE2::Set#compile`, and then `RE2::Set#match` will return an `Array<Integer>`
138
+ containing the indices of all the patterns that matched.
139
+
140
+ ```ruby
141
+ set = RE2::Set.new
142
+ set.add("abc") #=> 0
143
+ set.add("def") #=> 1
144
+ set.add("ghi") #=> 2
145
+ set.compile #=> true
146
+ set.match("abcdefghi") #=> [0, 1, 2]
147
+ set.match("ghidefabc") #=> [2, 1, 0]
148
+ ```
149
+
150
+ As of 1.6.0, you can use [Ruby's pattern matching](https://docs.ruby-lang.org/en/3.0/syntax/pattern_matching_rdoc.html) against `RE2::MatchData` with both array patterns and hash patterns:
151
+
152
+ ```ruby
153
+ case RE2('(\w+) (\d+)').match("Alice 42")
154
+ in [name, age]
155
+ puts "My name is #{name} and I am #{age} years old"
156
+ else
157
+ puts "No match!"
158
+ end
159
+ # My name is Alice and I am 42 years old
160
+
161
+
162
+ case RE2('(?P<name>\w+) (?P<age>\d+)').match("Alice 42")
163
+ in {name:, age:}
164
+ puts "My name is #{name} and I am #{age} years old"
165
+ else
166
+ puts "No match!"
167
+ end
168
+ # My name is Alice and I am 42 years old
169
+ ```
170
+
171
+ Features
172
+ --------
173
+
174
+ * Pre-compiling regular expressions with
175
+ [`RE2::Regexp.new(re)`](https://github.com/google/re2/blob/2016-02-01/re2/re2.h#L100),
176
+ `RE2::Regexp.compile(re)` or `RE2(re)` (including specifying options, e.g.
177
+ `RE2::Regexp.new("pattern", :case_sensitive => false)`
178
+
179
+ * Extracting matches with `re2.match(text)` (and an exact number of matches
180
+ with `re2.match(text, number_of_matches)` such as `re2.match("123-234", 2)`)
181
+
182
+ * Extracting matches by name (both with strings and symbols)
183
+
184
+ * Checking for matches with `re2 =~ text`, `re2 === text` (for use in `case`
185
+ statements) and `re2 !~ text`
186
+
187
+ * Incrementally scanning text with `re2.scan(text)`
188
+
189
+ * Search a collection of patterns simultaneously with `RE2::Set`
190
+
191
+ * Checking regular expression compilation with `re2.ok?`, `re2.error` and
192
+ `re2.error_arg`
193
+
194
+ * Checking regular expression "cost" with `re2.program_size`
195
+
196
+ * Checking the options for an expression with `re2.options` or individually
197
+ with `re2.case_sensitive?`
198
+
199
+ * Performing a single string replacement with `pattern.replace(replacement,
200
+ original)`
201
+
202
+ * Performing a global string replacement with
203
+ `pattern.replace_all(replacement, original)`
204
+
205
+ * Escaping regular expressions with
206
+ [`RE2.escape(unquoted)`](https://github.com/google/re2/blob/2016-02-01/re2/re2.h#L418) and
207
+ `RE2.quote(unquoted)`
208
+
209
+ * Pattern matching with `RE2::MatchData`
210
+
211
+ Contributions
212
+ -------------
213
+
214
+ * Thanks to [Jason Woods](https://github.com/driskell) who contributed the
215
+ original implementations of `RE2::MatchData#begin` and `RE2::MatchData#end`;
216
+ * Thanks to [Stefano Rivera](https://github.com/stefanor) who first contributed C++11 support;
217
+ * Thanks to [Stan Hu](https://github.com/stanhu) for reporting a bug with empty patterns and `RE2::Regexp#scan` and for contributing support for libre2.11 (2023-07-01);
218
+ * Thanks to [Sebastian Reitenbach](https://github.com/buzzdeee) for reporting
219
+ the deprecation and removal of the `utf8` encoding option in re2;
220
+ * Thanks to [Sergio Medina](https://github.com/serch) for reporting a bug when
221
+ using `RE2::Scanner#scan` with an invalid regular expression;
222
+ * Thanks to [Pritam Baral](https://github.com/pritambaral) for contributed the
223
+ initial support for `RE2::Set`.
224
+
225
+ Contact
226
+ -------
227
+
228
+ All issues and suggestions should go to [GitHub Issues](https://github.com/mudge/re2/issues).
229
+
230
+ [re2]: https://github.com/google/re2
231
+ [gcc]: http://gcc.gnu.org/
232
+ [ruby-dev]: http://packages.debian.org/ruby-dev
233
+ [build-essential]: http://packages.debian.org/build-essential
234
+ [Regexp]: http://ruby-doc.org/core/classes/Regexp.html
235
+ [MatchData]: http://ruby-doc.org/core/classes/MatchData.html
236
+ [Homebrew]: http://mxcl.github.com/homebrew
237
+ [libre2-dev]: http://packages.debian.org/search?keywords=libre2-dev
238
+ [official syntax page]: https://github.com/google/re2/wiki/Syntax
239
+
data/Rakefile ADDED
@@ -0,0 +1,155 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rake/extensiontask'
4
+ require 'rspec/core/rake_task'
5
+ require 'rake_compiler_dock'
6
+ require 'yaml'
7
+
8
+ require_relative 'ext/re2/recipes'
9
+
10
+ CLEAN.include FileList['**/*{.o,.so,.dylib,.bundle}'],
11
+ FileList['**/extconf.h'],
12
+ FileList['**/Makefile'],
13
+ FileList['pkg/']
14
+
15
+ CLOBBER.include FileList['**/tmp'],
16
+ FileList['**/*.log'],
17
+ FileList['doc/**'],
18
+ FileList['tmp/']
19
+ CLOBBER.add("ports/*").exclude(%r{ports/archives$})
20
+
21
+ RE2_GEM_SPEC = Gem::Specification.load('re2.gemspec')
22
+
23
+ task :prepare do
24
+ puts "Preparing project for gem building..."
25
+ recipes = load_recipes
26
+ recipes.each { |recipe| recipe.download }
27
+ end
28
+
29
+ task gem: :prepare
30
+
31
+ Gem::PackageTask.new(RE2_GEM_SPEC) do |p|
32
+ p.need_zip = false
33
+ p.need_tar = false
34
+ end
35
+
36
+ CROSS_RUBY_VERSIONS = %w[3.2.0 3.1.0 3.0.0 2.7.0].join(':')
37
+ CROSS_RUBY_PLATFORMS = %w[
38
+ aarch64-linux
39
+ arm-linux
40
+ arm64-darwin
41
+ x64-mingw-ucrt
42
+ x64-mingw32
43
+ x86-linux
44
+ x86-mingw32
45
+ x86_64-darwin
46
+ x86_64-linux
47
+ ].freeze
48
+
49
+ ENV['RUBY_CC_VERSION'] = CROSS_RUBY_VERSIONS
50
+
51
+ Rake::ExtensionTask.new('re2', RE2_GEM_SPEC) do |e|
52
+ e.cross_compile = true
53
+ e.cross_config_options << '--enable-cross-build'
54
+ e.config_options << '--disable-system-libraries'
55
+ e.cross_platform = CROSS_RUBY_PLATFORMS
56
+ e.cross_compiling do |spec|
57
+ spec.files.reject! { |path| File.fnmatch?('ports/*', path) }
58
+ spec.dependencies.reject! { |dep| dep.name == 'mini_portile2' }
59
+ end
60
+ end
61
+
62
+ RSpec::Core::RakeTask.new(:spec)
63
+
64
+ namespace 'gem' do
65
+ def gem_builder(platform)
66
+ # use Task#invoke because the pkg/*gem task is defined at runtime
67
+ Rake::Task["native:#{platform}"].invoke
68
+ Rake::Task["pkg/#{RE2_GEM_SPEC.full_name}-#{Gem::Platform.new(platform)}.gem"].invoke
69
+ end
70
+
71
+ CROSS_RUBY_PLATFORMS.each do |platform|
72
+ # The Linux x86 image (ghcr.io/rake-compiler/rake-compiler-dock-image:1.3.0-mri-x86_64-linux)
73
+ # is based on CentOS 7 and has two versions of cmake installed:
74
+ # a 2.8 version in /usr/bin and a 3.25 in /usr/local/bin. The latter is needed by abseil.
75
+ cmake =
76
+ case platform
77
+ when 'x86_64-linux', 'x86-linux'
78
+ '/usr/local/bin/cmake'
79
+ else
80
+ 'cmake'
81
+ end
82
+
83
+ desc "build native gem for #{platform} platform"
84
+ task platform do
85
+ RakeCompilerDock.sh <<~SCRIPT, platform: platform, verbose: true
86
+ gem install bundler --no-document &&
87
+ bundle &&
88
+ bundle exec rake gem:#{platform}:builder CMAKE=#{cmake}
89
+ SCRIPT
90
+ end
91
+
92
+ namespace platform do
93
+ desc "build native gem for #{platform} platform (guest container)"
94
+ task 'builder' do
95
+ gem_builder(platform)
96
+ end
97
+ end
98
+ end
99
+
100
+ desc 'build all native gems'
101
+ multitask 'native' => CROSS_RUBY_PLATFORMS
102
+ end
103
+
104
+ def add_file_to_gem(relative_source_path)
105
+ dest_path = File.join(gem_build_path, relative_source_path)
106
+ dest_dir = File.dirname(dest_path)
107
+
108
+ mkdir_p dest_dir unless Dir.exist?(dest_dir)
109
+ rm_f dest_path if File.exist?(dest_path)
110
+ safe_ln relative_source_path, dest_path
111
+
112
+ RE2_GEM_SPEC.files << relative_source_path
113
+ end
114
+
115
+ def gem_build_path
116
+ File.join 'pkg', RE2_GEM_SPEC.full_name
117
+ end
118
+
119
+ def add_vendored_libraries
120
+ dependencies = YAML.load_file(File.join(File.dirname(__FILE__), 'dependencies.yml'))
121
+ abseil_archive = File.join('ports', 'archives', "#{dependencies['abseil']['version']}.tar.gz")
122
+ libre2_archive = File.join('ports', 'archives', "re2-#{dependencies['libre2']['version']}.tar.gz")
123
+
124
+ add_file_to_gem(abseil_archive)
125
+ add_file_to_gem(libre2_archive)
126
+ end
127
+
128
+ task gem_build_path do
129
+ add_vendored_libraries
130
+ end
131
+
132
+ desc "Temporarily set VERSION to a unique timestamp"
133
+ task "set-version-to-timestamp" do
134
+ # this task is used by bin/test-gem-build
135
+ # to test building, packaging, and installing a precompiled gem
136
+ version_constant_re = /^\s*VERSION\s*=\s*["'](.*)["']$/
137
+
138
+ version_file_path = File.join(__dir__, "lib/re2/version.rb")
139
+ version_file_contents = File.read(version_file_path)
140
+
141
+ current_version_string = version_constant_re.match(version_file_contents)[1]
142
+ current_version = Gem::Version.new(current_version_string)
143
+
144
+ fake_version = Gem::Version.new(format("%s.test.%s", current_version.bump, Time.now.strftime("%Y.%m%d.%H%M")))
145
+
146
+ unless version_file_contents.gsub!(version_constant_re, " VERSION = \"#{fake_version}\"")
147
+ raise("Could not hack the VERSION constant")
148
+ end
149
+
150
+ File.open(version_file_path, "w") { |f| f.write(version_file_contents) }
151
+
152
+ puts "NOTE: wrote version as \"#{fake_version}\""
153
+ end
154
+
155
+ task default: [:compile, :spec]
data/dependencies.yml ADDED
@@ -0,0 +1,9 @@
1
+ libre2:
2
+ version: "2023-07-01"
3
+ sha256: "18cf85922e27fad3ed9c96a27733037da445f35eb1a2744c306a37c6d11e95c4"
4
+ # sha-256 hash provided in https://github.com/google/re2/releases/download/2023-07-01/re2-2023-07-01.tar.gz
5
+
6
+ abseil:
7
+ version: "20230125.3"
8
+ sha256: 5366d7e7fa7ba0d915014d387b66d0d002c03236448e1ba9ef98122c13b35c36
9
+ # sha-256 hash provided in https://github.com/abseil/abseil-cpp/archive/refs/tags/20230125.3.tar.gz