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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ad8b0f35cb67c5dfa7f950eed9c8d3f2a592a4c
4
- data.tar.gz: c3834db70856e0baaf045907d01c457f42eeae5d
3
+ metadata.gz: 079fdbbc8066a81887903c045a833df65a729910
4
+ data.tar.gz: aec39dd29d5c81a1807e39924c19303d3456c9be
5
5
  SHA512:
6
- metadata.gz: 8ce499a3eb979ba4c263662afc0475588e74c85f05ca8481d60e7a718ff9ec865838b76c0fcdf78236f0bd75cef593d2fa4af018a69096b5449568b5de4c8d77
7
- data.tar.gz: 96b6174602519e18fb8bad0d80393fe40cb40973180c93494d06dadbe85d39e1bc1484f848dd84cc682d6f2b1e2f3ebaa16812b593146f37f3344afe36321993
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, events_file_path: nil
16
- EventStore.new url: url, context: context, events_file_path: events_file_path
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, events_file_path: 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, events_file_path)
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};#{event[:aggregate_id]};#{event[:aggregate_version]};#{event[:aggregate_type]};#{event[:event_name]};#{event_data};#{event[:timestamp]}"
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, events_file_path)
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
- @event_file_output_wrapper = FileOutputWrapper::Events.new @event_file, last_sequence_number if @event_file
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
@@ -1,3 +1,3 @@
1
1
  module SandthornDriverSequel2
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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, nil) }
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 = []
@@ -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, nil) }
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.1
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-01 00:00:00.000000000 Z
13
+ date: 2015-04-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler