debouncer 0.2.0 → 0.2.1

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
  SHA1:
3
- metadata.gz: 48c4780e6aab992ab7ecf77f240897bd9e7474f4
4
- data.tar.gz: 8e311281e918f6bf12e0f8051e30be08638d1424
3
+ metadata.gz: 9f9e8547ac8f499bf83f7ea0a798cbc0296d8e33
4
+ data.tar.gz: e585350713f4323b67f7c94c66b52c13929aa165
5
5
  SHA512:
6
- metadata.gz: 969290d4ad850a13892552d0ee8e66ad442a2bbfbf736220f1596a4d8e3cd4d28b28b3d01566d01fe31496b8c11ead1a8cb943a5444512f698e7cd9a1f451ed5
7
- data.tar.gz: 84226ab4da39584b1c96a7e3c81b535514c7b5eaf7ca1c83bc23b016544c038169d16975732f1f72e6dfd3f85f6d670feb975c38c991b5e3758155484ae2373a
6
+ metadata.gz: 706f48631fa33382c9d219f6f64b1cd7416ef4bbc5d1bcc103a58318022c16e772395b31ca32ea338d273c2a1c9f8e82bf9047ad20f52c61542c699318dd5231
7
+ data.tar.gz: 665deabc223212af9b616d8509080908617d1490aaa34974b2fc9ce71f1cc99dbd49fde52b8890744b3aa25009dfd538c397fbb5654347ea03c18a7e5f6cf33f
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Debouncer
1
+ # Debouncer [![Build Status](https://travis-ci.org/hx/debouncer.svg?branch=master)](https://travis-ci.org/hx/debouncer)
2
2
 
3
3
  Background thread debouncing for Ruby.
4
4
 
@@ -102,6 +102,8 @@ end
102
102
 
103
103
  The `combine_messages` method will be called whenever `send_warning` is called. The first argument is the last value it returned, or an empty array if this is the first call for the thread. The second argument is an array of the arguments supplied to `send_warning`. It should return an array of arguments that will ultimately be passed to the original method.
104
104
 
105
+ If grouping is enabled, the first two arguments will not include the ID. Instead, it will be passed as the first argument. The reducer should not include the ID in the array it returns.
106
+
105
107
  A reducer method is a good place to call `flush_*` if you hit some sort of limit or threshold. Just remember to still return the array of arguments you want to call.
106
108
 
107
109
  ```ruby
@@ -14,7 +14,13 @@ class Debouncer
14
14
  immediate = "#{base_name}_immediately#{suffix}"
15
15
  debouncer = "@#{base_name}#{SUFFIXES[suffix]}_debouncer"
16
16
  extras = ''
17
- extras << ".reducer { |old, new| self.#{reduce_with} old, new }" if reduce_with
17
+ if reduce_with
18
+ if grouped
19
+ extras << ".reducer { |old, new| [new.first, *self.#{reduce_with}(old[1..-1] || [], new[1..-1], new.first)] }"
20
+ else
21
+ extras << ".reducer { |old, new| self.#{reduce_with} old, new }"
22
+ end
23
+ end
18
24
  extras << ".rescuer { |ex| self.#{rescue_with} ex }" if rescue_with
19
25
 
20
26
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
@@ -1,3 +1,3 @@
1
1
  class Debouncer
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: debouncer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil E. Pearson