propono 0.5.6 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +8 -8
  2. data/.gitignore +1 -0
  3. data/.travis.yml +1 -1
  4. data/CONTRIBUTING.md +10 -7
  5. data/README.md +102 -28
  6. data/Rakefile +10 -0
  7. data/lib/propono/components/queue_subscription.rb +1 -5
  8. data/lib/propono/components/sns.rb +3 -7
  9. data/lib/propono/components/sqs.rb +3 -7
  10. data/lib/propono/configuration.rb +4 -10
  11. data/lib/propono/logger.rb +19 -0
  12. data/lib/propono/propono_error.rb +7 -0
  13. data/lib/propono/services/publisher.rb +5 -8
  14. data/lib/propono/services/queue_creator.rb +1 -1
  15. data/lib/propono/services/queue_listener.rb +9 -10
  16. data/lib/propono/services/topic_creator.rb +1 -1
  17. data/lib/propono/services/udp_listener.rb +12 -14
  18. data/lib/propono/version.rb +1 -1
  19. data/lib/propono.rb +95 -11
  20. data/propono.gemspec +1 -0
  21. data/test/{post_subscription_test.rb → components/post_subscription_test.rb} +1 -1
  22. data/test/{queue_subscription_test.rb → components/queue_subscription_test.rb} +3 -3
  23. data/test/{queue_test.rb → components/queue_test.rb} +1 -1
  24. data/test/{sns_test.rb → components/sns_test.rb} +4 -10
  25. data/test/{sqs_test.rb → components/sqs_test.rb} +4 -10
  26. data/test/{topic_test.rb → components/topic_test.rb} +1 -1
  27. data/test/config.yml.example +4 -0
  28. data/test/configuration_test.rb +25 -22
  29. data/test/integration/integration_test.rb +31 -0
  30. data/test/integration/sns_to_sqs_test.rb +21 -0
  31. data/test/integration/udp_proxy_test.rb +27 -0
  32. data/test/integration/udp_to_sqs_test.rb +30 -0
  33. data/test/logger_test.rb +35 -0
  34. data/test/propono_test.rb +32 -11
  35. data/test/{publisher_test.rb → services/publisher_test.rb} +22 -9
  36. data/test/{queue_creator_test.rb → services/queue_creator_test.rb} +1 -1
  37. data/test/services/queue_listener_test.rb +90 -0
  38. data/test/{subscriber_test.rb → services/subscriber_test.rb} +1 -1
  39. data/test/{topic_creator_test.rb → services/topic_creator_test.rb} +1 -1
  40. data/test/{udp_listener.rb → services/udp_listener_test.rb} +23 -14
  41. data/test/test_helper.rb +10 -29
  42. metadata +55 -26
  43. data/test/queue_listener_test.rb +0 -119
data/test/test_helper.rb CHANGED
@@ -12,37 +12,18 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
12
12
 
13
13
  require "propono"
14
14
 
15
- Fog.mock!
16
-
17
15
  class Minitest::Test
18
16
  def setup
19
- Propono::Configuration.instance.access_key = "test-access-key"
20
- Propono::Configuration.instance.secret_key = "test-secret-key"
21
- Propono::Configuration.instance.queue_region = "us-east-1"
22
- Propono::Configuration.instance.application_name = "MyApp"
23
- end
24
-
25
- def config
26
- Propono::Configuration.instance
27
- end
28
-
29
- # capture_io reasigns stderr. Assign the config.logger
30
- # to where capture_io has redirected it to for this test.
31
- def capture_io(&block)
32
- require 'stringio'
33
-
34
- orig_stdout, orig_stderr = $stdout, $stderr
35
- captured_stdout, captured_stderr = StringIO.new, StringIO.new
36
- $stdout, $stderr = captured_stdout, captured_stderr
37
-
38
- config.logger = $stderr
39
- yield
40
-
41
- return captured_stdout.string, captured_stderr.string
42
- ensure
43
- $stdout = orig_stdout
44
- $stderr = orig_stderr
45
- config.logger = $stderr
17
+ Fog.mock!
18
+ Propono.config do |config|
19
+ config.access_key = "test-access-key"
20
+ config.secret_key = "test-secret-key"
21
+ config.queue_region = "us-east-1"
22
+ config.application_name = "MyApp"
23
+
24
+ config.logger.stubs(:debug)
25
+ config.logger.stubs(:error)
26
+ end
46
27
  end
