evrone-common-amqp 0.2.1 → 0.2.2

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: 8ee813131ec79d839c44a553e1a46115e453f015
4
- data.tar.gz: 63af6b7151a1bf0b31fe51e9b5747182a2ffe863
3
+ metadata.gz: b7026b69a2227f3adc9eef4d6cfd39ff0ec764ce
4
+ data.tar.gz: 8811dd3fd48a5e75384d7491334e3ba7db904f8a
5
5
  SHA512:
6
- metadata.gz: 46544f8e331efeee04d46d14a85658bb0c8aa3120c5030423e75dbf3342bcde2f98b49d6a24b0b44a43278fc347327106820528e081cfc6f31387b5364047efa
7
- data.tar.gz: 7fdfb4058aa3b36ed9f8ce963e239a370ad0343637b13ad8880c3705ae9856aa5cbdfcdff0456137b4d1ce8f4fb0bc67460af4f5c8ead14b034e9f04e5767f57
6
+ metadata.gz: 03a5921a1d9b900c30a4448caef99e68c6ecbd508f23cbe4422bb6e7c185d680bad891d92b64102f29ae95f77d2934e9219229fee75ba0ee386f2669262cbefa
7
+ data.tar.gz: 90b0697c2a69f25e70e5719b500f66566c9ac41e6bc8101d8dc01d7ca08b2c104d94c060440869990ac3ba80467adc8b7760b1e1edcf4289b92a45e9cd0a1da1
@@ -99,10 +99,10 @@ module Evrone
99
99
  end
100
100
 
101
101
  def make_consumer_name
102
- to_s.scan(/[A-Z][a-z]*/).join("_")
102
+ to_s.split("::")
103
+ .last
104
+ .scan(/[A-Z][a-z]*/).join("_")
103
105
  .downcase
104
- .gsub(/_/, '.')
105
- .gsub(/\.consumer$/, '')
106
106
  end
107
107
 
108
108
  end
@@ -29,6 +29,15 @@ module Evrone
29
29
  @@classes
30
30
  end
31
31
 
32
+ def consumer_name
33
+ @consumer_name ||= begin
34
+ id = Thread.current[:consumer_id]
35
+ name = self.class.consumer_name.dup
36
+ name << ".#{id}" if id
37
+ name
38
+ end
39
+ end
40
+
32
41
  module ClassMethods
33
42
 
34
43
  include Common::AMQP::Consumer::Configuration
@@ -1,7 +1,7 @@
1
1
  module Evrone
2
2
  module Common
3
3
  module AMQP
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
6
6
  end
7
7
  end
@@ -29,8 +29,22 @@ describe Evrone::Common::AMQP::Consumer do
29
29
 
30
30
  subject { consumer_class }
31
31
 
32
- its(:consumer_name) { should eq 'evrone.test' }
33
32
  its(:config) { should be_an_instance_of(Evrone::Common::AMQP::Config) }
33
+ its(:consumer_name) { should eq 'test_consumer' }
34
+
35
+ context "instance consumer_name" do
36
+ subject { consumer.consumer_name }
37
+
38
+ it { should eq 'test_consumer' }
39
+
40
+ context "when Thread.current has key :consumer_id" do
41
+ before do
42
+ mock(Thread.current).[](:consumer_id){ '99' }
43
+ end
44
+ it { should eq 'test_consumer.99' }
45
+ end
46
+ end
47
+
34
48
 
35
49
  context "model" do
36
50
  subject { consumer_class.model }
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.2.1
4
+ version: 0.2.2
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-10-08 00:00:00.000000000 Z
11
+ date: 2013-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny