entity_store 0.2.12 → 0.2.13
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/entity_store/event_bus.rb +9 -2
- data/lib/entity_store/utils.rb +8 -0
- data/lib/entity_store/version.rb +1 -1
- data/lib/entity_store.rb +2 -1
- data/spec/entity_store/event_bus_spec.rb +21 -9
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56a515dc52707cf7d8ad0a5442a6bbd50288c0d7
|
4
|
+
data.tar.gz: 5791edaf2c3fc2d42c5f3bffc014a67e372d41fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cac64af74658627325f5cb1aef22e457a96e8712d25dfcebd700ae4a9aca2c108abbf5c6f2ebc76c657370244b35af632b72c27c772854da8c9c8dde8c7fc822
|
7
|
+
data.tar.gz: f8cd018700bc09fe40590d8b06f30bdbf80e8c16fc996106a9e9b2cd88a06877aff938a120f7aee1f25cf7c8d350de894a16f586da1045044f0e14ff6b8a3475
|
@@ -27,7 +27,14 @@ module EntityStore
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def subscribers
|
30
|
-
EntityStore::Config.event_subscribers
|
30
|
+
EntityStore::Config.event_subscribers.map do |subscriber|
|
31
|
+
case subscriber
|
32
|
+
when String
|
33
|
+
Utils.get_type_constant(subscriber)
|
34
|
+
else
|
35
|
+
subscriber
|
36
|
+
end
|
37
|
+
end
|
31
38
|
end
|
32
39
|
|
33
40
|
def publish_to_feed(entity_type, event)
|
@@ -63,4 +70,4 @@ module EntityStore
|
|
63
70
|
end
|
64
71
|
end
|
65
72
|
end
|
66
|
-
end
|
73
|
+
end
|
data/lib/entity_store/version.rb
CHANGED
data/lib/entity_store.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module EntityStore
|
2
2
|
|
3
|
+
require_relative 'entity_store/utils'
|
3
4
|
require_relative 'entity_store/logging'
|
4
5
|
require_relative 'entity_store/config'
|
5
6
|
require_relative 'entity_store/time_factory'
|
@@ -28,4 +29,4 @@ module EntityStore
|
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
31
|
-
end
|
32
|
+
end
|
@@ -7,7 +7,13 @@ end
|
|
7
7
|
|
8
8
|
class DummySubscriber
|
9
9
|
def dummy_event
|
10
|
-
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class DummyStringSubscriber
|
15
|
+
def dummy_event
|
16
|
+
|
11
17
|
end
|
12
18
|
end
|
13
19
|
|
@@ -27,19 +33,25 @@ describe EventBus do
|
|
27
33
|
before(:each) do
|
28
34
|
@subscriber = DummySubscriber.new
|
29
35
|
DummySubscriber.stub(:new) { @subscriber }
|
36
|
+
@string_subscriber = DummyStringSubscriber.new
|
37
|
+
DummyStringSubscriber.stub(:new) { @string_subscriber }
|
30
38
|
@subscriber_class2 = double("SubscriberClass", :instance_methods => ['bilge'], :name => "SubscriberClass")
|
31
39
|
@all_subscriber = DummyAllSubscriber.new
|
32
40
|
DummyAllSubscriber.stub(:new) { @all_subscriber }
|
33
|
-
|
41
|
+
EntityStore::Config.stub(:event_subscribers).and_return([DummySubscriber, @subscriber_class2, DummyAllSubscriber, 'DummyStringSubscriber'])
|
34
42
|
@event_bus.stub(:publish_to_feed)
|
35
43
|
end
|
36
|
-
|
44
|
+
|
37
45
|
subject { @event_bus.publish(@entity_type, @event) }
|
38
|
-
|
46
|
+
|
39
47
|
it "calls the receiver method on the subscriber" do
|
40
48
|
@subscriber.should_receive(:dummy_event).with(@event)
|
41
49
|
subject
|
42
50
|
end
|
51
|
+
it "calls the receiver method on the string-resolved subscriber" do
|
52
|
+
@string_subscriber.should_receive(:dummy_event).with(@event)
|
53
|
+
subject
|
54
|
+
end
|
43
55
|
it "should not create an instance of a class without the receiver method" do
|
44
56
|
@subscriber_class2.should_not_receive(:new)
|
45
57
|
subject
|
@@ -53,15 +65,15 @@ describe EventBus do
|
|
53
65
|
subject
|
54
66
|
end
|
55
67
|
end
|
56
|
-
|
68
|
+
|
57
69
|
describe ".publish_to_feed" do
|
58
70
|
before(:each) do
|
59
71
|
@feed_store = double(ExternalStore)
|
60
72
|
@event_bus.stub(:feed_store) { @feed_store }
|
61
73
|
end
|
62
|
-
|
74
|
+
|
63
75
|
subject { @event_bus.publish_to_feed @entity_type, @event }
|
64
|
-
|
76
|
+
|
65
77
|
it "should publish to the external store" do
|
66
78
|
@feed_store.should_receive(:add_event).with(@entity_type, @event)
|
67
79
|
subject
|
@@ -78,10 +90,10 @@ describe EventBus do
|
|
78
90
|
@feed_store = double(ExternalStore)
|
79
91
|
@id = random_object_id
|
80
92
|
@feed_store.stub(:get_events) { |since| since == @id ? [] : [
|
81
|
-
EventDataObject.new('_id' => @id, '_type' => DummyEvent.name, 'name' => random_string)
|
93
|
+
EventDataObject.new('_id' => @id, '_type' => DummyEvent.name, 'name' => random_string)
|
82
94
|
]}
|
83
95
|
@event_bus.stub(:feed_store) { @feed_store }
|
84
|
-
end
|
96
|
+
end
|
85
97
|
|
86
98
|
subject { @event_bus.replay(@since, @type, DummySubscriber) }
|
87
99
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: entity_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Bird
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongo
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- lib/entity_store/not_found.rb
|
74
74
|
- lib/entity_store/store.rb
|
75
75
|
- lib/entity_store/time_factory.rb
|
76
|
+
- lib/entity_store/utils.rb
|
76
77
|
- lib/entity_store/version.rb
|
77
78
|
- lib/tasks/entity_store.rake
|
78
79
|
- spec/entity_store/config_spec.rb
|
@@ -105,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
106
|
version: '0'
|
106
107
|
requirements: []
|
107
108
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.2.
|
109
|
+
rubygems_version: 2.2.2
|
109
110
|
signing_key:
|
110
111
|
specification_version: 4
|
111
112
|
summary: Event sourced entity store with a replaceable body
|