propono 1.1.2 → 1.1.3

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: 1917ef51173b438968c6c9a9453d710a48158312
4
- data.tar.gz: fe799f2582f1b5180e21d0567e0d9657f3322a02
3
+ metadata.gz: 158f942077120ee93c8c02b1f44007ad1292eb3e
4
+ data.tar.gz: aa5ad40b0f52a720e0c6f291453ab827d53a297a
5
5
  SHA512:
6
- metadata.gz: 526f52cb4a183d3a1dbed6048e12899abcd20eace75f017a80ea26d2753c5f1d061b222bf57b0a0c631ad81d6b78229c6b812e9fb652f3b390bedf34330631d2
7
- data.tar.gz: f8060edb37e58dddd21b23778a111229dc5f84c3ccea43f286c93aaf32c475a0f426b28582ef5098cf6732845fa2f18aad2334772963871a28933b7fb87f494a
6
+ metadata.gz: 98a05da78d36f413b9f1ae7be5fb3fa667c81348cce0d46b97cf0de95ad286f3fbfcb4b1e3588a0fa7f765c2687552a466d2bd1bbd9ea38bc3ae3db15a13563b
7
+ data.tar.gz: 5e8f33d494c1cf232a51a0a4051fe0548e2a853df8c15ca707a6f270a1b7c27ca7a2256fc368ace22a2e97b29a3b006067f2033b39048ac6ea6175fd61baad7d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 1.1.3 / 2014-05-14
2
+ * [FEATURE] Added ability to drain queue. Also allow dot releases of Fog.
3
+
1
4
  # 1.1.2 / 2014-03-31
2
5
  * [BUGFIX] Move topic lookup into publishing thread.
3
6
 
data/lib/propono.rb CHANGED
@@ -107,6 +107,22 @@ module Propono
107
107
  QueueListener.listen(topic, &message_processor)
108
108
  end
109
109
 
110
+ # Listens on a queue and yields for each message
111
+ #
112
+ # Calling this will enter a queue-listening loop that
113
+ # yields the message_processor for each messages. The
114
+ # loop will end when all messages have been processed.
115
+ #
116
+ # This method will automatically create a subscription if
117
+ # one does not exist, so there is no need to call
118
+ # <tt>subscribe_by_queue</tt> in addition.
119
+ #
120
+ # @param [String] topic The topic to subscribe to.
121
+ # @param &message_processor The block to yield for each message.
122
+ def self.drain_queue(topic, &message_processor)
123
+ QueueListener.drain(topic, &message_processor)
124
+ end
125
+
110
126
  # Listens for UDP messages and yields for each.
111
127
  #
112
128
  # Calling this will enter a queue-listening loop that
@@ -7,6 +7,10 @@ module Propono
7
7
  new(topic_id, &message_processor).listen
8
8
  end
9
9
 
10
+ def self.drain(topic_id, &message_processor)
11
+ new(topic_id, &message_processor).drain
12
+ end
13
+
10
14
  def initialize(topic_id, &message_processor)
11
15
  @topic_id = topic_id
12
16
  @message_processor = message_processor
@@ -21,6 +25,13 @@ module Propono
21
25
  end
22
26
  end
23
27
 
28
+ def drain
29
+ raise ProponoError.new("topic_id is nil") unless @topic_id
30
+ while read_messages
31
+ # continue as long as there are messages in the queue
32
+ end
33
+ end
34
+
24
35
  private
25
36
 
26
37
  def read_messages
@@ -1,3 +1,3 @@
1
1
  module Propono
2
- VERSION = "1.1.2"
2
+ VERSION = "1.1.3"
3
3
  end
data/propono.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "fog", "~> 1.15.0"
21
+ spec.add_dependency "fog", "~> 1.15"
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.3"
24
24
  spec.add_development_dependency "rake"
data/test/propono_test.rb CHANGED
@@ -36,6 +36,12 @@ module Propono
36
36
  Propono.listen_to_queue(topic)
37
37
  end
38
38
 
39
+ def test_drain_queue_calls_queue_listener
40
+ topic = 'foobar'
41
+ QueueListener.expects(:drain).with(topic)
42
+ Propono.drain_queue(topic)
43
+ end
44
+
39
45
  def test_listen_to_udp_calls_udp_listener
40
46
  UdpListener.expects(:listen).with()
41
47
  Propono.listen_to_udp()
@@ -41,6 +41,19 @@ module Propono
41
41
  end
42
42
  end
43
43
 
44
+ def test_drain_should_continue_if_queue_empty
45
+ @listener.expects(:read_messages).returns(nil)
46
+ @listener.drain
47
+ assert true
48
+ end
49
+
50
+ def test_drain_raises_with_nil_topic
51
+ listener = QueueListener.new(nil) {}
52
+ assert_raises ProponoError do
53
+ listener.drain
54
+ end
55
+ end
56
+
44
57
  def test_read_messages_should_subscribe
45
58
  QueueSubscription.expects(create: mock(queue: mock(url: {})))
46
59
  @listener.send(:read_messages)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: propono
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - MalcyL
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-31 00:00:00.000000000 Z
12
+ date: 2014-05-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ~>
19
19
  - !ruby/object:Gem::Version
20
- version: 1.15.0
20
+ version: '1.15'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ~>
26
26
  - !ruby/object:Gem::Version
27
- version: 1.15.0
27
+ version: '1.15'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: bundler
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  version: '0'
180
180
  requirements: []
181
181
  rubyforge_project:
182
- rubygems_version: 2.1.9
182
+ rubygems_version: 2.2.1
183
183
  signing_key:
184
184
  specification_version: 4
185
185
  summary: General purpose pub/sub library built on top of AWS SNS and SQS