multi_string_replace 1.0.7 → 2.0.0
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/Gemfile.lock +1 -1
- data/README.md +3 -3
- data/ext/multi_string_replace/ahocorasick.c +3 -1
- data/lib/multi_string_replace/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 475f85424faff8b9059d92aa706fd613f62947684f583b3ecfe893aeac995c90
|
4
|
+
data.tar.gz: 771f516436986b6a75d94ab7d68037742cabc346c4c9c9673610af80df00971b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2e795cc477087170a4f68f0a0d8da58040eee092af9d24b16421580b79e4362f2cf52749dd88cf738bf1f59cee40f733d8413c92b94d6d44f2447633ce1522e
|
7
|
+
data.tar.gz: 231caecb64e33c2e15b9ce48a0557bd2aa261657de9e4b9a34d9a552c66ec779a75bdab62e7b0e541c092be7a1dcf52331df4736fce12d8b85b37940da0830d6
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -36,16 +36,16 @@ MultiStringReplace.replace("The quick brown fox jumps over the lazy dog brown",
|
|
36
36
|
# The quick black wolf jumps over the lazy dog black
|
37
37
|
```
|
38
38
|
|
39
|
-
You can also pass in a Proc, these will only get evaluated when the token is encountered.
|
39
|
+
You can also pass in a Proc, these will only get evaluated when the token is encountered. The start and end replace position will passed to the proc.
|
40
40
|
|
41
41
|
```ruby
|
42
|
-
MultiStringReplace.replace("The quick brown fox jumps over the lazy dog brown", {'brown' => 'black', 'fox' => ->() { "cat" }})
|
42
|
+
MultiStringReplace.replace("The quick brown fox jumps over the lazy dog brown", {'brown' => 'black', 'fox' => ->(s, e) { "cat" }})
|
43
43
|
```
|
44
44
|
|
45
45
|
Also adds a mreplace method to String which does the same thing:
|
46
46
|
|
47
47
|
```ruby
|
48
|
-
"The quick brown fox jumps over the lazy dog brown".mreplace({'brown' => 'black', 'fox' => ->() { "cat" }})
|
48
|
+
"The quick brown fox jumps over the lazy dog brown".mreplace({'brown' => 'black', 'fox' => ->(_, _) { "cat" }})
|
49
49
|
```
|
50
50
|
|
51
51
|
## Performance
|
@@ -217,10 +217,12 @@ VALUE aho_replace_text(struct ahocorasick * restrict aho, const char* data,
|
|
217
217
|
if (pos > last_concat_pos) {
|
218
218
|
rb_str_cat(main_result, &data[last_concat_pos], pos - last_concat_pos);
|
219
219
|
}
|
220
|
+
|
221
|
+
|
220
222
|
|
221
223
|
// concatenate replace
|
222
224
|
if (values[result->id] == NULL) {
|
223
|
-
VALUE proc_result = rb_funcall(ruby_values[result->id], rb_intern("call"),
|
225
|
+
VALUE proc_result = rb_funcall(ruby_values[result->id], rb_intern("call"), 2, LONG2NUM(pos), LONG2NUM(pos + result->len));
|
224
226
|
value_sizes[result->id] = RSTRING_LEN(proc_result);
|
225
227
|
values[result->id] = StringValuePtr(proc_result);
|
226
228
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multi_string_replace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joseph Dayo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|