fast_regexp 0.6.0-aarch64-linux → 0.6.2-aarch64-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/README.md +8 -2
- data/lib/fast_regexp/version.rb +1 -1
- data/lib/fast_regexp.rb +28 -9
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 631f8758ae432269424c547c8ea613ed475fc95d589f8d77eda6a9157a303297
|
|
4
|
+
data.tar.gz: a7c2d5cf6328d43d2bb73692adfefcac19d1ffbdf22e7a91b3b053d02a53a195
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4c9ce826241c325c128c72be6da2f4d3d5a3eb4a67f09b973bc752a2a1b1fdf6de8ee1515a89af5326df90a2726de2cd341dd888815ae1db34be73e6393ddd9b
|
|
7
|
+
data.tar.gz: 7cc23ef4cdde598acf331187818e639ca846ecc8294958248d822d8fbd3f731d9da7a6021017b13b136660f982fc770201475d0e67a9755912a74a622e996016
|
data/README.md
CHANGED
|
@@ -9,8 +9,6 @@ You get rust/regex's speed on the common path, and a single uniform API (`Fast::
|
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
12
|
-
Install [Rust](https://www.rust-lang.org/) via [rustup](https://rustup.rs/) or in any other way.
|
|
13
|
-
|
|
14
12
|
Add as a dependency:
|
|
15
13
|
|
|
16
14
|
```ruby
|
|
@@ -21,6 +19,14 @@ gem "fast_regexp"
|
|
|
21
19
|
gem install fast_regexp
|
|
22
20
|
```
|
|
23
21
|
|
|
22
|
+
Precompiled native gems are published for **arm64-darwin**, **x86_64-linux**,
|
|
23
|
+
and **aarch64-linux** against Ruby **3.3**, **3.4**, and **4.0** — no Rust
|
|
24
|
+
toolchain required on those platforms.
|
|
25
|
+
|
|
26
|
+
On any other platform/Ruby combo, Bundler/RubyGems falls back to the source
|
|
27
|
+
gem and compiles the extension at install time. That path needs
|
|
28
|
+
[Rust](https://www.rust-lang.org/) (install via [rustup](https://rustup.rs/)).
|
|
29
|
+
|
|
24
30
|
Include in your code:
|
|
25
31
|
|
|
26
32
|
```ruby
|
data/lib/fast_regexp/version.rb
CHANGED
data/lib/fast_regexp.rb
CHANGED
|
@@ -10,12 +10,23 @@ module Fast
|
|
|
10
10
|
# (lookaround, backreferences, possessive quantifiers, etc.) we fall back
|
|
11
11
|
# to `::Regexp` so consumers don't have to juggle two libraries.
|
|
12
12
|
class Regexp
|
|
13
|
+
NATIVE_EXTENSIONS = %w[.bundle .so .rb].freeze
|
|
14
|
+
|
|
15
|
+
# Precompiled native gems ship per-ABI subdirs (`fast_regexp/4.0/...`),
|
|
16
|
+
# the source-gem `rake compile` build lands flat (`fast_regexp/...`).
|
|
17
|
+
# Pick whichever exists for the current Ruby ABI, with the per-ABI path
|
|
18
|
+
# winning when both are present.
|
|
19
|
+
def self.locate_native(base, ruby_version: RUBY_VERSION)
|
|
20
|
+
abi = ruby_version[/\d+\.\d+/]
|
|
21
|
+
candidates = [File.join(base, abi, "fast_regexp"), File.join(base, "fast_regexp")]
|
|
22
|
+
candidates.find { |stem| NATIVE_EXTENSIONS.any? { |ext| File.exist?(stem + ext) } }
|
|
23
|
+
end
|
|
13
24
|
end
|
|
14
25
|
end
|
|
15
26
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
27
|
+
native = Fast::Regexp.locate_native(File.expand_path("fast_regexp", __dir__))
|
|
28
|
+
raise LoadError, "could not locate fast_regexp native extension" unless native
|
|
29
|
+
require native
|
|
19
30
|
|
|
20
31
|
module Fast
|
|
21
32
|
class Regexp
|
|
@@ -34,13 +45,21 @@ module Fast
|
|
|
34
45
|
allocate.tap { |re| re.send(:initialize, translated, original: pattern, **opts) }
|
|
35
46
|
end
|
|
36
47
|
|
|
37
|
-
# Bulk-compile a
|
|
38
|
-
#
|
|
48
|
+
# Bulk-compile a set of patterns. Two call shapes:
|
|
49
|
+
#
|
|
50
|
+
# Fast::Regexp.create_many(word: '\w+', num: '\d+')
|
|
51
|
+
# # => { word: #<Fast::Regexp ...>, num: #<Fast::Regexp ...> }
|
|
39
52
|
#
|
|
40
|
-
#
|
|
41
|
-
#
|
|
42
|
-
|
|
43
|
-
|
|
53
|
+
# Fast::Regexp.create_many('\w+', '\d+')
|
|
54
|
+
# # => [#<Fast::Regexp ...>, #<Fast::Regexp ...>]
|
|
55
|
+
#
|
|
56
|
+
# Mixing the two raises ArgumentError — pick one shape per call.
|
|
57
|
+
def create_many(*patterns, **named)
|
|
58
|
+
if !patterns.empty? && !named.empty?
|
|
59
|
+
raise ArgumentError, "create_many accepts positional patterns OR keyword patterns, not both"
|
|
60
|
+
end
|
|
61
|
+
return named.transform_values { |pat| new(pat) } if patterns.empty?
|
|
62
|
+
patterns.map { |pat| new(pat) }
|
|
44
63
|
end
|
|
45
64
|
|
|
46
65
|
private
|