eventus 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eventus/persistence/sequel.rb +14 -8
- data/lib/eventus/version.rb +1 -1
- data/spec/persistence/sequel_spec.rb +5 -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: f044a21d912f891cddeb152780b7c9f1f572b8c4
|
4
|
+
data.tar.gz: e129431af35652286f4c2a5a730e722e9087c341
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a4079431f8c26910a46640182593fd03823547ed26b5a37d10a064fc2ba66417584720a5515387e51a7c0ad46b124f30daeed4fd63b96286c724d6795fdde6c
|
7
|
+
data.tar.gz: 1a7a0edfc561aae0685c85b0ff5cabaa57b9293e70fd4b70b6ce3b9bf6c8a9944d43eb67995c85a03a021a26c8a14e357e9f8f0e338b18cc3eebf38e479410db
|
@@ -25,16 +25,20 @@ module Eventus
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def load(sid, min = nil, max = nil)
|
28
|
-
|
29
|
-
events = events.where{ sequence >= min } if min
|
30
|
-
events = events.where{ sequence <= max } if max
|
31
|
-
events.order_by(:sequence).all
|
28
|
+
_load(sid, nil, min, max)
|
32
29
|
end
|
33
30
|
|
34
31
|
def load_undispatched(sid = nil)
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
_load(sid, false)
|
33
|
+
end
|
34
|
+
|
35
|
+
def _load(sid = nil, dispatched = nil, min = nil, max = nil)
|
36
|
+
events = @dataset
|
37
|
+
events = events.where(:sid => sid) unless sid.nil?
|
38
|
+
events = events.where(:dispatched => dispatched) unless dispatched.nil?
|
39
|
+
events = events.where{ sequence >= min } unless min.nil?
|
40
|
+
events = events.where{ sequence <= max } unless max.nil?
|
41
|
+
events.order_by(:sequence).all
|
38
42
|
end
|
39
43
|
|
40
44
|
def mark_dispatched(sid, sequence)
|
@@ -44,9 +48,11 @@ module Eventus
|
|
44
48
|
end
|
45
49
|
|
46
50
|
def convert_row(row)
|
47
|
-
row.each_with_object({}) do |(k,v), memo|
|
51
|
+
res = row.each_with_object({}) do |(k,v), memo|
|
48
52
|
memo[k.to_s] = v
|
49
53
|
end
|
54
|
+
res['body'] = res.fetch('body', {}).to_hash
|
55
|
+
res
|
50
56
|
end
|
51
57
|
|
52
58
|
def self.migrate!(db, target = nil)
|
data/lib/eventus/version.rb
CHANGED
@@ -81,6 +81,11 @@ describe Eventus::Persistence::Sequel do
|
|
81
81
|
expect {persistence.commit create_commit(id, 3, {"foo" => "This is taken"})}.to raise_error(Eventus::ConcurrencyError)
|
82
82
|
end
|
83
83
|
|
84
|
+
it "should convert body into a normal hash" do
|
85
|
+
result = persistence.load_undispatched(id)
|
86
|
+
result[0]['body'].class.should == Hash
|
87
|
+
end
|
88
|
+
|
84
89
|
it "should rollback changes on concurrency error" do
|
85
90
|
begin
|
86
91
|
persistence.commit create_commit(id, 3, {"foo" => "first"}, {"foo" => "second"}, {"foo" => "third"})
|
@@ -103,7 +108,6 @@ describe Eventus::Persistence::Sequel do
|
|
103
108
|
|
104
109
|
it "should load events between minimum and maximum" do
|
105
110
|
result = persistence.load id, 10, 15
|
106
|
-
p result
|
107
111
|
result.length.should == 6
|
108
112
|
end
|
109
113
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eventus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Staten
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|