re2 2.15.0.rc1-x86-linux-gnu

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.
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ # re2 (https://github.com/mudge/re2)
4
+ # Ruby bindings to RE2, a "fast, safe, thread-friendly alternative to
5
+ # backtracking regular expression engines like those used in PCRE, Perl, and
6
+ # Python".
7
+ #
8
+ # Copyright (c) 2010, Paul Mucur (https://mudge.name)
9
+ # Released under the BSD Licence, please see LICENSE.txt
10
+
11
+ PACKAGE_ROOT_DIR = File.expand_path('../..', __dir__)
12
+ REQUIRED_MINI_PORTILE_VERSION = '~> 2.8.7' # keep this version in sync with the one in the gemspec
13
+
14
+ def load_recipes
15
+ require 'yaml'
16
+ dependencies = YAML.load_file(File.join(PACKAGE_ROOT_DIR, 'dependencies.yml'))
17
+
18
+ abseil_recipe = build_recipe('abseil', dependencies['abseil']['version']) do |recipe|
19
+ recipe.files = [{
20
+ url: "https://github.com/abseil/abseil-cpp/archive/refs/tags/#{recipe.version}.tar.gz",
21
+ sha256: dependencies['abseil']['sha256']
22
+ }]
23
+ end
24
+
25
+ re2_recipe = build_recipe('libre2', dependencies['libre2']['version']) do |recipe|
26
+ recipe.files = [{
27
+ url: "https://github.com/google/re2/releases/download/#{recipe.version}/re2-#{recipe.version}.tar.gz",
28
+ sha256: dependencies['libre2']['sha256']
29
+ }]
30
+ end
31
+
32
+ [abseil_recipe, re2_recipe]
33
+ end
34
+
35
+ def build_recipe(name, version)
36
+ require 'rubygems'
37
+ gem('mini_portile2', REQUIRED_MINI_PORTILE_VERSION) # gemspec is not respected at install time
38
+ require 'mini_portile2'
39
+
40
+ MiniPortileCMake.new(name, version).tap do |recipe|
41
+ recipe.target = File.join(PACKAGE_ROOT_DIR, 'ports')
42
+ recipe.configure_options += [
43
+ # abseil needs a C++14 compiler
44
+ '-DCMAKE_CXX_STANDARD=14',
45
+ # needed for building the C extension shared library with -fPIC
46
+ '-DCMAKE_POSITION_INDEPENDENT_CODE=ON',
47
+ # ensures pkg-config and installed libraries will be in lib, not lib64
48
+ '-DCMAKE_INSTALL_LIBDIR=lib',
49
+ '-DCMAKE_CXX_VISIBILITY_PRESET=hidden'
50
+ ]
51
+
52
+ yield recipe
53
+ end
54
+ end
data/lib/3.1/re2.so ADDED
Binary file
data/lib/3.2/re2.so ADDED
Binary file
data/lib/3.3/re2.so ADDED
Binary file
data/lib/3.4/re2.so ADDED
Binary file
data/lib/re2/regexp.rb ADDED
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ # re2 (https://github.com/mudge/re2)
4
+ # Ruby bindings to RE2, a "fast, safe, thread-friendly alternative to
5
+ # backtracking regular expression engines like those used in PCRE, Perl, and
6
+ # Python".
7
+ #
8
+ # Copyright (c) 2010, Paul Mucur (https://mudge.name)
9
+ # Released under the BSD Licence, please see LICENSE.txt
10
+
11
+
12
+ module RE2
13
+ class Regexp
14
+ # Match the pattern against any substring of the given `text` and return a
15
+ # {RE2::MatchData} instance with the specified number of submatches
16
+ # (defaults to the total number of capturing groups) or a boolean (if no
17
+ # submatches are required).
18
+ #
19
+ # The number of submatches has a significant impact on performance: requesting
20
+ # one submatch is much faster than requesting more than one and requesting
21
+ # zero submatches is faster still.
22
+ #
23
+ # @param [String] text the text to search
24
+ # @param [Hash] options the options with which to perform the match
25
+ # @option options [Integer] :submatches how many submatches to extract (0
26
+ # is fastest), defaults to the total number of capturing groups
27
+ # @return [RE2::MatchData, nil] if extracting any submatches
28
+ # @return [Boolean] if not extracting any submatches
29
+ # @raise [ArgumentError] if given a negative number of submatches
30
+ # @raise [NoMemoryError] if there was not enough memory to allocate the
31
+ # matches
32
+ # @raise [TypeError] if given non-numeric submatches or non-hash options
33
+ # @example
34
+ # r = RE2::Regexp.new('w(o)(o)')
35
+ # r.partial_match('woot') #=> #<RE2::MatchData "woo" 1:"o" 2:"o">
36
+ # r.partial_match('nope') #=> nil
37
+ # r.partial_match('woot', submatches: 1) #=> #<RE2::MatchData "woo" 1:"o">
38
+ # r.partial_match('woot', submatches: 0) #=> true
39
+ def partial_match(text, options = {})
40
+ match(text, Hash(options).merge(anchor: :unanchored))
41
+ end
42
+
43
+ # Match the pattern against the given `text` exactly and return a
44
+ # {RE2::MatchData} instance with the specified number of submatches
45
+ # (defaults to the total number of capturing groups) or a boolean (if no
46
+ # submatches are required).
47
+ #
48
+ # The number of submatches has a significant impact on performance: requesting
49
+ # one submatch is much faster than requesting more than one and requesting
50
+ # zero submatches is faster still.
51
+ #
52
+ # @param [String] text the text to search
53
+ # @param [Hash] options the options with which to perform the match
54
+ # @option options [Integer] :submatches how many submatches to extract (0
55
+ # is fastest), defaults to the total number of capturing groups
56
+ # @return [RE2::MatchData, nil] if extracting any submatches
57
+ # @return [Boolean] if not extracting any submatches
58
+ # @raise [ArgumentError] if given a negative number of submatches
59
+ # @raise [NoMemoryError] if there was not enough memory to allocate the
60
+ # matches
61
+ # @raise [TypeError] if given non-numeric submatches or non-hash options
62
+ # @example
63
+ # r = RE2::Regexp.new('w(o)(o)')
64
+ # r.full_match('woo') #=> #<RE2::MatchData "woo" 1:"o" 2:"o">
65
+ # r.full_match('woot') #=> nil
66
+ # r.full_match('woo', submatches: 1) #=> #<RE2::MatchData "woo" 1:"o">
67
+ # r.full_match('woo', submatches: 0) #=> true
68
+ def full_match(text, options = {})
69
+ match(text, Hash(options).merge(anchor: :anchor_both))
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ # re2 (https://github.com/mudge/re2)
4
+ # Ruby bindings to RE2, a "fast, safe, thread-friendly alternative to
5
+ # backtracking regular expression engines like those used in PCRE, Perl, and
6
+ # Python".
7
+ #
8
+ # Copyright (c) 2010, Paul Mucur (https://mudge.name)
9
+ # Released under the BSD Licence, please see LICENSE.txt
10
+
11
+
12
+ module RE2
13
+ class Scanner
14
+ include Enumerable
15
+
16
+ def each
17
+ if block_given?
18
+ while matches = scan
19
+ yield matches
20
+ end
21
+ else
22
+ to_enum(:each)
23
+ end
24
+ end
25
+ end
26
+ end
data/lib/re2/string.rb ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ # re2 (https://github.com/mudge/re2)
4
+ # Ruby bindings to RE2, a "fast, safe, thread-friendly alternative to
5
+ # backtracking regular expression engines like those used in PCRE, Perl, and
6
+ # Python".
7
+ #
8
+ # Copyright (c) 2010, Paul Mucur (https://mudge.name)
9
+ # Released under the BSD Licence, please see LICENSE.txt
10
+
11
+ require "re2"
12
+
13
+ module RE2
14
+ # @deprecated Use methods on {RE2} and {RE2::Regexp} instead.
15
+ module String
16
+ # @deprecated Use {RE2.Replace} instead.
17
+ def re2_sub(*args)
18
+ RE2.Replace(self, *args)
19
+ end
20
+
21
+ # @deprecated Use {RE2.GlobalReplace} instead.
22
+ def re2_gsub(*args)
23
+ RE2.GlobalReplace(self, *args)
24
+ end
25
+
26
+ # @deprecated Use {RE2::Regexp#match} instead.
27
+ def re2_match(pattern, *args)
28
+ RE2::Regexp.new(pattern).match(self, *args)
29
+ end
30
+
31
+ # @deprecated Use {RE2.QuoteMeta} instead.
32
+ def re2_escape
33
+ RE2.QuoteMeta(self)
34
+ end
35
+
36
+ alias_method :re2_quote, :re2_escape
37
+ end
38
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ # re2 (https://github.com/mudge/re2)
4
+ # Ruby bindings to RE2, a "fast, safe, thread-friendly alternative to
5
+ # backtracking regular expression engines like those used in PCRE, Perl, and
6
+ # Python".
7
+ #
8
+ # Copyright (c) 2010, Paul Mucur (https://mudge.name)
9
+ # Released under the BSD Licence, please see LICENSE.txt
10
+
11
+
12
+ module RE2
13
+ VERSION = "2.15.0.rc1"
14
+ end
data/lib/re2.rb ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # re2 (https://github.com/mudge/re2)
4
+ # Ruby bindings to RE2, a "fast, safe, thread-friendly alternative to
5
+ # backtracking regular expression engines like those used in PCRE, Perl, and
6
+ # Python".
7
+ #
8
+ # Copyright (c) 2010, Paul Mucur (https://mudge.name)
9
+ # Released under the BSD Licence, please see LICENSE.txt
10
+
11
+ begin
12
+ ::RUBY_VERSION =~ /(\d+\.\d+)/
13
+ require_relative "#{Regexp.last_match(1)}/re2.so"
14
+ rescue LoadError
15
+ require 're2.so'
16
+ end
17
+
18
+ require "re2/regexp"
19
+ require "re2/scanner"
20
+ require "re2/version"
data/re2.gemspec ADDED
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/re2/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "re2"
7
+ s.summary = "Ruby bindings to RE2."
8
+ s.description = 'Ruby bindings to RE2, "a fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python".'
9
+ s.version = RE2::VERSION
10
+ s.authors = ["Paul Mucur", "Stan Hu"]
11
+ s.homepage = "https://github.com/mudge/re2"
12
+ s.extensions = ["ext/re2/extconf.rb"]
13
+ s.license = "BSD-3-Clause"
14
+ s.required_ruby_version = ">= 3.1.0"
15
+ s.files = [
16
+ "dependencies.yml",
17
+ "ext/re2/extconf.rb",
18
+ "ext/re2/re2.cc",
19
+ "ext/re2/recipes.rb",
20
+ "Gemfile",
21
+ "lib/re2.rb",
22
+ "lib/re2/regexp.rb",
23
+ "lib/re2/scanner.rb",
24
+ "lib/re2/string.rb",
25
+ "lib/re2/version.rb",
26
+ "LICENSE.txt",
27
+ "LICENSE-DEPENDENCIES.txt",
28
+ "README.md",
29
+ "Rakefile",
30
+ "re2.gemspec"
31
+ ]
32
+ s.test_files = [
33
+ ".rspec",
34
+ "spec/spec_helper.rb",
35
+ "spec/re2_spec.rb",
36
+ "spec/kernel_spec.rb",
37
+ "spec/re2/regexp_spec.rb",
38
+ "spec/re2/match_data_spec.rb",
39
+ "spec/re2/string_spec.rb",
40
+ "spec/re2/set_spec.rb",
41
+ "spec/re2/scanner_spec.rb"
42
+ ]
43
+ s.add_development_dependency("rake-compiler", "~> 1.2.7")
44
+ s.add_development_dependency("rake-compiler-dock", "~> 1.7.0.rc1")
45
+ s.add_development_dependency("rspec", "~> 3.2")
46
+ s.add_runtime_dependency("mini_portile2", "~> 2.8.7") # keep version in sync with extconf.rb
47
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe Kernel do
4
+ describe ".RE2" do
5
+ it "returns an RE2::Regexp instance given a pattern" do
6
+ expect(RE2('w(o)(o)')).to be_a(RE2::Regexp)
7
+ end
8
+
9
+ it "returns an RE2::Regexp instance given a pattern and options" do
10
+ re = RE2('w(o)(o)', case_sensitive: false)
11
+
12
+ expect(re).not_to be_case_sensitive
13
+ end
14
+
15
+ it "accepts patterns containing null bytes" do
16
+ re = RE2("a\0b")
17
+
18
+ expect(re.pattern).to eq("a\0b")
19
+ end
20
+
21
+ it "raises an error if given an inappropriate type" do
22
+ expect { RE2(nil) }.to raise_error(TypeError)
23
+ end
24
+
25
+ it "allows invalid patterns to be created" do
26
+ re = RE2('???', log_errors: false)
27
+
28
+ expect(re).to be_a(RE2::Regexp)
29
+ end
30
+
31
+ it "supports passing something that can be coerced to a String as input" do
32
+ re = RE2(StringLike.new('w(o)(o)'))
33
+
34
+ expect(re).to be_a(RE2::Regexp)
35
+ end
36
+ end
37
+ end