multi_string_replace 1.0.8 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b91478f7ea291a05bdf88d9eb1d2f6a580abdcf2dac9961e244e8fdf1d0ee98
4
- data.tar.gz: d68af3891f7a2dce1c4058030c7b228106242611952e54483e3b81da57e37e97
3
+ metadata.gz: 475f85424faff8b9059d92aa706fd613f62947684f583b3ecfe893aeac995c90
4
+ data.tar.gz: 771f516436986b6a75d94ab7d68037742cabc346c4c9c9673610af80df00971b
5
5
  SHA512:
6
- metadata.gz: 64411c414d7fc075155a4da1c173700a5d51fa924b454f45610b58c03ff2cb5d5e8f6464b4ad96ddb927825d79f24c1a2e5a1f816edcfe18b9caaa95ea22c399
7
- data.tar.gz: 5613fab6a79fe69149fdd65085efb97888f5541f19b67694df6d6895a67e65b49da15aa714ba0c367e2cc419abf24afaf7c5d29bf38379407eefb14eae95fb8f
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.8)
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.8"
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.8
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