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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a6f186704baaa5be4569f4b82a00a9d2bf46683
4
- data.tar.gz: b54daff3d8f3354601e95503d99367dcf6748dbf
3
+ metadata.gz: 4a588480c336550aaca3f8e23ee7138363c9719f
4
+ data.tar.gz: 35e8f36438f042c03cf668b6ebdcfef9ed244012
5
5
  SHA512:
6
- metadata.gz: 7cfbedf5fe4f2d2525e5dd00d52917f64da6c45f168ed282d80d1ceae995f42aaa037c4292de565564bdde00146416718a052805f45f8e67e1a23ead8c22ab9e
7
- data.tar.gz: a7c9b7e0f295735e82ff4b316fda3c98efa0b1cbf8d73f62dc1e868aa50d069ce7c3ae3798ef3845a259dfa7f7fd1755ef81fdfb95b53cc6da391abab3e65c3a
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 items.include?(data)
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 items.include?(data)
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
- @redis.lrange(@queue_name, 0, length).map { |i| deserialize(i) }
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
@@ -1,3 +1,3 @@
1
1
  module Coordinator
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
  end
@@ -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.13
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-09-30 00:00:00.000000000 Z
11
+ date: 2014-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http