redis-deque 0.1.0 → 0.2.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: 1cdd48df50df7ac6187df87833dea87bc081d62fef36043681b57de55a720440
4
- data.tar.gz: c91128c60fed13783d74d73c2a59c60974074d23403a2f4af150c4f1e2dbf3ad
3
+ metadata.gz: a1a41c2cb5cb29d32dc7e30a396689e1e6015003eeba9c1505ecfc1f61a248d3
4
+ data.tar.gz: a0c3cce5a779ee790fdcd64eeecb5129022a2898bd5e9f95903e7a0612fe4af2
5
5
  SHA512:
6
- metadata.gz: b3443c68eed981dd345298f79f001eab472a129dca821a5a48cbd2f678a3f62f66b697c2a14a8fc254a1b79ecb644e0a9525626c112313d5a31a9e2f421cd851
7
- data.tar.gz: 6117efd7dfd74d2c639813eca093dca92c2d0ae08a9dc67f9c7f8d04a6e75e7db577f9ab12d45436f7caea8d0c4c4612e7d05d14f144497db6b6654035fcff57
6
+ metadata.gz: 8d7ecca6d10e343c10d3d57e4aedaeaa289b380ba27169d15523f0c22c0279ead1b0bbcf4cb21a628a742123709b21ffb486cc3079f9130dd6b3463b76b64dfb
7
+ data.tar.gz: 2423e22c76e865cab81d888bd71760a12dbf74fce9828d21e1df6b2da09325b45bd6c0a1d4bb18b0a953217750853af4618a0bb56c973788137b4c77eb3480e0
@@ -0,0 +1,11 @@
1
+ # 0.2.0
2
+
3
+ **Breaking changes:**
4
+
5
+ - `commit` is renamed to `commit_last`
6
+
7
+ **New features:**
8
+
9
+ - New `commit(msg)` acks specific message from the process queue
10
+ - New method `commit_all` that clears the process queue
11
+
@@ -2,7 +2,7 @@
2
2
 
3
3
  class Redis
4
4
  class Deque
5
- VERSION = '0.1.0'
5
+ VERSION = '0.2.0'
6
6
 
7
7
  def self.version
8
8
  "redis-deque version #{VERSION}"
@@ -50,8 +50,16 @@ class Redis
50
50
  @last_message
51
51
  end
52
52
 
53
- def commit
54
- @redis.lrem(@process_queue_name, 0, @last_message)
53
+ def commit(message)
54
+ @redis.lrem(@process_queue_name, 0, message)
55
+ end
56
+
57
+ def commit_last
58
+ commit @last_message
59
+ end
60
+
61
+ def commit_all
62
+ @redis.del @process_queue_name
55
63
  end
56
64
 
57
65
  def process(non_block = false, timeout = nil)
@@ -59,7 +67,7 @@ class Redis
59
67
  loop do
60
68
  message = pop(non_block)
61
69
  ret = yield message if block_given?
62
- commit if ret
70
+ commit_last if ret
63
71
  break if message.nil? || (non_block && empty?)
64
72
  end
65
73
  end
@@ -62,12 +62,38 @@ describe Redis::Deque do
62
62
  message.should be == 'a'
63
63
  end
64
64
 
65
- it 'should remove the element from bp_queue if commit is called' do
65
+ it 'should remove the last element from bp_queue if commit_last is called' do
66
66
  @queue << 'a'
67
+ @queue << 'b'
68
+ @queue.pop true
69
+ @queue.pop true
70
+
71
+ @redis.llen('bp__test').should be == 2
72
+ @queue.commit_last
73
+ @redis.llen('bp__test').should be == 1
74
+ @redis.lpop('bp__test').should be == 'a'
75
+ end
76
+
77
+ it 'should remove specific element from bp_queue if commit is called' do
78
+ @queue << 'a'
79
+ @queue << 'b'
80
+ @queue.pop true
67
81
  @queue.pop true
68
82
 
83
+ @redis.llen('bp__test').should be == 2
84
+ @queue.commit 'a'
69
85
  @redis.llen('bp__test').should be == 1
70
- @queue.commit
86
+ @redis.lpop('bp__test').should be == 'b'
87
+ end
88
+
89
+ it 'should remove everything from bp_queue if commit_all is called' do
90
+ @queue << 'a'
91
+ @queue << 'b'
92
+ @queue.pop true
93
+ @queue.pop true
94
+
95
+ @redis.llen('bp__test').should be == 2
96
+ @queue.commit_all
71
97
  @redis.llen('bp__test').should be == 0
72
98
  end
73
99
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-deque
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaakko Rinta-Filppula
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-01-28 00:00:00.000000000 Z
12
+ date: 2020-02-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis
@@ -63,6 +63,7 @@ extensions: []
63
63
  extra_rdoc_files: []
64
64
  files:
65
65
  - ".gitignore"
66
+ - CHANGELOG.md
66
67
  - Gemfile
67
68
  - LICENSE.txt
68
69
  - README.md