re2 2.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 61adec1576c6c0a07b57f7e5c579c198193e600d9cdadb4d2b206f7743cdbeff
4
+ data.tar.gz: 92e0cc8523bc056c95c6401e83acbbe31c7d35be85072910d432592df94cfa02
5
+ SHA512:
6
+ metadata.gz: 02b960acdfcc5e3d9b4fe556be705ba10c61fd730095a02365f94aa72a48517a51b372fcbd29b74127bb2adf1bed8b9d89636ded374750a0deb1c4e2722099cc
7
+ data.tar.gz: 726387d17994989d26ef4841ea8d5e90ec4c13f4f95691b524604b1310b7fd10002f1171be65dc3e99e145c522b750f804278acb5475c5f190f977dd777d753a
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "rake", "> 12.3.2"
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,263 @@
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:** 2.0.0
8
+ **Supported Ruby versions:** 2.6, 2.7, 3.0, 3.1, 3.2
9
+ **Bundled re2 version:** libre2.11 (2023-09-01)
10
+ **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)
11
+
12
+ Installation
13
+ ------------
14
+
15
+ The gem comes bundled with a version of [re2][] and will compile itself (and
16
+ any dependencies) on install. As compilation can take a while, precompiled
17
+ native gems are available for Linux, Windows and macOS.
18
+
19
+ In v2.0 and later, precompiled native gems are available for Ruby 2.6 to 3.2
20
+ on these platforms:
21
+
22
+ - `aarch64-linux` (requires: glibc >= 2.29)
23
+ - `arm-linux` (requires: glibc >= 2.29)
24
+ - `arm64-darwin`
25
+ - `x64-mingw32` / `x64-mingw-ucrt`
26
+ - `x86-linux` (requires: glibc >= 2.17)
27
+ - `x86_64-darwin`
28
+ - `x86_64-linux` (requires: glibc >= 2.17)
29
+
30
+ If you wish to opt out of using the bundled libraries, you will need re2
31
+ installed as well as a C++ compiler such as [gcc][] (on Debian and Ubuntu, this
32
+ is provided by the [build-essential][] package). If you are using Mac OS X, I
33
+ recommend installing re2 with [Homebrew][] by running the following:
34
+
35
+ $ brew install re2
36
+
37
+ If you are using Debian, you can install the [libre2-dev][] package like so:
38
+
39
+ $ sudo apt-get install libre2-dev
40
+
41
+ Recent versions of re2 require a compiler with C++14 support such as
42
+ [clang](http://clang.llvm.org/) 3.4 or [gcc](https://gcc.gnu.org/) 5.
43
+
44
+ If you are using a packaged Ruby distribution, make sure you also have the
45
+ Ruby header files installed such as those provided by the [ruby-dev][] package
46
+ on Debian and Ubuntu.
47
+
48
+ You can then install the library via RubyGems with `gem install re2 --platform=ruby --
49
+ --enable-system-libraries` or `gem install re2 --platform=ruby -- --enable-system-libraries
50
+ --with-re2-dir=/path/to/re2/prefix` if re2 is not installed in any of the
51
+ following default locations:
52
+
53
+ * `/usr/local`
54
+ * `/opt/homebrew`
55
+ * `/usr`
56
+
57
+ Alternatively, you can set the `RE2_USE_SYSTEM_LIBRARIES` environment variable instead of passing `--enable-system-libraries` to the `gem` command.
58
+
59
+ If you're using Bundler, you can use the
60
+ [`force_ruby_platform`](https://bundler.io/v2.3/man/gemfile.5.html#FORCE_RUBY_PLATFORM)
61
+ option in your Gemfile.
62
+
63
+ Documentation
64
+ -------------
65
+
66
+ Full documentation automatically generated from the latest version is
67
+ available at <http://mudge.name/re2/>.
68
+
69
+ Note that re2's regular expression syntax differs from PCRE and Ruby's
70
+ built-in [`Regexp`][Regexp] library, see the [official syntax page][] for more
71
+ details.
72
+
73
+ Usage
74
+ -----
75
+
76
+ While re2 uses the same naming scheme as Ruby's built-in regular expression
77
+ library (with [`Regexp`](http://mudge.name/re2/RE2/Regexp.html) and
78
+ [`MatchData`](http://mudge.name/re2/RE2/MatchData.html)), its API is slightly
79
+ different:
80
+
81
+ ```console
82
+ $ irb -rubygems
83
+ > require 're2'
84
+ > r = RE2::Regexp.new('w(\d)(\d+)')
85
+ => #<RE2::Regexp /w(\d)(\d+)/>
86
+ > m = r.match("w1234")
87
+ => #<RE2::MatchData "w1234" 1:"1" 2:"234">
88
+ > m[1]
89
+ => "1"
90
+ > m.string
91
+ => "w1234"
92
+ > m.begin(1)
93
+ => 1
94
+ > m.end(1)
95
+ => 2
96
+ > r =~ "w1234"
97
+ => true
98
+ > r !~ "bob"
99
+ => true
100
+ > r.match("bob")
101
+ => nil
102
+ ```
103
+
104
+ As
105
+ [`RE2::Regexp.new`](http://mudge.name/re2/RE2/Regexp.html#initialize-instance_method)
106
+ (or `RE2::Regexp.compile`) can be quite verbose, a helper method has been
107
+ defined against `Kernel` so you can use a shorter version to create regular
108
+ expressions:
109
+
110
+ ```console
111
+ > RE2('(\d+)')
112
+ => #<RE2::Regexp /(\d+)/>
113
+ ```
114
+
115
+ Note the use of *single quotes* as double quotes will interpret `\d` as `d` as
116
+ in the following example:
117
+
118
+ ```console
119
+ > RE2("(\d+)")
120
+ => #<RE2::Regexp /(d+)/>
121
+ ```
122
+
123
+ As of 0.3.0, you can use named groups:
124
+
125
+ ```console
126
+ > r = RE2::Regexp.new('(?P<name>\w+) (?P<age>\d+)')
127
+ => #<RE2::Regexp /(?P<name>\w+) (?P<age>\d+)/>
128
+ > m = r.match("Bob 40")
129
+ => #<RE2::MatchData "Bob 40" 1:"Bob" 2:"40">
130
+ > m[:name]
131
+ => "Bob"
132
+ > m["age"]
133
+ => "40"
134
+ ```
135
+
136
+ As of 0.6.0, you can use `RE2::Regexp#scan` to incrementally scan text for
137
+ matches (similar in purpose to Ruby's
138
+ [`String#scan`](http://ruby-doc.org/core-2.0.0/String.html#method-i-scan)).
139
+ Calling `scan` will return an `RE2::Scanner` which is
140
+ [enumerable](http://ruby-doc.org/core-2.0.0/Enumerable.html) meaning you can
141
+ use `each` to iterate through the matches (and even use
142
+ [`Enumerator::Lazy`](http://ruby-doc.org/core-2.0/Enumerator/Lazy.html)):
143
+
144
+ ```ruby
145
+ re = RE2('(\w+)')
146
+ scanner = re.scan("It is a truth universally acknowledged")
147
+ scanner.each do |match|
148
+ puts match
149
+ end
150
+
151
+ scanner.rewind
152
+
153
+ enum = scanner.to_enum
154
+ enum.next #=> ["It"]
155
+ enum.next #=> ["is"]
156
+ ```
157
+
158
+ As of 1.5.0, you can use `RE2::Set` to match multiple patterns against a
159
+ string. Calling `RE2::Set#add` with a pattern will return an integer index of
160
+ the pattern. After all patterns have been added, the set can be compiled using
161
+ `RE2::Set#compile`, and then `RE2::Set#match` will return an `Array<Integer>`
162
+ containing the indices of all the patterns that matched.
163
+
164
+ ```ruby
165
+ set = RE2::Set.new
166
+ set.add("abc") #=> 0
167
+ set.add("def") #=> 1
168
+ set.add("ghi") #=> 2
169
+ set.compile #=> true
170
+ set.match("abcdefghi") #=> [0, 1, 2]
171
+ set.match("ghidefabc") #=> [2, 1, 0]
172
+ ```
173
+
174
+ 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:
175
+
176
+ ```ruby
177
+ case RE2('(\w+) (\d+)').match("Alice 42")
178
+ in [name, age]
179
+ puts "My name is #{name} and I am #{age} years old"
180
+ else
181
+ puts "No match!"
182
+ end
183
+ # My name is Alice and I am 42 years old
184
+
185
+
186
+ case RE2('(?P<name>\w+) (?P<age>\d+)').match("Alice 42")
187
+ in {name:, age:}
188
+ puts "My name is #{name} and I am #{age} years old"
189
+ else
190
+ puts "No match!"
191
+ end
192
+ # My name is Alice and I am 42 years old
193
+ ```
194
+
195
+ Features
196
+ --------
197
+
198
+ * Pre-compiling regular expressions with
199
+ [`RE2::Regexp.new(re)`](https://github.com/google/re2/blob/2016-02-01/re2/re2.h#L100),
200
+ `RE2::Regexp.compile(re)` or `RE2(re)` (including specifying options, e.g.
201
+ `RE2::Regexp.new("pattern", :case_sensitive => false)`
202
+
203
+ * Extracting matches with `re2.match(text)` (and an exact number of matches
204
+ with `re2.match(text, number_of_matches)` such as `re2.match("123-234", 2)`)
205
+
206
+ * Extracting matches by name (both with strings and symbols)
207
+
208
+ * Checking for matches with `re2 =~ text`, `re2 === text` (for use in `case`
209
+ statements) and `re2 !~ text`
210
+
211
+ * Incrementally scanning text with `re2.scan(text)`
212
+
213
+ * Search a collection of patterns simultaneously with `RE2::Set`
214
+
215
+ * Checking regular expression compilation with `re2.ok?`, `re2.error` and
216
+ `re2.error_arg`
217
+
218
+ * Checking regular expression "cost" with `re2.program_size`
219
+
220
+ * Checking the options for an expression with `re2.options` or individually
221
+ with `re2.case_sensitive?`
222
+
223
+ * Performing a single string replacement with `pattern.replace(replacement,
224
+ original)`
225
+
226
+ * Performing a global string replacement with
227
+ `pattern.replace_all(replacement, original)`
228
+
229
+ * Escaping regular expressions with
230
+ [`RE2.escape(unquoted)`](https://github.com/google/re2/blob/2016-02-01/re2/re2.h#L418) and
231
+ `RE2.quote(unquoted)`
232
+
233
+ * Pattern matching with `RE2::MatchData`
234
+
235
+ Contributions
236
+ -------------
237
+
238
+ * Thanks to [Jason Woods](https://github.com/driskell) who contributed the
239
+ original implementations of `RE2::MatchData#begin` and `RE2::MatchData#end`;
240
+ * Thanks to [Stefano Rivera](https://github.com/stefanor) who first contributed C++11 support;
241
+ * Thanks to [Stan Hu](https://github.com/stanhu) for reporting a bug with empty patterns and `RE2::Regexp#scan`, contributing support for libre2.11 (2023-07-01) and for vendoring re2 and abseil and compiling native gems in 2.0;
242
+ * Thanks to [Sebastian Reitenbach](https://github.com/buzzdeee) for reporting
243
+ the deprecation and removal of the `utf8` encoding option in re2;
244
+ * Thanks to [Sergio Medina](https://github.com/serch) for reporting a bug when
245
+ using `RE2::Scanner#scan` with an invalid regular expression;
246
+ * Thanks to [Pritam Baral](https://github.com/pritambaral) for contributed the
247
+ initial support for `RE2::Set`.
248
+
249
+ Contact
250
+ -------
251
+
252
+ All issues and suggestions should go to [GitHub Issues](https://github.com/mudge/re2/issues).
253
+
254
+ [re2]: https://github.com/google/re2
255
+ [gcc]: http://gcc.gnu.org/
256
+ [ruby-dev]: http://packages.debian.org/ruby-dev
257
+ [build-essential]: http://packages.debian.org/build-essential
258
+ [Regexp]: http://ruby-doc.org/core/classes/Regexp.html
259
+ [MatchData]: http://ruby-doc.org/core/classes/MatchData.html
260
+ [Homebrew]: http://mxcl.github.com/homebrew
261
+ [libre2-dev]: http://packages.debian.org/search?keywords=libre2-dev
262
+ [official syntax page]: https://github.com/google/re2/wiki/Syntax
263
+
data/Rakefile ADDED
@@ -0,0 +1,132 @@
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 2.6.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
+ task default: [:compile, :spec]
data/dependencies.yml ADDED
@@ -0,0 +1,9 @@
1
+ libre2:
2
+ version: "2023-09-01"
3
+ sha256: "5bb6875ae1cd1e9fedde98018c346db7260655f86fdb8837e3075103acd3649b"
4
+ # sha-256 hash provided in https://github.com/google/re2/releases/download/2023-09-01/re2-2023-09-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