rabbit_feed 1.0.1 → 1.0.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: d2f2331b2c4cfdf1e6030118fdbd7bb42827ed6c
4
- data.tar.gz: 3fd57a4b07458e78582e3daf136516e7bda87ad8
3
+ metadata.gz: fbd44e51378b933adbf33ef5b981628cc4f0471e
4
+ data.tar.gz: 120f6141be92381289476244240d70e8f641bda3
5
5
  SHA512:
6
- metadata.gz: f7872b47e62f16c00560f21c866067c4be21e54e3c1573257bbccb39819edbc9287c18319352612400d1bae166b379634fb4c2ccbe07268168f53fb986cae120
7
- data.tar.gz: fa9d2cb55db7200a3b81608335a7ad38a415412e6538bc8002f280c5608bcb57d872c0c2817cfc932b132ac38b6aa41f45c5f5f107ce49a56845bd581c09c8ae
6
+ metadata.gz: d97b69fe484666ba92d018ef8a8f63e9821cc221134568833404dec7f4bef18ee2a70bf5dd71dbfe13c10f2aadfc4f2d3b8f350b7a127d9a4736534bd1b9e432
7
+ data.tar.gz: 98b830cf47fba91cbb18c537edd6a46310f9c73687072fccc39f30749a5cb5173aad9b5cabaca984c9b75d538d79375187db5c6386ab8d455fbf97d33218818e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rabbit_feed (1.0.1)
4
+ rabbit_feed (1.0.2)
5
5
  activemodel (>= 3.2.0, < 5.0.0)
6
6
  activesupport (>= 3.2.0, < 5.0.0)
7
7
  avro (>= 1.5.4, < 1.8.0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../../
3
3
  specs:
4
- rabbit_feed (1.0.0)
4
+ rabbit_feed (1.0.2)
5
5
  activemodel (>= 3.2.0, < 5.0.0)
6
6
  activesupport (>= 3.2.0, < 5.0.0)
7
7
  avro (>= 1.5.4, < 1.8.0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../../
3
3
  specs:
4
- rabbit_feed (1.0.0)
4
+ rabbit_feed (1.0.2)
5
5
  activemodel (>= 3.2.0, < 5.0.0)
6
6
  activesupport (>= 3.2.0, < 5.0.0)
7
7
  avro (>= 1.5.4, < 1.8.0)
@@ -56,10 +56,13 @@ module RabbitFeed
56
56
 
57
57
  def handle_event event
58
58
  event_rule = events[event.name]
59
- raise RoutingError.new "No routing defined for application with name: #{event.application} for events named: #{event.name}" unless event_rule.present?
60
59
  event_rule.handle_event event
61
60
  end
62
61
 
62
+ def handles_event? event
63
+ events.has_key? event.name
64
+ end
65
+
63
66
  def validate!
64
67
  raise ConfigurationError.new "Bad application specification for #{name}: #{errors.messages}" if invalid?
65
68
  end
@@ -86,8 +89,8 @@ module RabbitFeed
86
89
  end
87
90
 
88
91
  def handle_event event
89
- application = find_application event.application
90
- raise RoutingError.new "No routing defined for application with name: #{event.application}" unless application.present?
92
+ application = find_application event
93
+ raise RoutingError.new "No routing defined for application with name: #{event.application} for events named: #{event.name}" unless application.present?
91
94
  application.handle_event event
92
95
  end
93
96
 
@@ -107,8 +110,11 @@ module RabbitFeed
107
110
  @catch_all_application = application
108
111
  end
109
112
 
110
- def find_application name
111
- named_applications[name] || catch_all_application
113
+ def find_application event
114
+ candidate_applications = [named_applications[event.application], catch_all_application].compact
115
+ candidate_applications.detect do |application|
116
+ application.handles_event? event
117
+ end
112
118
  end
113
119
  end
114
120
  end
@@ -1,3 +1,3 @@
1
1
  module RabbitFeed
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
@@ -43,6 +43,7 @@ module RabbitFeed
43
43
  events = [
44
44
  double(:event, application: 'dummy_1', name: 'event_1', payload: 1),
45
45
  double(:event, application: 'dummy_1', name: 'event_2', payload: 2),
46
+ double(:event, application: 'dummy_1', name: 'event_4', payload: 4),
46
47
  double(:event, application: 'dummy_2', name: 'event_3', payload: 3),
47
48
  double(:event, application: 'none', name: 'event_4', payload: 4),
48
49
  ]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rabbit_feed
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simply Business
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-23 00:00:00.000000000 Z
11
+ date: 2015-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny