nexia_event_store 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a53b46ee6253d85453dc97abcaea3cf60d1b6cd6
4
- data.tar.gz: 717b8827588f413f87b41513c2ef8539254140fb
3
+ metadata.gz: da7ed1c2d85dee75190b00526a806602d2d6c71b
4
+ data.tar.gz: 536ec662447be0e41c8199d19a43e732ef6f9331
5
5
  SHA512:
6
- metadata.gz: b96e05c1a31be2b889a473e86ea7254f506d946be4ef505d6fb2522a3b6c23a425cdc3a0debd3b3ba73d9e0eae386e06e71f4378735a09fc64dd6e452f516971
7
- data.tar.gz: 8e2ecbf2ca66a91042dda7fd790f2b61f328a432232045c27b16d1d8fa5807a8a123033345fee46718c65a2a5e5ec7e4c0d6693e945f1dd43e1ee6233f8cdc1c
6
+ metadata.gz: 73bbaeaa3c718528b35aa230b5424e59cf45a63cbd7ddee2a7087a5b4f365ea8ec3d317f8b7c5c225abee78f09255f06427a17184088940c30ce669ff625d200
7
+ data.tar.gz: 67f5a022073cef94a0dc566085788ccca545c9c6cc3564485d0f5d3531d6e1457a4890a46ba85233dfc75975606cea79e2eb438dbbd2c4aa0143b0521a0cae60
@@ -12,6 +12,7 @@ module EventStore
12
12
  :rebuild_snapshot!,
13
13
  :delete_snapshot!,
14
14
  :version,
15
+ :version_for,
15
16
  :snapshot_version_table
16
17
 
17
18
  def_delegators :@event_stream,
@@ -2,7 +2,7 @@ module EventStore
2
2
  class Client
3
3
  extend Forwardable
4
4
 
5
- def_delegators :aggregate, :delete_snapshot!, :snapshot_version_table
5
+ def_delegators :aggregate, :delete_snapshot!, :snapshot_version_table, :version_for
6
6
 
7
7
  def self.count
8
8
  Aggregate.count
@@ -18,8 +18,12 @@ module EventStore
18
18
  snapshot.last
19
19
  end
20
20
 
21
- def version
22
- (@redis.hget(snapshot_version_table, :current_version) || -1).to_i
21
+ def version(snapshot_key =:current_version)
22
+ (@redis.hget(snapshot_version_table, snapshot_key) || -1).to_i
23
+ end
24
+
25
+ def version_for(fully_qualified_name, sub_key = nil)
26
+ version(snapshot_key(fully_qualified_name: fully_qualified_name, sub_key: sub_key))
23
27
  end
24
28
 
25
29
  def size
@@ -1,3 +1,3 @@
1
1
  module EventStore
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.0'
3
3
  end
@@ -50,6 +50,15 @@ module EventStore
50
50
  end
51
51
  end
52
52
 
53
+ describe "#version_for" do
54
+ let(:subkey) { first_event[:sub_key] }
55
+ let(:fqn) { first_event[:fully_qualified_name] }
56
+
57
+ it "returns the version number for the last event of specific fqn" do
58
+ expect(snapshot.version_for(fqn, subkey)).to eq(first_event[:version])
59
+ end
60
+ end
61
+
53
62
  describe "#rebuild_snapshot!" do
54
63
  it "deletes the existing snapshot" do
55
64
  expect(redis).to receive(:del).with([snapshot.snapshot_table , snapshot.snapshot_version_table])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexia_event_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Saieg, John Colvin
@@ -273,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
273
273
  version: '0'
274
274
  requirements: []
275
275
  rubyforge_project:
276
- rubygems_version: 2.4.5
276
+ rubygems_version: 2.4.2
277
277
  signing_key:
278
278
  specification_version: 4
279
279
  summary: Ruby implementation of an EventSource (A+ES) for the Nexia Ecosystem