sandthorn_driver_sequel_2 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sandthorn_driver_sequel_2.rb +2 -2
- data/lib/sandthorn_driver_sequel_2/event_store.rb +2 -2
- data/lib/sandthorn_driver_sequel_2/file_output_wrappers/events.rb +3 -2
- data/lib/sandthorn_driver_sequel_2/storage.rb +11 -3
- data/lib/sandthorn_driver_sequel_2/version.rb +1 -1
- data/spec/event_access_spec.rb +1 -1
- data/spec/event_store_file_output_spec.rb +1 -1
- data/spec/storage_spec.rb +1 -1
- data/spec/storage_to_file_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 079fdbbc8066a81887903c045a833df65a729910
|
4
|
+
data.tar.gz: aec39dd29d5c81a1807e39924c19303d3456c9be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5e1260390f6f8a84792c6fbbd9a2e1985b72174f49213c99a6f6960ff759724de14def6207453ccca50efaa44e917910decf6db9e8d8f88f0f09391dff6acb7
|
7
|
+
data.tar.gz: 7dc85c574d038bfc651650e62a4fe3055df9daf376d76bbf6d9c9a16760cd38a3ee1ad6616c86bb84dcc591f3f6057403aeab2706e1db3bc10d3318de9e95a67
|
@@ -12,8 +12,8 @@ require 'sandthorn_driver_sequel_2/file_output_wrappers/events'
|
|
12
12
|
|
13
13
|
module SandthornDriverSequel2
|
14
14
|
class << self
|
15
|
-
def driver_from_url url: nil, context: nil,
|
16
|
-
EventStore.new url: url, context: context,
|
15
|
+
def driver_from_url url: nil, context: nil, file_output_options: {}
|
16
|
+
EventStore.new url: url, context: context, file_output_options: file_output_options
|
17
17
|
end
|
18
18
|
def migrate_db url: nil, context: nil
|
19
19
|
migrator = Migration.new url: url, context: context
|
@@ -4,13 +4,13 @@ module SandthornDriverSequel2
|
|
4
4
|
|
5
5
|
attr_reader :driver, :context, :url
|
6
6
|
|
7
|
-
def initialize url: nil, context: nil,
|
7
|
+
def initialize url: nil, context: nil, file_output_options: {}
|
8
8
|
@driver = SequelDriver.new url: url
|
9
9
|
@context = context
|
10
10
|
@url = url
|
11
11
|
|
12
12
|
driver.execute do |db|
|
13
|
-
@storage = Storage.new(db, context,
|
13
|
+
@storage = Storage.new(db, context, file_output_options)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -4,9 +4,10 @@ module SandthornDriverSequel2
|
|
4
4
|
module FileOutputWrapper
|
5
5
|
class Events
|
6
6
|
extend Forwardable
|
7
|
-
def initialize event_file, sequence_number
|
7
|
+
def initialize event_file, sequence_number, delimiter: ','
|
8
8
|
@event_file = event_file
|
9
9
|
@sequence_number = sequence_number
|
10
|
+
@delimiter = delimiter
|
10
11
|
end
|
11
12
|
|
12
13
|
def events sequel
|
@@ -19,7 +20,7 @@ module SandthornDriverSequel2
|
|
19
20
|
@sequence_number += 1
|
20
21
|
event_data = String.new("#{event[:event_data]}")
|
21
22
|
event_data = " #{event_data}" if event_data =~ /^[\n\r]/
|
22
|
-
@event_file.puts "#{@sequence_number}
|
23
|
+
@event_file.puts "#{@sequence_number}#{@delimiter}#{event[:aggregate_id]}#{@delimiter}#{event[:aggregate_version]}#{@delimiter}#{event[:aggregate_type]}#{@delimiter}#{event[:event_name]}#{@delimiter}#{event_data}#{@delimiter}#{event[:timestamp]}"
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
@@ -10,13 +10,21 @@ module SandthornDriverSequel2
|
|
10
10
|
|
11
11
|
attr_reader :db
|
12
12
|
|
13
|
-
def initialize(db, context,
|
13
|
+
def initialize(db, context, file_output_options)
|
14
14
|
@db = db
|
15
15
|
@context = context
|
16
|
-
@event_file = File.open(events_file_path, "a") if events_file_path
|
16
|
+
@event_file = File.open(file_output_options[:events_file_path], "a") if file_output_options[:events_file_path]
|
17
17
|
last_event = events_table.order(:sequence_number).limit(1).last
|
18
18
|
last_sequence_number = last_event ? last_event[:sequence_number] : 0
|
19
|
-
|
19
|
+
|
20
|
+
if @event_file
|
21
|
+
if file_output_options[:delimiter]
|
22
|
+
@event_file_output_wrapper = FileOutputWrapper::Events.new @event_file, last_sequence_number, delimiter: file_output_options[:delimiter]
|
23
|
+
else
|
24
|
+
@event_file_output_wrapper = FileOutputWrapper::Events.new @event_file, last_sequence_number
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
20
28
|
end
|
21
29
|
|
22
30
|
# Returns a Sequel::Model for accessing events
|
data/spec/event_access_spec.rb
CHANGED
@@ -14,7 +14,7 @@ module SandthornDriverSequel2
|
|
14
14
|
let(:aggregate) do
|
15
15
|
aggregate_access.register_aggregate(aggregate_id, "foo")
|
16
16
|
end
|
17
|
-
let(:storage) { Storage.new(db, :test,
|
17
|
+
let(:storage) { Storage.new(db, :test, {}) }
|
18
18
|
let(:aggregate_access) { AggregateAccess.new(storage) }
|
19
19
|
let(:snapshot_access) { SnapshotAccess.new(storage)}
|
20
20
|
let(:access) { EventAccess.new(storage) }
|
@@ -5,7 +5,7 @@ module SandthornDriverSequel2
|
|
5
5
|
#after(:each) {File.delete(aggregates_file); File.delete(events_file);}
|
6
6
|
let(:events_file) {"spec/db_file/test_events.csv"}
|
7
7
|
let(:aggregates_file) {"spec/db_file/test_aggregates.csv"}
|
8
|
-
let(:event_store_file_output) { EventStore.new url: event_store_url, events_file_path: events_file }
|
8
|
+
let(:event_store_file_output) { EventStore.new url: event_store_url, file_output_options: {events_file_path: events_file} }
|
9
9
|
|
10
10
|
let(:test_events) do
|
11
11
|
e = []
|
data/spec/storage_spec.rb
CHANGED
@@ -9,7 +9,7 @@ module SandthornDriverSequel2
|
|
9
9
|
end
|
10
10
|
let(:db) { Sequel.connect(event_store_url) }
|
11
11
|
let(:driver) { SequelDriver.new(event_store_url)}
|
12
|
-
let(:storage) { Storage.new(db, context,
|
12
|
+
let(:storage) { Storage.new(db, context, {}) }
|
13
13
|
|
14
14
|
# describe "anonymous aggegrate class" do
|
15
15
|
# it "can insert and read data" do
|
@@ -17,7 +17,7 @@ module SandthornDriverSequel2
|
|
17
17
|
end
|
18
18
|
let(:db) { Sequel.connect(event_store_url) }
|
19
19
|
let(:driver) { SequelDriver.new(event_store_url)}
|
20
|
-
let(:storage) { Storage.new(db, context, event_file) }
|
20
|
+
let(:storage) { Storage.new(db, context, {events_file_path: event_file, delimiter: ';'}) }
|
21
21
|
|
22
22
|
describe "anonymous event class" do
|
23
23
|
it "insert no data to the db" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sandthorn_driver_sequel_2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lars Krantz
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-04-
|
13
|
+
date: 2015-04-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|