event_source 0.1.3 → 0.1.4

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: eb914b34c5ac365c2393fe93faf8d60127c110b0
4
- data.tar.gz: 936b70c31f5cd44aa650b035c02344aa20bdccbd
3
+ metadata.gz: 99615d0ee1b5991859cd7fdcf7b4058517131dc7
4
+ data.tar.gz: 51a0eb2bb11c880fb8b7387c03c8ccd155911c9c
5
5
  SHA512:
6
- metadata.gz: 5e73db02567fe3240d8958235adac8884a9f5d4bb1783fed344be05b2cf279f834017f0d4d31798fe1cf603fd62b6a1f06ba24914188e2d595b6dd2b9142f0a0
7
- data.tar.gz: 83da293f76c79226baafc460beb0394c7e922bde23fed2775dbbae8c87846e5bca764e0adeff7bd1dd317fe62c011e13ee66ab4d0c1f2028199b07cb4531752f
6
+ metadata.gz: cfda1b68846dddf94ceae003bcf142075a09adc4258be3ec6ed58efc481faa29272cd2c057214f8b2cf09d7e27af545786c63ce70e0b1e9af5aeb85da994f0f8
7
+ data.tar.gz: 71214026651276cfdb88ad0a545b636f645c658eaecb9e565ab9fdf3887538a074112fbddf794264c8d6c44481e987d01c94aea7f899b44712eb69631bb5eef0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # changes
2
2
 
3
- ## version 0.1.0
3
+ ## version 0.1.3
4
4
 
5
- nothing yet!
5
+ Include entities
6
+ Extend entities
7
+ Provide on_event meta method
8
+ rebuild entities based on events
9
+ provide in_memory sqlite3 event store
10
+
11
+ ## version 0.1.4
12
+ can specify a connection string to connect to an existing database
data/README.md CHANGED
@@ -4,7 +4,7 @@ This library is an implementation of the Event Sourcing pattern, where instead o
4
4
 
5
5
  ## The event repository
6
6
 
7
- An event store must be initialized. Currently, only the in_memory SQLlite3 type is available.
7
+ An event store must be initialized. Currently, only SQL based databases accessible via the Sequel gem can be used.
8
8
 
9
9
  ```ruby
10
10
  EventSource::EventRepository.create(in_memory: true)
@@ -16,6 +16,24 @@ Once initialized, the event repository is memoized and can be retrieved with:
16
16
  EventSource::EventRepository.current
17
17
  ```
18
18
 
19
+ ### Connecting to an existing database
20
+ Alternatively, you will probably need to connect to an existing database.
21
+
22
+ ```ruby
23
+ EventSource::EventRepository.create(connect: {connection_string: 'sqlite://events.db'})
24
+ ```
25
+
26
+ ### Schema
27
+
28
+ In the event you connect to an existing database, the EventRepository will expect the database to contain a table called "events" with the following schema:
29
+
30
+ * primary key: id
31
+ * string: name
32
+ * string: entity_id
33
+ * string: entity_type
34
+ * time: created_at
35
+ * string: data
36
+
19
37
  ## Your entities
20
38
 
21
39
  An entity is an object that you intend to persist. You must extend and include some class methods and instance methods. Let's create an entity called BankAccount.
@@ -11,6 +11,11 @@ module EventSource
11
11
  @db = Sequel.sqlite
12
12
  init_in_memory_schema
13
13
  end
14
+
15
+ if options[:connect]
16
+ con = options[:connect][:connection_string]
17
+ @db = Sequel.connect(con)
18
+ end
14
19
  end
15
20
 
16
21
  def save(event)
@@ -1,3 +1,3 @@
1
1
  module EventSource
2
- Version = '0.1.3'
2
+ Version = '0.1.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: event_source
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis Salin