tre_regex 0.2.0-x86_64-linux-gnu → 0.2.1-x86_64-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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 636dcee7d14a052114c9b609df771d172675bcc8820f3905d2915e660e2b159c
4
- data.tar.gz: 41a2a77f6250951e0f23479715e83e51d10b786120f4bbe62144bffb3efc8c82
3
+ metadata.gz: fe30d3e934e629a133ca2c1da201ba0f5354aeee2b0afac3bfb9ecbbe25ede79
4
+ data.tar.gz: c45c97a59f0f78e2eadd0ddf085062a5934a97681d38a79976957a922cf97a5b
5
5
  SHA512:
6
- metadata.gz: 3a96a64be828e120c60489a728fdded4c7d5bb191cb53415b4521b3f579aa80d5169e11f50c801cfb9bdc1b48dfc5332e47f9c709fa0b564f0fe91d465dcd899
7
- data.tar.gz: edc5b78363235c215f8ef95eea826071edec72ff79aef96b1c3d11e0943d983384d2569310a3dda391bc0b968d25f31754ab89edefe5d0cb92a1f3642beb13cd
6
+ metadata.gz: e4577e12d44759f51b761b92e0aeb4225fed15d867cc2758354925906a64256a30607b13bf86378307b2b2402070fa9d6b3c2951b8acc50425fc42340e5231bd
7
+ data.tar.gz: 32c418ea77b6c926d613dd0f95e48c268ec02706a99331b8b4440d90abe4b8fc50914874e6ed5439cf81bb5fdf5e5844a5bb89808c8f776fb2d1e7e006bd5f90
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # TreRegex [![Ruby Checks](https://github.com/le0pard/tre_regex/actions/workflows/main.yml/badge.svg)](https://github.com/le0pard/tre_regex/actions/workflows/main.yml)
2
2
 
3
- `TreRegex` is a robust Ruby gem that provides a high-performance interface to the [TRE](https://github.com/laurikari/tre) approximate regex matching library. Powered by FFI, it allows you to perform lightning-fast fuzzy string searching while safely handling Ruby's Unicode characters.
3
+ `TreRegex` provides a high-performance Ruby interface to the [TRE](https://github.com/laurikari/tre) C library using FFI. It brings robust approximate (fuzzy) regular expression matching to Ruby, featuring multi-byte Unicode string safety, and granular error limits
4
4
 
5
5
  ## Why?
6
6
 
@@ -316,6 +316,22 @@ If you need to find overlapping fuzzy matches, you will need to manually step th
316
316
 
317
317
  ## Development
318
318
 
319
+ Because `TreRegex` compiles the underlying TRE C-library from source, you must have standard C-compilation and `autotools` dependencies installed on your machine before running the setup script
320
+
321
+ **Ubuntu / Debian Linux**
322
+
323
+ ```bash
324
+ sudo apt-get update
325
+ sudo apt-get install build-essential autoconf automake libtool gettext autopoint pkg-config
326
+ ```
327
+
328
+ **macOS**
329
+
330
+ Then, install the autotools suite via [Homebrew](https://brew.sh/):
331
+ ```bash
332
+ brew install autoconf automake libtool gettext pkg-config
333
+ ```
334
+
319
335
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
320
336
 
321
337
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
@@ -2,7 +2,6 @@
2
2
 
3
3
  require 'mkmf'
4
4
  require 'rbconfig'
5
- require 'open-uri'
6
5
  require 'net/http'
7
6
  require 'fileutils'
8
7
  require 'digest'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TreRegex
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
data/lib/tre_regex.rb CHANGED
@@ -42,6 +42,12 @@ module TreRegex
42
42
  REG_NEWLINE = 4
43
43
  REG_NOSUB = 8
44
44
 
45
+ # TRE's regex_t struct
46
+ class RegexT < FFI::Struct
47
+ layout :re_nsub, :size_t,
48
+ :value, :pointer
49
+ end
50
+
45
51
  # Memory layout for TRE match offsets
46
52
  class RegMatch < FFI::Struct
47
53
  layout :rm_so, :int,
@@ -82,13 +88,12 @@ module TreRegex
82
88
 
83
89
  def initialize(pattern, ignore_case: false)
84
90
  @pattern = pattern
85
- # Allocate a safe 256-byte buffer in C memory for the regex_t struc
86
- @preg = FFI::MemoryPointer.new(:char, 256)
91
+ @preg = Native::RegexT.new
87
92
 
88
93
  flags = Native::REG_EXTENDED
89
94
  flags |= Native::REG_ICASE if ignore_case
90
95
 
91
- res = Native.tre_regcomp(@preg, pattern, flags)
96
+ res = Native.tre_regcomp(@preg.to_ptr, pattern, flags)
92
97
  raise TreRegex::Error, "Failed to compile regex pattern: #{pattern}" if res != 0
93
98
 
94
99
  # Garbage Collection Hook: Tell Ruby to free the C memory when this object is destroyed
@@ -96,10 +101,12 @@ module TreRegex
96
101
  end
97
102
 
98
103
  # The GC finalizer proc
99
- def self.finalize(preg_ptr)
104
+ def self.finalize(preg)
100
105
  proc do
101
- Native.tre_regfree(preg_ptr)
102
- preg_ptr.free
106
+ # Free the internal arrays allocated by TRE
107
+ Native.tre_regfree(preg.to_ptr)
108
+ # Safely free the struct memory ourselves
109
+ preg.to_ptr.free
103
110
  end
104
111
  end
105
112
 
@@ -149,7 +156,7 @@ module TreRegex
149
156
  pmatch_array = FFI::MemoryPointer.new(Native::RegMatch, MAX_NMATCH)
150
157
  match_data = prepare_match_data(pmatch_array, MAX_NMATCH)
151
158
 
152
- res = Native.tre_reganexec(@preg, text_ptr, len, match_data, params, 0)
159
+ res = Native.tre_reganexec(@preg.to_ptr, text_ptr, len, match_data, params, 0)
153
160
  return nil unless res.zero?
154
161
 
155
162
  # Return the entire array pointer to be parsed
data/tre_regex.gemspec CHANGED
@@ -9,11 +9,11 @@ Gem::Specification.new do |spec|
9
9
  spec.email = ['leopard.not.a@gmail.com']
10
10
  spec.license = 'MIT'
11
11
 
12
- spec.summary = 'A fast Ruby FFI wrapper for the TRE approximate regex matching library.'
12
+ spec.summary = 'A fast Ruby FFI wrapper for the TRE approximate regex matching library'
13
13
  spec.description = [
14
14
  'TreRegex provides a high-performance Ruby interface to the TRE C library using FFI.',
15
15
  'It brings robust approximate (fuzzy) regular expression matching to Ruby, featuring',
16
- 'multi-byte Unicode string safety, granular error limits, and precompiled cross-platform native binaries'
16
+ 'multi-byte Unicode string safety, and granular error limits'
17
17
  ].join(' ')
18
18
  spec.homepage = 'https://github.com/le0pard/tre_regex'
19
19
  spec.required_ruby_version = '>= 3.3.0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tre_regex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: x86_64-linux-gnu
6
6
  authors:
7
7
  - Oleksii Vasyliev
@@ -25,8 +25,7 @@ dependencies:
25
25
  version: '1.0'
26
26
  description: TreRegex provides a high-performance Ruby interface to the TRE C library
27
27
  using FFI. It brings robust approximate (fuzzy) regular expression matching to Ruby,
28
- featuring multi-byte Unicode string safety, granular error limits, and precompiled
29
- cross-platform native binaries
28
+ featuring multi-byte Unicode string safety, and granular error limits
30
29
  email:
31
30
  - leopard.not.a@gmail.com
32
31
  executables: []
@@ -73,5 +72,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
72
  requirements: []
74
73
  rubygems_version: 4.0.6
75
74
  specification_version: 4
76
- summary: A fast Ruby FFI wrapper for the TRE approximate regex matching library.
75
+ summary: A fast Ruby FFI wrapper for the TRE approximate regex matching library
77
76
  test_files: []