evrone-common-amqp 0.0.3 → 0.0.4
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/evrone/common/amqp/consumer/configuration.rb +28 -10
- data/lib/evrone/common/amqp/version.rb +1 -1
- data/spec/lib/amqp/consumer_spec.rb +23 -1
- 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: 13e75e0e8027b05c344009de228c214703cffaf8
|
|
4
|
+
data.tar.gz: 957c8666262ad04d916252f6446f4136e6dcc91c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 46fd1b8ec7e5561e7fc6d61c29c86b3a4b64b0b2122689b800a10b671f0da4281c00149a4bf3171dcdd50233041514906eaefe68d22447b397f6dcb5f8d42c95
|
|
7
|
+
data.tar.gz: f2ef3a3725cad3aaa5762864f9f2185461619b3b106ffd0074a7d3c195deda60c72b3fd09343aba1273d40a76d524044fdb75d43026b2e91975e4ab1c0a001cc
|
|
@@ -24,29 +24,38 @@ module Evrone
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
%w{ exchange queue }.each do |m|
|
|
27
|
-
define_method m do |*name|
|
|
27
|
+
define_method m do |*name, &b|
|
|
28
28
|
options = name.last.is_a?(Hash) ? name.pop : {}
|
|
29
|
-
|
|
29
|
+
val = b || name.first
|
|
30
|
+
consumer_configuration.__send__(m).name = val
|
|
30
31
|
consumer_configuration.__send__(m).options = options
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
define_method "#{m}_name" do
|
|
34
|
-
consumer_configuration.__send__(m).name || consumer_name
|
|
35
|
+
value_maybe_proc(consumer_configuration.__send__(m).name || consumer_name)
|
|
35
36
|
end
|
|
36
37
|
|
|
37
38
|
define_method "#{m}_options" do
|
|
38
|
-
consumer_configuration.__send__(m).options
|
|
39
|
+
value_maybe_proc(consumer_configuration.__send__(m).options)
|
|
39
40
|
end
|
|
40
41
|
end
|
|
41
42
|
|
|
42
|
-
def routing_key(name = nil)
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
def routing_key(name = nil, &block)
|
|
44
|
+
val = block || name
|
|
45
|
+
if val
|
|
46
|
+
consumer_configuration.routing_key = val
|
|
47
|
+
else
|
|
48
|
+
value_maybe_proc consumer_configuration.routing_key
|
|
49
|
+
end
|
|
45
50
|
end
|
|
46
51
|
|
|
47
|
-
def headers(values = nil)
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
def headers(values = nil, &block)
|
|
53
|
+
val = block || values
|
|
54
|
+
if val
|
|
55
|
+
consumer_configuration.headers = val
|
|
56
|
+
else
|
|
57
|
+
value_maybe_proc consumer_configuration.headers
|
|
58
|
+
end
|
|
50
59
|
end
|
|
51
60
|
|
|
52
61
|
def model(value = nil)
|
|
@@ -80,6 +89,15 @@ module Evrone
|
|
|
80
89
|
|
|
81
90
|
private
|
|
82
91
|
|
|
92
|
+
def value_maybe_proc(val)
|
|
93
|
+
case val
|
|
94
|
+
when Proc
|
|
95
|
+
val.call
|
|
96
|
+
else
|
|
97
|
+
val
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
83
101
|
def make_consumer_name
|
|
84
102
|
to_s.scan(/[A-Z][a-z]*/).join("_")
|
|
85
103
|
.downcase
|
|
@@ -68,13 +68,25 @@ describe Evrone::Common::AMQP::Consumer do
|
|
|
68
68
|
|
|
69
69
|
context "set routing_key" do
|
|
70
70
|
before { consumer_class.routing_key 'key' }
|
|
71
|
-
it { should eq(
|
|
71
|
+
it { should eq(routing_key: 'key') }
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
context "set routing_key by block" do
|
|
75
|
+
before do
|
|
76
|
+
consumer_class.routing_key { 'key.block' }
|
|
77
|
+
end
|
|
78
|
+
it { should eq(routing_key: 'key.block') }
|
|
72
79
|
end
|
|
73
80
|
|
|
74
81
|
context "set headers" do
|
|
75
82
|
before { consumer_class.headers 'key' }
|
|
76
83
|
it { should eq({headers: 'key'}) }
|
|
77
84
|
end
|
|
85
|
+
|
|
86
|
+
context "set headers by block" do
|
|
87
|
+
before { consumer_class.headers { 'key.block' } }
|
|
88
|
+
it { should eq(headers: 'key.block') }
|
|
89
|
+
end
|
|
78
90
|
end
|
|
79
91
|
|
|
80
92
|
context "ack" do
|
|
@@ -101,6 +113,11 @@ describe Evrone::Common::AMQP::Consumer do
|
|
|
101
113
|
consumer_class.exchange :foo
|
|
102
114
|
expect(subject).to eq :foo
|
|
103
115
|
end
|
|
116
|
+
|
|
117
|
+
it "when set by block should be" do
|
|
118
|
+
consumer_class.exchange { 'name.block' }
|
|
119
|
+
expect(subject).to eq 'name.block'
|
|
120
|
+
end
|
|
104
121
|
end
|
|
105
122
|
|
|
106
123
|
context "queue_name" do
|
|
@@ -113,6 +130,11 @@ describe Evrone::Common::AMQP::Consumer do
|
|
|
113
130
|
consumer_class.queue :bar
|
|
114
131
|
expect(subject).to eq :bar
|
|
115
132
|
end
|
|
133
|
+
|
|
134
|
+
it "when set by block should be" do
|
|
135
|
+
consumer_class.queue { 'name.block' }
|
|
136
|
+
expect(subject).to eq 'name.block'
|
|
137
|
+
end
|
|
116
138
|
end
|
|
117
139
|
|
|
118
140
|
%w{ queue exchange }.each do |m|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: evrone-common-amqp
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dmitry Galinsky
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2013-09-
|
|
11
|
+
date: 2013-09-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bunny
|