47
28
  end
48
29
 
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: 0.5.6
4
+ version: 0.6.0
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: 2013-10-18 00:00:00.000000000 Z
12
+ date: 2013-10-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog
@@ -67,6 +67,20 @@ dependencies:
67
67
  - - ! '>='
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: yard
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
70
84
  - !ruby/object:Gem::Dependency
71
85
  name: minitest
72
86
  requirement: !ruby/object:Gem::Requirement
@@ -104,6 +118,8 @@ files:
104
118
  - lib/propono/components/sqs.rb
105
119
  - lib/propono/components/topic.rb
106
120
  - lib/propono/configuration.rb
121
+ - lib/propono/logger.rb
122
+ - lib/propono/propono_error.rb
107
123
  - lib/propono/services/publisher.rb
108
124
  - lib/propono/services/queue_creator.rb
109
125
  - lib/propono/services/queue_listener.rb
@@ -112,21 +128,27 @@ files:
112
128
  - lib/propono/services/udp_listener.rb
113
129
  - lib/propono/version.rb
114
130
  - propono.gemspec
131
+ - test/components/post_subscription_test.rb
132
+ - test/components/queue_subscription_test.rb
133
+ - test/components/queue_test.rb
134
+ - test/components/sns_test.rb
135
+ - test/components/sqs_test.rb
136
+ - test/components/topic_test.rb
137
+ - test/config.yml.example
115
138
  - test/configuration_test.rb
116
- - test/post_subscription_test.rb
139
+ - test/integration/integration_test.rb
140
+ - test/integration/sns_to_sqs_test.rb
141
+ - test/integration/udp_proxy_test.rb
142
+ - test/integration/udp_to_sqs_test.rb
143
+ - test/logger_test.rb
117
144
  - test/propono_test.rb
118
- - test/publisher_test.rb
119
- - test/queue_creator_test.rb
120
- - test/queue_listener_test.rb
121
- - test/queue_subscription_test.rb
122
- - test/queue_test.rb
123
- - test/sns_test.rb
124
- - test/sqs_test.rb
125
- - test/subscriber_test.rb
145
+ - test/services/publisher_test.rb
146
+ - test/services/queue_creator_test.rb
147
+ - test/services/queue_listener_test.rb
148
+ - test/services/subscriber_test.rb
149
+ - test/services/topic_creator_test.rb
150
+ - test/services/udp_listener_test.rb
126
151
  - test/test_helper.rb
127
- - test/topic_creator_test.rb
128
- - test/topic_test.rb
129
- - test/udp_listener.rb
130
152
  homepage: ''
131
153
  licenses:
132
154
  - AGPL3
@@ -152,18 +174,25 @@ signing_key:
152
174
  specification_version: 4
153
175
  summary: General purpose pub/sub library built on top of AWS SNS and SQS
154
176
  test_files:
177
+ - test/components/post_subscription_test.rb
178
+ - test/components/queue_subscription_test.rb
179
+ - test/components/queue_test.rb
180
+ - test/components/sns_test.rb
181
+ - test/components/sqs_test.rb
182
+ - test/components/topic_test.rb
183
+ - test/config.yml.example
155
184
  - test/configuration_test.rb
156
- - test/post_subscription_test.rb
185
+ - test/integration/integration_test.rb
186
+ - test/integration/sns_to_sqs_test.rb
187
+ - test/integration/udp_proxy_test.rb
188
+ - test/integration/udp_to_sqs_test.rb
189
+ - test/logger_test.rb
157
190
  - test/propono_test.rb
158
- - test/publisher_test.rb
159
- - test/queue_creator_test.rb
160
- - test/queue_listener_test.rb
161
- - test/queue_subscription_test.rb
162
- - test/queue_test.rb
163
- - test/sns_test.rb
164
- - test/sqs_test.rb
165
- - test/subscriber_test.rb
191
+ - test/services/publisher_test.rb
192
+ - test/services/queue_creator_test.rb
193
+ - test/services/queue_listener_test.rb
194
+ - test/services/subscriber_test.rb
195
+ - test/services/topic_creator_test.rb
196
+ - test/services/udp_listener_test.rb
166
197
  - test/test_helper.rb
