sandthorn_sequel_projection 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/README.md +4 -1
- data/lib/sandthorn_sequel_projection.rb +11 -2
- data/lib/sandthorn_sequel_projection/event_store.rb +1 -2
- data/lib/sandthorn_sequel_projection/projection.rb +0 -1
- data/lib/sandthorn_sequel_projection/version.rb +1 -1
- data/sandthorn_sequel_projection.gemspec +1 -2
- data/spec/integration/projection_spec.rb +1 -1
- data/spec/mock_event_store_spec.rb +1 -1
- data/spec/processed_events_tracker_spec.rb +2 -2
- data/spec/projection_spec.rb +6 -20
- data/spec/spec_helper.rb +4 -2
- data/spec/support/mock_event_store.rb +0 -2
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0aa54a1f2ed8cb250822f67430942ca9debcf453
|
4
|
+
data.tar.gz: 6c921ee98eaec4ecc6dd89a13aab7c11aca5e064
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2478b3887e86f83c65d1e7b91c4fb1a3d6505b0f1a7312e9f941683b364512312fc24a5181d5b5c6c40987bf02256d929eaef11757ade52f2c69a9c1894d04d
|
7
|
+
data.tar.gz: df7fcc08a9ed93255e76a9abb7e934e7073a7709b4e08fa835c64af3622bafb95923ab6ebd74ce31443fe063a9f0b35ef6bf7af01f1c8f663d1593f97fb0b796
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -32,12 +32,15 @@ Or install it yourself as:
|
|
32
32
|
|
33
33
|
### 1. Configure
|
34
34
|
|
35
|
-
|
35
|
+
At least one sandthorn_driver instance is needed to fetch events from.
|
36
36
|
|
37
37
|
SandthornSequelProjection uses Sequel to connected to a database. Configure it like this:
|
38
38
|
|
39
|
+
#Setup an event_store from SanthornDriverSequel
|
40
|
+
event_store = SandthornDriverSequel.driver_from_connection(connection: Sequel.sqlite)
|
39
41
|
SandthornSequelProjection.configure do |thorn|
|
40
42
|
thorn.db_connection = Sequel.sqlite
|
43
|
+
thorn.event_store = event_store
|
41
44
|
end
|
42
45
|
|
43
46
|
### 2. Define projections
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require "sequel"
|
2
2
|
require "sandthorn_event_filter"
|
3
3
|
require "simple_migrator"
|
4
|
-
require "sandthorn"
|
4
|
+
#require "sandthorn"
|
5
5
|
|
6
6
|
require "sandthorn_sequel_projection/errors"
|
7
7
|
require "sandthorn_sequel_projection/version"
|
8
8
|
require "sandthorn_sequel_projection/utilities"
|
9
|
-
require "sandthorn_sequel_projection/event_store"
|
10
9
|
require "sandthorn_sequel_projection/cursor"
|
11
10
|
require "sandthorn_sequel_projection/event_handler"
|
11
|
+
require "sandthorn_sequel_projection/event_store"
|
12
12
|
require "sandthorn_sequel_projection/event_handler_collection"
|
13
13
|
require "sandthorn_sequel_projection/projection"
|
14
14
|
require "sandthorn_sequel_projection/lock"
|
@@ -39,6 +39,11 @@ module SandthornSequelProjection
|
|
39
39
|
def find_event_store(name)
|
40
40
|
EventStore.new(name)
|
41
41
|
end
|
42
|
+
|
43
|
+
def default_event_store
|
44
|
+
SandthornSequelProjection.configuration.event_stores[:default]
|
45
|
+
end
|
46
|
+
|
42
47
|
end
|
43
48
|
|
44
49
|
class Configuration
|
@@ -49,6 +54,10 @@ module SandthornSequelProjection
|
|
49
54
|
yield(self) if block_given?
|
50
55
|
end
|
51
56
|
|
57
|
+
def event_store=(store)
|
58
|
+
@event_stores = { default: store }
|
59
|
+
end
|
60
|
+
|
52
61
|
def self.default
|
53
62
|
self.new do |c|
|
54
63
|
c.batch_size = 40
|
@@ -23,13 +23,12 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.6"
|
24
24
|
spec.add_development_dependency "rake"
|
25
25
|
spec.add_development_dependency "rspec"
|
26
|
-
spec.add_development_dependency "sandthorn_driver_sequel", "~> 2.0
|
26
|
+
spec.add_development_dependency "sandthorn_driver_sequel", "~> 3.2.0"
|
27
27
|
spec.add_development_dependency "awesome_print"
|
28
28
|
spec.add_development_dependency "pry"
|
29
29
|
spec.add_development_dependency "sqlite3"
|
30
30
|
spec.add_development_dependency "codeclimate-test-reporter"
|
31
31
|
|
32
|
-
spec.add_runtime_dependency "sandthorn", "~> 0.7"
|
33
32
|
spec.add_runtime_dependency "sandthorn_event_filter", "~> 0.0.4"
|
34
33
|
spec.add_runtime_dependency "sequel"
|
35
34
|
spec.add_runtime_dependency "simple_migrator", "~> 0.0.3"
|
@@ -79,7 +79,7 @@ module SandthornSequelProjection
|
|
79
79
|
let(:projection) { MyProjection.new }
|
80
80
|
|
81
81
|
before do
|
82
|
-
|
82
|
+
SandthornSequelProjection.configuration.event_stores = { default: MockEventStore.with_data }
|
83
83
|
end
|
84
84
|
|
85
85
|
describe "#migrate!" do
|
@@ -9,7 +9,7 @@ module SandthornSequelProjection
|
|
9
9
|
it "returns events with serialized event data" do
|
10
10
|
events = store.get_events
|
11
11
|
event = events.first
|
12
|
-
expect(event[:
|
12
|
+
expect(event[:event_args]).to eq(event[:event_args])
|
13
13
|
end
|
14
14
|
|
15
15
|
it "returns the correct amount of events" do
|
@@ -4,7 +4,7 @@ module SandthornSequelProjection
|
|
4
4
|
describe ProcessedEventsTracker do
|
5
5
|
|
6
6
|
describe "migrated specs" do
|
7
|
-
let(:event_store) {
|
7
|
+
let(:event_store) { driver_event_store }
|
8
8
|
let(:db_connection) { SandthornSequelProjection.configuration.db_connection }
|
9
9
|
let(:tracker) { ProcessedEventsTracker.new(identifier: :foo, event_store: event_store) }
|
10
10
|
describe "::initialize" do
|
@@ -36,7 +36,7 @@ module SandthornSequelProjection
|
|
36
36
|
|
37
37
|
before do
|
38
38
|
tracker.reset
|
39
|
-
|
39
|
+
SandthornSequelProjection.configuration.event_stores[:default].reset
|
40
40
|
events.each { |e| event_store.add(e) }
|
41
41
|
end
|
42
42
|
|
data/spec/projection_spec.rb
CHANGED
@@ -50,10 +50,9 @@ module SandthornSequelProjection
|
|
50
50
|
describe "#update!" do
|
51
51
|
|
52
52
|
before do
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
event_store.add_event({sequence_number: 2, event_args: {}})
|
53
|
+
driver_event_store.reset
|
54
|
+
driver_event_store.add_event({sequence_number: 1, event_args: {}})
|
55
|
+
driver_event_store.add_event({sequence_number: 2, event_args: {}})
|
57
56
|
end
|
58
57
|
|
59
58
|
it "fetches events and passes them on to the handlers" do
|
@@ -68,24 +67,11 @@ module SandthornSequelProjection
|
|
68
67
|
|
69
68
|
describe "::event_store" do
|
70
69
|
let(:klass) { Class.new(Projection) }
|
71
|
-
context "when given an event store name" do
|
72
|
-
it "sets the event store" do
|
73
|
-
klass.event_store(:foo)
|
74
|
-
expect(klass.event_store_name).to eq(:foo)
|
75
|
-
end
|
76
|
-
end
|
77
70
|
|
78
|
-
|
79
|
-
|
80
|
-
before do
|
81
|
-
klass.event_store(:foo)
|
82
|
-
end
|
83
|
-
it "fetches the event store" do
|
84
|
-
expect(SandthornSequelProjection).to receive(:find_event_store).with(:foo)
|
85
|
-
klass.event_store
|
86
|
-
end
|
87
|
-
end
|
71
|
+
it "should be a SandthornSequelProjection::EventStore" do
|
72
|
+
expect(klass.event_store).to be_a SandthornSequelProjection::EventStore
|
88
73
|
end
|
74
|
+
|
89
75
|
end
|
90
76
|
|
91
77
|
describe "::define_event_handlers" do
|
data/spec/spec_helper.rb
CHANGED
@@ -12,12 +12,14 @@ require 'support/mock_event_store'
|
|
12
12
|
|
13
13
|
RSpec.configure do |config|
|
14
14
|
config.before(:each) do
|
15
|
+
|
15
16
|
SandthornSequelProjection.configure do |config|
|
16
17
|
config.db_connection = Sequel.sqlite
|
18
|
+
config.event_store = driver_event_store
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
+
def driver_event_store
|
24
|
+
@event_store ||= SandthornSequelProjection::MockEventStore.new
|
23
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sandthorn_sequel_projection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lars Krantz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.0
|
61
|
+
version: 3.2.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.0
|
68
|
+
version: 3.2.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: awesome_print
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,20 +122,6 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: sandthorn
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0.7'
|
132
|
-
type: :runtime
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0.7'
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: sandthorn_event_filter
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|