propono 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 +7 -0
- data/README.md +1 -0
- data/lib/propono.rb +11 -9
- data/lib/propono/{queue.rb → components/queue.rb} +0 -0
- data/lib/propono/{sns.rb → components/sns.rb} +0 -0
- data/lib/propono/{sqs.rb → components/sqs.rb} +0 -0
- data/lib/propono/components/topic.rb +11 -0
- data/lib/propono/configuration.rb +1 -1
- data/lib/propono/{post_subscriber.rb → services/post_subscriber.rb} +0 -0
- data/lib/propono/{publisher.rb → services/publisher.rb} +0 -0
- data/lib/propono/{queue_creator.rb → services/queue_creator.rb} +0 -0
- data/lib/propono/{queue_subscriber.rb → services/queue_subscriber.rb} +7 -3
- data/lib/propono/{subscriber.rb → services/subscriber.rb} +0 -0
- data/lib/propono/{topic_creator.rb → services/topic_creator.rb} +2 -1
- data/lib/propono/version.rb +1 -1
- data/test/configuration_test.rb +6 -6
- data/test/queue_subscriber_test.rb +23 -9
- data/test/test_helper.rb +5 -0
- data/test/topic_creator_test.rb +2 -1
- data/test/topic_test.rb +12 -0
- metadata +24 -39
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: d088866567c48097ae184895e09ead7de705179d
|
|
4
|
+
data.tar.gz: c6f6e90ed8d3c1773e95e1c7d60c211274df48d9
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: b39237981ffd1d4c3515247ea61db476633f810e8de97308ec76a25efb4b5a0d6e9db71196c15b9250a88b6dee657f1ccc22940916c87619df8e14547e06f33f
|
|
7
|
+
data.tar.gz: 60bffaf2b6bd7f07189c5b3d441db887b90720ca3d1c5e5365895b407757943289b40c564b0a9244db1a805125b69e78dc534dd19382b6d302890cda3deb3cc7
|
data/README.md
CHANGED
data/lib/propono.rb
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
require "propono/version"
|
|
2
2
|
require 'propono/configuration'
|
|
3
|
-
require 'propono/sns'
|
|
4
|
-
require 'propono/sqs'
|
|
5
|
-
require "propono/
|
|
6
|
-
require "propono/
|
|
7
|
-
|
|
8
|
-
require "propono/
|
|
9
|
-
require "propono/
|
|
10
|
-
require "propono/
|
|
11
|
-
require "propono/
|
|
3
|
+
require 'propono/components/sns'
|
|
4
|
+
require 'propono/components/sqs'
|
|
5
|
+
require "propono/components/queue"
|
|
6
|
+
require "propono/components/topic"
|
|
7
|
+
|
|
8
|
+
require "propono/services/post_subscriber"
|
|
9
|
+
require "propono/services/publisher"
|
|
10
|
+
require "propono/services/queue_creator"
|
|
11
|
+
require "propono/services/queue_subscriber"
|
|
12
|
+
require "propono/services/subscriber"
|
|
13
|
+
require "propono/services/topic_creator"
|
|
12
14
|
|
|
13
15
|
module Propono
|
|
14
16
|
def self.config
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -15,15 +15,19 @@ module Propono
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def subscribe
|
|
18
|
-
@
|
|
18
|
+
@topic = TopicCreator.find_or_create(@topic_id)
|
|
19
19
|
@queue = QueueCreator.find_or_create(queue_name)
|
|
20
|
-
sns.subscribe(@
|
|
20
|
+
sns.subscribe(@topic.arn, @queue.arn, 'sqs')
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
private
|
|
24
24
|
|
|
25
25
|
def queue_name
|
|
26
|
-
@topic_id
|
|
26
|
+
"#{config.application_name.gsub(" ", "_")}::#{@topic_id}"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def config
|
|
30
|
+
Configuration.instance
|
|
27
31
|
end
|
|
28
32
|
end
|
|
29
33
|
end
|
|
File without changes
|
|
@@ -16,7 +16,8 @@ module Propono
|
|
|
16
16
|
def find_or_create
|
|
17
17
|
result = sns.create_topic(@topic_id)
|
|
18
18
|
body = result.body
|
|
19
|
-
body.fetch('TopicArn') { raise TopicCreatorError.new("No TopicArn returned from SNS") }
|
|
19
|
+
arn = body.fetch('TopicArn') { raise TopicCreatorError.new("No TopicArn returned from SNS") }
|
|
20
|
+
Topic.new(arn)
|
|
20
21
|
end
|
|
21
22
|
end
|
|
22
23
|
end
|
data/lib/propono/version.rb
CHANGED
data/test/configuration_test.rb
CHANGED
|
@@ -34,10 +34,10 @@ module Propono
|
|
|
34
34
|
assert_equal queue_region, config.queue_region
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
def
|
|
38
|
-
|
|
39
|
-
config.
|
|
40
|
-
assert_equal
|
|
37
|
+
def test_application_name
|
|
38
|
+
application_name = "test-application-name"
|
|
39
|
+
config.application_name = application_name
|
|
40
|
+
assert_equal application_name, config.application_name
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
def test_missing_access_key_throws_exception
|
|
@@ -58,9 +58,9 @@ module Propono
|
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
-
def
|
|
61
|
+
def test_missing_application_name_throws_exception
|
|
62
62
|
assert_raises(ConfigurationError) do
|
|
63
|
-
config.
|
|
63
|
+
config.application_name
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
end
|
|
@@ -3,16 +3,17 @@ require File.expand_path('../test_helper', __FILE__)
|
|
|
3
3
|
module Propono
|
|
4
4
|
class QueueSubscriberTest < Minitest::Test
|
|
5
5
|
def test_create_topic
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
topic_id = 'foobar'
|
|
7
|
+
topic = Topic.new(topic_id)
|
|
8
|
+
TopicCreator.expects(:find_or_create).with(topic_id).returns(topic)
|
|
9
|
+
QueueSubscriber.subscribe(topic_id)
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
def test_sqs_create_is_called
|
|
12
|
-
|
|
13
|
-
subscriber = QueueSubscriber.new(
|
|
13
|
+
topic_id = "Foobar"
|
|
14
|
+
subscriber = QueueSubscriber.new(topic_id)
|
|
14
15
|
|
|
15
|
-
TopicCreator.stubs(find_or_create: "1123")
|
|
16
|
+
TopicCreator.stubs(find_or_create: Topic.new("1123"))
|
|
16
17
|
|
|
17
18
|
sqs = mock()
|
|
18
19
|
sqs.expects(:create_queue).with(subscriber.send(:queue_name)).returns(mock(body: {'QueueUrl' => Fog::AWS::SQS::Mock::QueueUrl}))
|
|
@@ -22,14 +23,27 @@ module Propono
|
|
|
22
23
|
end
|
|
23
24
|
|
|
24
25
|
def test_subscriber_queue_name
|
|
25
|
-
|
|
26
|
+
config.application_name = "MyApp"
|
|
27
|
+
|
|
28
|
+
topic_id = "Foobar"
|
|
29
|
+
subscriber = QueueSubscriber.new(topic_id)
|
|
30
|
+
|
|
31
|
+
assert_equal subscriber.send(:queue_name), "MyApp::Foobar"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_subscriber_queue_name_with_spaces
|
|
35
|
+
config.application_name = "My App"
|
|
36
|
+
|
|
37
|
+
topic_id = "Foobar"
|
|
38
|
+
subscriber = QueueSubscriber.new(topic_id)
|
|
39
|
+
|
|
40
|
+
assert_equal subscriber.send(:queue_name), "My_App::Foobar"
|
|
26
41
|
end
|
|
27
42
|
|
|
28
43
|
def test_subscribe_calls_subscribe
|
|
29
44
|
arn = "arn123"
|
|
30
|
-
queue_url =
|
|
31
45
|
|
|
32
|
-
TopicCreator.stubs(find_or_create: arn)
|
|
46
|
+
TopicCreator.stubs(find_or_create: Topic.new(arn))
|
|
33
47
|
QueueCreator.stubs(find_or_create: Queue.new(Fog::AWS::SQS::Mock::QueueUrl))
|
|
34
48
|
|
|
35
49
|
sns = mock()
|
data/test/test_helper.rb
CHANGED
|
@@ -19,6 +19,11 @@ class Minitest::Test
|
|
|
19
19
|
Propono::Configuration.instance.access_key = "test-access-key"
|
|
20
20
|
Propono::Configuration.instance.secret_key = "test-secret-key"
|
|
21
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
|
|
22
27
|
end
|
|
23
28
|
end
|
|
24
29
|
|
data/test/topic_creator_test.rb
CHANGED
data/test/topic_test.rb
ADDED
metadata
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: propono
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 0.2.0
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- MalcyL
|
|
@@ -15,23 +14,20 @@ dependencies:
|
|
|
15
14
|
- !ruby/object:Gem::Dependency
|
|
16
15
|
name: fog
|
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
|
18
|
-
none: false
|
|
19
17
|
requirements:
|
|
20
|
-
- -
|
|
18
|
+
- - '>='
|
|
21
19
|
- !ruby/object:Gem::Version
|
|
22
20
|
version: '0'
|
|
23
21
|
type: :runtime
|
|
24
22
|
prerelease: false
|
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
-
none: false
|
|
27
24
|
requirements:
|
|
28
|
-
- -
|
|
25
|
+
- - '>='
|
|
29
26
|
- !ruby/object:Gem::Version
|
|
30
27
|
version: '0'
|
|
31
28
|
- !ruby/object:Gem::Dependency
|
|
32
29
|
name: bundler
|
|
33
30
|
requirement: !ruby/object:Gem::Requirement
|
|
34
|
-
none: false
|
|
35
31
|
requirements:
|
|
36
32
|
- - ~>
|
|
37
33
|
- !ruby/object:Gem::Version
|
|
@@ -39,7 +35,6 @@ dependencies:
|
|
|
39
35
|
type: :development
|
|
40
36
|
prerelease: false
|
|
41
37
|
version_requirements: !ruby/object:Gem::Requirement
|
|
42
|
-
none: false
|
|
43
38
|
requirements:
|
|
44
39
|
- - ~>
|
|
45
40
|
- !ruby/object:Gem::Version
|
|
@@ -47,39 +42,34 @@ dependencies:
|
|
|
47
42
|
- !ruby/object:Gem::Dependency
|
|
48
43
|
name: rake
|
|
49
44
|
requirement: !ruby/object:Gem::Requirement
|
|
50
|
-
none: false
|
|
51
45
|
requirements:
|
|
52
|
-
- -
|
|
46
|
+
- - '>='
|
|
53
47
|
- !ruby/object:Gem::Version
|
|
54
48
|
version: '0'
|
|
55
49
|
type: :development
|
|
56
50
|
prerelease: false
|
|
57
51
|
version_requirements: !ruby/object:Gem::Requirement
|
|
58
|
-
none: false
|
|
59
52
|
requirements:
|
|
60
|
-
- -
|
|
53
|
+
- - '>='
|
|
61
54
|
- !ruby/object:Gem::Version
|
|
62
55
|
version: '0'
|
|
63
56
|
- !ruby/object:Gem::Dependency
|
|
64
57
|
name: mocha
|
|
65
58
|
requirement: !ruby/object:Gem::Requirement
|
|
66
|
-
none: false
|
|
67
59
|
requirements:
|
|
68
|
-
- -
|
|
60
|
+
- - '>='
|
|
69
61
|
- !ruby/object:Gem::Version
|
|
70
62
|
version: '0'
|
|
71
63
|
type: :development
|
|
72
64
|
prerelease: false
|
|
73
65
|
version_requirements: !ruby/object:Gem::Requirement
|
|
74
|
-
none: false
|
|
75
66
|
requirements:
|
|
76
|
-
- -
|
|
67
|
+
- - '>='
|
|
77
68
|
- !ruby/object:Gem::Version
|
|
78
69
|
version: '0'
|
|
79
70
|
- !ruby/object:Gem::Dependency
|
|
80
71
|
name: minitest
|
|
81
72
|
requirement: !ruby/object:Gem::Requirement
|
|
82
|
-
none: false
|
|
83
73
|
requirements:
|
|
84
74
|
- - ~>
|
|
85
75
|
- !ruby/object:Gem::Version
|
|
@@ -87,7 +77,6 @@ dependencies:
|
|
|
87
77
|
type: :development
|
|
88
78
|
prerelease: false
|
|
89
79
|
version_requirements: !ruby/object:Gem::Requirement
|
|
90
|
-
none: false
|
|
91
80
|
requirements:
|
|
92
81
|
- - ~>
|
|
93
82
|
- !ruby/object:Gem::Version
|
|
@@ -108,16 +97,17 @@ files:
|
|
|
108
97
|
- README.md
|
|
109
98
|
- Rakefile
|
|
110
99
|
- lib/propono.rb
|
|
100
|
+
- lib/propono/components/queue.rb
|
|
101
|
+
- lib/propono/components/sns.rb
|
|
102
|
+
- lib/propono/components/sqs.rb
|
|
103
|
+
- lib/propono/components/topic.rb
|
|
111
104
|
- lib/propono/configuration.rb
|
|
112
|
-
- lib/propono/post_subscriber.rb
|
|
113
|
-
- lib/propono/publisher.rb
|
|
114
|
-
- lib/propono/
|
|
115
|
-
- lib/propono/
|
|
116
|
-
- lib/propono/
|
|
117
|
-
- lib/propono/
|
|
118
|
-
- lib/propono/sqs.rb
|
|
119
|
-
- lib/propono/subscriber.rb
|
|
120
|
-
- lib/propono/topic_creator.rb
|
|
105
|
+
- lib/propono/services/post_subscriber.rb
|
|
106
|
+
- lib/propono/services/publisher.rb
|
|
107
|
+
- lib/propono/services/queue_creator.rb
|
|
108
|
+
- lib/propono/services/queue_subscriber.rb
|
|
109
|
+
- lib/propono/services/subscriber.rb
|
|
110
|
+
- lib/propono/services/topic_creator.rb
|
|
121
111
|
- lib/propono/version.rb
|
|
122
112
|
- propono.gemspec
|
|
123
113
|
- test/configuration_test.rb
|
|
@@ -131,36 +121,30 @@ files:
|
|
|
131
121
|
- test/subscriber_test.rb
|
|
132
122
|
- test/test_helper.rb
|
|
133
123
|
- test/topic_creator_test.rb
|
|
124
|
+
- test/topic_test.rb
|
|
134
125
|
homepage: ''
|
|
135
126
|
licenses:
|
|
136
127
|
- AGPL3
|
|
128
|
+
metadata: {}
|
|
137
129
|
post_install_message:
|
|
138
130
|
rdoc_options: []
|
|
139
131
|
require_paths:
|
|
140
132
|
- lib
|
|
141
133
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
|
-
none: false
|
|
143
134
|
requirements:
|
|
144
|
-
- -
|
|
135
|
+
- - '>='
|
|
145
136
|
- !ruby/object:Gem::Version
|
|
146
137
|
version: '0'
|
|
147
|
-
segments:
|
|
148
|
-
- 0
|
|
149
|
-
hash: 1295735887844079183
|
|
150
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
|
-
none: false
|
|
152
139
|
requirements:
|
|
153
|
-
- -
|
|
140
|
+
- - '>='
|
|
154
141
|
- !ruby/object:Gem::Version
|
|
155
142
|
version: '0'
|
|
156
|
-
segments:
|
|
157
|
-
- 0
|
|
158
|
-
hash: 1295735887844079183
|
|
159
143
|
requirements: []
|
|
160
144
|
rubyforge_project:
|
|
161
|
-
rubygems_version:
|
|
145
|
+
rubygems_version: 2.0.0
|
|
162
146
|
signing_key:
|
|
163
|
-
specification_version:
|
|
147
|
+
specification_version: 4
|
|
164
148
|
summary: General purpose pub/sub library built on top of AWS SNS and SQS
|
|
165
149
|
test_files:
|
|
166
150
|
- test/configuration_test.rb
|
|
@@ -174,3 +158,4 @@ test_files:
|
|
|
174
158
|
- test/subscriber_test.rb
|
|
175
159
|
- test/test_helper.rb
|
|
176
160
|
- test/topic_creator_test.rb
|
|
161
|
+
- test/topic_test.rb
|