coordinator 0.0.13 → 0.0.14
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/lib/coordinator/redis_queue.rb +7 -3
- data/lib/coordinator/version.rb +1 -1
- data/test/unit/redis_queue_test.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a588480c336550aaca3f8e23ee7138363c9719f
|
4
|
+
data.tar.gz: 35e8f36438f042c03cf668b6ebdcfef9ed244012
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1d3a81354fdda554f8b8bdb1b191f33e9a737405c2d7921bfb8f63a8841a6e20dedb3d7cda3b7d7dc5a19984d3ad8a978bfb04ffe346d05c7e3a1c762539b0c
|
7
|
+
data.tar.gz: f8dd4e04a3bc6f3ae23d945c5ec0571795d56325e142e3f0bcb530ef1b5727d4a89e69a7b4a976d482778e44e64e59c2a60c5865b1049941311a732aae900954
|
@@ -12,12 +12,12 @@ module Coordinator
|
|
12
12
|
def push(item)
|
13
13
|
return false if full?
|
14
14
|
data = serialize(item)
|
15
|
-
@redis.rpush(@queue_name, data) unless
|
15
|
+
@redis.rpush(@queue_name, data) unless serialized_items.include?(data)
|
16
16
|
end
|
17
17
|
|
18
18
|
def left_push(item)
|
19
19
|
data = serialize(item)
|
20
|
-
@redis.lpush(@queue_name, data) unless
|
20
|
+
@redis.lpush(@queue_name, data) unless serialized_items.include?(data)
|
21
21
|
end
|
22
22
|
|
23
23
|
def pop
|
@@ -49,7 +49,7 @@ module Coordinator
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def items
|
52
|
-
|
52
|
+
serialized_items.map { |i| deserialize(i) }
|
53
53
|
end
|
54
54
|
|
55
55
|
def full?
|
@@ -58,6 +58,10 @@ module Coordinator
|
|
58
58
|
|
59
59
|
private
|
60
60
|
|
61
|
+
def serialized_items
|
62
|
+
@redis.lrange(@queue_name, 0, length)
|
63
|
+
end
|
64
|
+
|
61
65
|
def serialize(item)
|
62
66
|
item.is_a?(String) ? item : item.to_json
|
63
67
|
end
|
data/lib/coordinator/version.rb
CHANGED
@@ -13,6 +13,17 @@ describe 'Coordinator::RedisQueue' do
|
|
13
13
|
assert_equal 2, @queue.length
|
14
14
|
end
|
15
15
|
|
16
|
+
it 'adds same hash to queue only once' do
|
17
|
+
el = {
|
18
|
+
'id' => 10,
|
19
|
+
'subject' => 'testing'
|
20
|
+
}
|
21
|
+
|
22
|
+
@queue.push(el)
|
23
|
+
@queue.push(el)
|
24
|
+
assert_equal 1, @queue.length
|
25
|
+
end
|
26
|
+
|
16
27
|
it 'adds the same item only once' do
|
17
28
|
@queue.push("a")
|
18
29
|
@queue.push("a")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coordinator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Mercier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|