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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1a53ef0a40acd23f625842f8ce1335b69e28b4334896ef50989c09936f4601b
4
- data.tar.gz: 64880e395d26638853ab4501d76f9c882628410df8a1a41bea533249b8d0b447
3
+ metadata.gz: 475f85424faff8b9059d92aa706fd613f62947684f583b3ecfe893aeac995c90
4
+ data.tar.gz: 771f516436986b6a75d94ab7d68037742cabc346c4c9c9673610af80df00971b
5
5
  SHA512:
6
- metadata.gz: 2b3f3479e79dbca29630549b6895c714069d6baa134e184a8f87488203b4aac551b5b2e8759de5dfd4bd9b30d4abc5d5a8c8cb9fd56742801361f504c9d21829
7
- data.tar.gz: e88071ce970e38300297472214eb73bb368308e924bb57ee80488228ac57eb820348d3e573566ca7fb4148083434e1071d96e53725307a50e0b9f21041f61c25
6
+ metadata.gz: d2e795cc477087170a4f68f0a0d8da58040eee092af9d24b16421580b79e4362f2cf52749dd88cf738bf1f59cee40f733d8413c92b94d6d44f2447633ce1522e
7
+ data.tar.gz: 231caecb64e33c2e15b9ce48a0557bd2aa261657de9e4b9a34d9a552c66ec779a75bdab62e7b0e541c092be7a1dcf52331df4736fce12d8b85b37940da0830d6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- multi_string_replace (1.0.6)
4
+ multi_string_replace (2.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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"), 0);
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
  }
@@ -1,3 +1,3 @@
1
1
  module MultiStringReplace
2
- VERSION = "1.0.7"
2
+ VERSION = "2.0.0"
3
3
  end
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: 1.0.7
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-16 00:00:00.000000000 Z
11
+ date: 2022-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler