sandthorn 0.0.3 → 0.1.0

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: d62a1f08ee388aa164ab762e900658f7ff91fc58
4
- data.tar.gz: 226b61d65c54236354d87336f7de0521201b4695
3
+ metadata.gz: 5ea77d4f178bf3c2124f48fbe2e5b12a406cf787
4
+ data.tar.gz: e671b7b29d552b10251c335e73d4bfa5280b9614
5
5
  SHA512:
6
- metadata.gz: 6a672eea33d5a9f80a0dff9ccfb221149c51439167f1ca421bc0e0904fd531087645f761bb19d620f55b84e84acf05528ca3871dc5c9ef3e9b26ca3aef73f49f
7
- data.tar.gz: 04b81dd3de59073c253fdabd4dc93ddb5c08f06421d1f0f32646c90f5c0a3fe7f07dc8701f0a537a935a0534744ca6136b0e81b4bbe25980441bc3ef1d2d1d8f
6
+ metadata.gz: 417397fc0a413067e0e1756a325444867aaa9c8e5fd5d7bbb8b8553628f3144987464093e423d07de5bf6c44eacc0bf5e9725c4dbde09d896560085aa7a75e0a
7
+ data.tar.gz: 20406f646d0885d2dfbc066825562838a31ad7c4b76ca9b30c0efd6b5218363771e5ad0cee8902b3430bde5f992525a62a91d1ffaac6ed8889383dfff31c1163
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sandthorn (0.0.3)
4
+ sandthorn (0.1.0)
5
5
  dirty_hashy
6
6
 
7
7
  GEM
@@ -32,7 +32,7 @@ GEM
32
32
  method_source (0.8.2)
33
33
  mime-types (2.2)
34
34
  minitest (4.7.5)
35
- multi_json (1.9.0)
35
+ multi_json (1.9.2)
36
36
  pg (0.17.1)
37
37
  pry (0.9.12.6)
38
38
  coderay (~> 1.0)
@@ -41,7 +41,7 @@ GEM
41
41
  pry-doc (0.6.0)
42
42
  pry (~> 0.9)
43
43
  yard (~> 0.8)
44
- rake (10.1.1)
44
+ rake (10.2.2)
45
45
  rest-client (1.6.7)
46
46
  mime-types (>= 1.16)
47
47
  rspec (2.14.1)
@@ -66,11 +66,11 @@ GEM
66
66
  term-ansicolor (1.3.0)
67
67
  tins (~> 1.0)
68
68
  thor (0.19.1)
69
- thread_safe (0.2.0)
69
+ thread_safe (0.3.1)
70
70
  atomic (>= 1.1.7, < 2)
71
71
  tins (1.0.1)
72
72
  tzinfo (0.3.39)
73
- yard (0.8.7.3)
73
+ yard (0.8.7.4)
74
74
 
75
75
  PLATFORMS
76
76
  ruby
data/lib/sandthorn.rb CHANGED
@@ -50,6 +50,10 @@ module Sandthorn
50
50
  driver_for(class_name).save_snapshot aggregate_snapshot, aggregate_id, class_name
51
51
  end
52
52
 
53
+ def get_aggregate_list_by_typename class_name
54
+ driver_for(class_name).get_aggregate_list_by_typename class_name
55
+ end
56
+
53
57
  private
54
58
  def driver_for class_name, &block
55
59
  driver = identify_driver_from_class class_name
@@ -45,10 +45,6 @@ module Sandthorn
45
45
 
46
46
  alias :record_event :commit
47
47
 
48
-
49
- def all
50
- end
51
-
52
48
  def aggregate_trace args
53
49
  @aggregate_trace_information = args
54
50
  yield self
@@ -66,7 +62,17 @@ module Sandthorn
66
62
  @aggregate_trace_information = nil
67
63
  end
68
64
 
69
- def find aggregate_id
65
+ def all
66
+ aggregate_id_list = Sandthorn.get_aggregate_list_by_typename(self.name)
67
+ find aggregate_id_list
68
+ end
69
+
70
+ def find id
71
+ return aggregate_find id unless id.respond_to?(:each)
72
+ return id.map { |e| aggregate_find e }
73
+ end
74
+
75
+ def aggregate_find aggregate_id
70
76
  class_name = self.respond_to?(:name) ? self.name : self.class # to be able to extend a string for example.
71
77
  events = Sandthorn.get_aggregate(aggregate_id, class_name)
72
78
  raise Sandthorn::Errors::AggregateNotFound unless events and !events.empty?
@@ -1,3 +1,3 @@
1
1
  module Sandthorn
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -37,6 +37,29 @@ module Sandthorn
37
37
 
38
38
  end
39
39
 
40
+ describe "when get all aggregates from DirtyClass" do
41
+
42
+ before(:each) do
43
+ @first = DirtyClass.new.save
44
+ @middle = DirtyClass.new.save
45
+ @last = DirtyClass.new.save
46
+ end
47
+
48
+ let(:subject) { DirtyClass.all.map{ |s| s.id} }
49
+ let(:ids) { [@first.id, @middle.id, @last.id] }
50
+
51
+ context "all" do
52
+ it "should all the aggregates" do
53
+ expect(subject.length).to eql 3
54
+ end
55
+
56
+ it "should include correct aggregates" do
57
+ expect(subject).to match_array(ids)
58
+ end
59
+ end
60
+
61
+ end
62
+
40
63
 
41
64
  describe "when making a change on a aggregate" do
42
65
  let(:dirty_obejct) {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sandthorn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lars Krantz
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-28 00:00:00.000000000 Z
12
+ date: 2014-03-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler