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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0510de94abd807d6021a437c50991ee12c0905c2
4
- data.tar.gz: 6f0a0ae284f6c1950c64293c746e08395aca4db9
3
+ metadata.gz: f044a21d912f891cddeb152780b7c9f1f572b8c4
4
+ data.tar.gz: e129431af35652286f4c2a5a730e722e9087c341
5
5
  SHA512:
6
- metadata.gz: 7b4ab55c58fdfaf02e5f0a5d143ede5c0439ad76734d36c4ce8fd8e03d671f1348015d442bcdc605ffa67f0930d625e2aaada01bf146177d725a1bcc43a70aaf
7
- data.tar.gz: 14e9d30c0dab348d35bdcd3693debb83c0d1f7e40317d6aaa4f50f9bbc38ff31b239abc6ccff80d0be3acd5dd886d496d531b97c98f3b56a36e630d0740b924c
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
- events = @dataset.where(:sid => sid)
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
- events = @dataset.where(:dispatched => false)
36
- events = events.where(:sid => sid).order_by(:sequence) if sid
37
- events.all
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)
@@ -1,3 +1,3 @@
1
1
  module Eventus
2
- VERSION = "0.6.5"
2
+ VERSION = "0.6.6"
3
3
  end
@@ -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.5
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-02 00:00:00.000000000 Z
11
+ date: 2014-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake