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 +4 -4
- data/README.md +17 -1
- data/ext/tre_regex/extconf.rb +0 -1
- data/lib/tre_regex/version.rb +1 -1
- data/lib/tre_regex.rb +14 -7
- data/tre_regex.gemspec +2 -2
- metadata +3 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fe30d3e934e629a133ca2c1da201ba0f5354aeee2b0afac3bfb9ecbbe25ede79
|
|
4
|
+
data.tar.gz: c45c97a59f0f78e2eadd0ddf085062a5934a97681d38a79976957a922cf97a5b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e4577e12d44759f51b761b92e0aeb4225fed15d867cc2758354925906a64256a30607b13bf86378307b2b2402070fa9d6b3c2951b8acc50425fc42340e5231bd
|
|
7
|
+
data.tar.gz: 32c418ea77b6c926d613dd0f95e48c268ec02706a99331b8b4440d90abe4b8fc50914874e6ed5439cf81bb5fdf5e5844a5bb89808c8f776fb2d1e7e006bd5f90
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# TreRegex [](https://github.com/le0pard/tre_regex/actions/workflows/main.yml)
|
|
2
2
|
|
|
3
|
-
`TreRegex`
|
|
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).
|
data/ext/tre_regex/extconf.rb
CHANGED
data/lib/tre_regex/version.rb
CHANGED
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
|
-
|
|
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(
|
|
104
|
+
def self.finalize(preg)
|
|
100
105
|
proc do
|
|
101
|
-
|
|
102
|
-
|
|
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
|
|
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.
|
|
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
|
|
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: []
|