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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd7e60a70c4a2d0f1074dea867281bf9138ceef1
4
- data.tar.gz: 89e32de168ec58ea217bec061767687de4f54804
3
+ metadata.gz: 0aa54a1f2ed8cb250822f67430942ca9debcf453
4
+ data.tar.gz: 6c921ee98eaec4ecc6dd89a13aab7c11aca5e064
5
5
  SHA512:
6
- metadata.gz: 8d07c96e0eb781e401267d6007ecf42c18f18f979b7c9d4f10194e0d463a7921e8975ba108a394c04ca480279173fd0e55b9f487338c4e8bd9c4e0a9f1a30856
7
- data.tar.gz: 874b41407f5c1d7a3820ec01ed11998c8a607cfeb077598b45043a0d5b2348e4c6eb1bc65d88393df92afe669f54f7fcdd9598abdb2b3bf7dd6530b8f3b84b05
6
+ metadata.gz: b2478b3887e86f83c65d1e7b91c4fb1a3d6505b0f1a7312e9f941683b364512312fc24a5181d5b5c6c40987bf02256d929eaef11757ade52f2c69a9c1894d04d
7
+ data.tar.gz: df7fcc08a9ed93255e76a9abb7e934e7073a7709b4e08fa835c64af3622bafb95923ab6ebd74ce31443fe063a9f0b35ef6bf7af01f1c8f663d1593f97fb0b796
@@ -8,3 +8,5 @@ addons:
8
8
  repo_token: d57433c34e6540ec1ede44f03df0843c49e8f9b83bdf6ce7a767e9be0c9c6fd7
9
9
  after_script:
10
10
  - cat lcov.info | codeclimate
11
+ before_install:
12
+ - gem install bundler
data/README.md CHANGED
@@ -32,12 +32,15 @@ Or install it yourself as:
32
32
 
33
33
  ### 1. Configure
34
34
 
35
- The default configuration expects that the Sandthorn gem is present and uses it to fetch events.
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
@@ -6,8 +6,7 @@ module SandthornSequelProjection
6
6
 
7
7
  def get_events(*args)
8
8
  keywords = args.pop || {}
9
- keywords[:event_store] = @name
10
- Sandthorn.get_events(keywords)
9
+ SandthornSequelProjection.configuration.event_stores[@name].get_events(keywords)
11
10
  end
12
11
  end
13
12
  end
@@ -48,7 +48,6 @@ require 'forwardable'
48
48
  SandthornSequelProjection.find_event_store(@event_store_name)
49
49
  end
50
50
 
51
- attr_reader :event_store_name
52
51
  attr_accessor :event_handlers
53
52
 
54
53
  def define_event_handlers
@@ -1,3 +1,3 @@
1
1
  module SandthornSequelProjection
2
- VERSION = "0.0.4"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -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.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
- Sandthorn.default_event_store = MockEventStore.with_data
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[:event_data]).to eq(YAML.dump(event[:event_args]))
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) { Sandthorn.default_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
- Sandthorn.default_event_store.reset
39
+ SandthornSequelProjection.configuration.event_stores[:default].reset
40
40
  events.each { |e| event_store.add(e) }
41
41
  end
42
42
 
@@ -50,10 +50,9 @@ module SandthornSequelProjection
50
50
  describe "#update!" do
51
51
 
52
52
  before do
53
- event_store = Sandthorn.default_event_store
54
- event_store.reset
55
- event_store.add_event({sequence_number: 1, event_args: {}})
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
- context "when given no argument" do
79
- context "when an event store has been configured" do
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
@@ -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
- Sandthorn.configure do |sand|
22
- sand.event_stores = { default: SandthornSequelProjection::MockEventStore.new }
23
+ def driver_event_store
24
+ @event_store ||= SandthornSequelProjection::MockEventStore.new
23
25
  end
@@ -18,8 +18,6 @@ module SandthornSequelProjection
18
18
  end
19
19
 
20
20
  def add_event(event)
21
- # We have to do these silly things b/c of Sandthorn design errors.
22
- event[:event_data] = Sandthorn.serialize(event[:event_args])
23
21
  events << event
24
22
  end
25
23
 
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
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: 2015-03-18 00:00:00.000000000 Z
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.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.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