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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '039084596a2999534c4e78c9c3fc008ddcf0712a573c93234f4191d9b8e6fd3d'
4
- data.tar.gz: 8f2629a2a40c5a82c26f73ce9826954bf8de24ab879757c7e672808a3b1edf26
3
+ metadata.gz: 631f8758ae432269424c547c8ea613ed475fc95d589f8d77eda6a9157a303297
4
+ data.tar.gz: a7c2d5cf6328d43d2bb73692adfefcac19d1ffbdf22e7a91b3b053d02a53a195
5
5
  SHA512:
6
- metadata.gz: 415c361fe5761dfcb68d734c970e120189cd2f7770dc8997af51e4572c42ba17f72fa1d04465d3b67d9f191ffc58054b8bff98498a42ff41ad25145ecad0eed1
7
- data.tar.gz: 2a011e1aa4c1b1c45107fbe93ed9dffe1e5d94e61bfb429e57daa58feeeabf8dca954d85c041dee7cdb5844e5cd7df1b39be1f696fa419e2c65477036cb2a950
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Fast
4
4
  class Regexp
5
- VERSION = "0.6.0"
5
+ VERSION = "0.6.2"
6
6
  end
7
7
  end
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
- # Load the native extension AFTER the Fast::Regexp class shell exists — the
17
- # Rust init() looks up Fast::Regexp and registers Native under it.
18
- require_relative "fast_regexp/fast_regexp"
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 symbol-keyed hash of patterns. Handy for defining a set
38
- # of regex constants in one shot:
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
- # RE = Fast::Regexp.create_many(word: '\w+', num: '\d+').freeze
41
- # RE[:word].match("hello")
42
- def create_many(**patterns)
43
- patterns.transform_values { |pat| new(pat) }
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_regexp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.2
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Eric Jacobs