active_projection 0.4.1 → 0.4.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: a6b4b40f0225e31820939e9bfe3148ea9f212e47
4
- data.tar.gz: 0aa40406e3d1bb73fcf2073290b9154e67ed7e94
3
+ metadata.gz: 97dfe755e5611e78daf6c681a76b8469a6802842
4
+ data.tar.gz: 23edd1fbad4104a3070efaeec338e05f328c204f
5
5
  SHA512:
6
- metadata.gz: f6488612d653cdbba05c73f17276e73c534a1fdcb6d35c1740c536bdf87b3c950ffc5941a0059bd9f0afbea120db2d9be290c47c84df5b07cfa8a750c71de5a9
7
- data.tar.gz: 49c4483a2904602e73395a14d5ad1ef731c53e5dba486e272caddbf9924a076480e137fbc6bac06e7b8a93fc4b7363eb9e4533625aedc5deb342ea457b620d05
6
+ metadata.gz: 14dc5922412d9951353395420268a532927fbc10838e5be356651f14965a87da6ff1f132dba178e52f0d9d276e07f0a77544e02e804fa7b9f814a6dcd703327b
7
+ data.tar.gz: 345ebedd47f6e3df1ce2746ee421609d4d4385cb10390d9ff95eb8dffd4459ad02c58501fc55048d905c2f0b62ef1f960b46932a449fb8a3ee312a99607bd36e
@@ -11,6 +11,7 @@ module ActiveProjection
11
11
 
12
12
  def start
13
13
  event_connection.start
14
+ sync_projections
14
15
  listen_for_events
15
16
  request_missing_events
16
17
  event_channel.work_pool.join
@@ -18,6 +19,10 @@ module ActiveProjection
18
19
  puts 'Catching Interrupt'
19
20
  end
20
21
 
22
+ def sync_projections
23
+ ProjectionTypeRegistry.sync_projections
24
+ end
25
+
21
26
  def listen_for_events
22
27
  subscribe_to event_queue do |delivery_info, properties, body|
23
28
  event_received properties, body
@@ -20,6 +20,16 @@ module ActiveProjection
20
20
  end
21
21
  end
22
22
 
23
+ def self.sync_projections
24
+ instance.sync_projections
25
+ end
26
+
27
+ def sync_projections
28
+ projections.each do |projection|
29
+ ProjectionRepository.create_or_get(projection.class.name)
30
+ end
31
+ end
32
+
23
33
  private
24
34
 
25
35
  cattr_accessor :registry
@@ -1,7 +1,7 @@
1
1
  module ActiveProjection
2
2
  # Returns the version of the currently loaded ActiveProjection as a Gem::Version
3
3
  def self.version
4
- Gem::Version.new '0.4.1'
4
+ Gem::Version.new '0.4.2'
5
5
  end
6
6
 
7
7
  module VERSION #:nodoc:
@@ -20,4 +20,9 @@ describe ActiveProjection::ProjectionTypeRegistry do
20
20
  expect_any_instance_of(TestProjection).to receive(:invoke).with(event, headers)
21
21
  ActiveProjection::ProjectionTypeRegistry.process(headers, event)
22
22
  end
23
+
24
+ it 'synchronizes the known projections with the db' do
25
+ expect(ActiveProjection::ProjectionRepository).to receive(:create_or_get).with('TestProjection')
26
+ ActiveProjection::ProjectionTypeRegistry.sync_projections
27
+ end
23
28
  end
@@ -15,11 +15,15 @@ describe ActiveProjection::ProjectionType do
15
15
  def test_event(event, headers)
16
16
  end
17
17
 
18
- def dummy_event(event)
18
+ def admin__dummy_event(event)
19
19
  end
20
20
  end
21
21
  class TestEvent
22
22
  end
23
+ module Admin
24
+ class DummyEvent
25
+ end
26
+ end
23
27
  before :each do
24
28
  allow(ActiveProjection::ProjectionTypeRegistry).to receive(:register)
25
29
  TestProjection.send(:include, ActiveProjection::ProjectionType)
@@ -64,11 +68,20 @@ describe ActiveProjection::ProjectionType do
64
68
  end
65
69
  end
66
70
 
67
- it 'invokes all handler' do
68
- expect(ActiveProjection::ProjectionRepository).to receive(:set_last_id).with(1, 6)
69
- expect(@projection).to receive(:test_event)
70
- expect(@projection).to_not receive(:dummy)
71
- @projection.invoke(TestEvent.new, {id: 6})
71
+ describe 'invokes correct handler' do
72
+ it 'without namespace' do
73
+ expect(ActiveProjection::ProjectionRepository).to receive(:set_last_id).with(1, 6)
74
+ expect(@projection).to receive(:test_event)
75
+ expect(@projection).to_not receive(:admin__dummy_event)
76
+ @projection.invoke(TestEvent.new, {id: 6})
77
+ end
78
+
79
+ it 'with namespace' do
80
+ expect(ActiveProjection::ProjectionRepository).to receive(:set_last_id).with(1, 6)
81
+ expect(@projection).to receive(:admin__dummy_event)
82
+ expect(@projection).to_not receive(:test_event)
83
+ @projection.invoke(Admin::DummyEvent.new, {id: 6})
84
+ end
72
85
  end
73
86
  end
74
87
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_projection
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Reischuck
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-21 00:00:00.000000000 Z
11
+ date: 2013-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_event
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.4.1
19
+ version: 0.4.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.4.1
26
+ version: 0.4.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  version: '0'
194
194
  requirements: []
195
195
  rubyforge_project:
196
- rubygems_version: 2.0.5
196
+ rubygems_version: 2.1.11
197
197
  signing_key:
198
198
  specification_version: 4
199
199
  summary: Projection related stuff (part of rails-disco)