167
- - test/topic_creator_test.rb
168
- - test/topic_test.rb
169
- - test/udp_listener.rb
198
+ has_rdoc:
@@ -1,119 +0,0 @@
1
- require File.expand_path('../test_helper', __FILE__)
2
-
3
- module Propono
4
- class QueueListenerTest < Minitest::Test
5
-
6
- def setup
7
- super
8
- @topic_id = "some-topic"
9
-
10
- @receipt_handle1 = "test-receipt-handle1"
11
- @receipt_handle2 = "test-receipt-handle2"
12
- @message1 = { "ReceiptHandle" => @receipt_handle1}
13
- @message2 = { "ReceiptHandle" => @receipt_handle2}
14
- @messages = { "Message" => [ @message1, @message2 ] }
15
- end
16
-
17
- def test_read_message_from_sqs
18
- message_response = mock()
19
- messages = { "Message" => [ { "ReceiptHandle" => "test-receipt-handle"} ] }
20
- message_response.expects(:body).returns(messages)
21
- sqs = mock()
22
- sqs.stubs(delete_message: message_response)
23
-
24
- sqs.expects(:receive_message).returns(message_response)
25
-
26
- queue_listener = QueueListener.new(@topic_id) {}
27
- queue_listener.stubs(sqs: sqs)
28
-
29
- queue_listener.send(:read_messages)
30
- end
31
-
32
- def test_each_message_yielded
33
- message_response = mock()
34
- message_response.expects(:body).returns(@messages)
35
- sqs = mock()
36
- sqs.stubs(receive_message: message_response)
37
-
38
- queue_url = "test-queue-url"
39
-
40
- sqs.expects(:delete_message).with(queue_url,@receipt_handle1)
41
- sqs.expects(:delete_message).with(queue_url,@receipt_handle2)
42
-
43
- queue_listener = QueueListener.new(@topic_id) { }
44
- queue_listener.stubs(sqs: sqs)
45
- queue_listener.stubs(queue_url: queue_url)
46
-
47
- queue_listener.send(:read_messages)
48
- end
49
-
50
- def test_each_message_deleted_from_sqs
51
- message_response = mock()
52
- message_response.expects(:body).returns(@messages)
53
- sqs = mock()
54
- sqs.stubs(delete_message: message_response)
55
- sqs.stubs(receive_message: message_response)
56
-
57
- messages_yielded = [ ]
58
- queue_listener = QueueListener.new(@topic_id) { |m| messages_yielded.push(m) }
59
- queue_listener.stubs(sqs: sqs)
60
-
61
- queue_listener.send(:read_messages)
62
-
63
- assert_equal messages_yielded.size, 2
64
- assert messages_yielded.include?(@message1)
65
- assert messages_yielded.include?(@message2)
66
- end
67
-
68
- def test_empty_list_of_messages_returned
69
- message_response = mock()
70
- messages = { "Message" => [ ] }
71
- message_response.expects(:body).returns(messages)
72
- sqs = mock()
73
- sqs.stubs(delete_message: message_response)
74
-
75
- sqs.expects(:receive_message).returns(message_response)
76
-
77
- queue_listener = QueueListener.new(@topic_id) {}
78
- queue_listener.stubs(sqs: sqs)
79
-
80
- refute queue_listener.send(:read_messages)
81
- end
82
-
83
- def test_exception_from_sqs_is_logged
84
- sqs = mock()
85
- sqs.stubs(:receive_message).raises(StandardError)
86
-
87
- queue_listener = QueueListener.new(@topic_id) {}
88
- queue_listener.stubs(sqs: sqs)
89
- queue_listener.stubs(queue_url: "http://example.com")
90
-
91
- out, err = capture_io do
92
- queue_listener.send(:read_messages)
93
- end
94
- assert_equal "Unexpected error reading from queue http://example.com\nStandardError\n", err
95
- end
96
-
97
- def test_exception_from_sqs_returns_false
98
- sqs = mock()
99
- sqs.stubs(:receive_message).raises(StandardError)
100
-
101
- queue_listener = QueueListener.new(@topic_id) {}
102
- queue_listener.stubs(sqs: sqs)
103
-
104
- refute queue_listener.send(:read_messages)
105
- end
106
-
107
- def test_listen_should_loop
108
- listener = QueueListener.new(@topic_id)
109
- listener.expects(:loop)
110
- listener.listen
111
- end
112
-
113
- def test_read_messages_should_subscribe
114
- listener = QueueListener.new(@topic_id)
115
- QueueSubscription.expects(create: mock(queue: mock(url: {})))
116
- listener.send(:read_messages)
117
- end
118
- end
119
- end