sandthorn 0.2.0 → 0.3.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: 6b32292f067fc1a54b2a64d44a42c88c852489b8
4
- data.tar.gz: 3da32e8fbd184194b7f99d0977742ab6cccc8f74
3
+ metadata.gz: f99d35485b8746cbbe8ea792d915d764344a689c
4
+ data.tar.gz: d3da0a1e657e55b9fdc283a4d549d1ea4c5c1a7b
5
5
  SHA512:
6
- metadata.gz: 69576400bb2d0667765130a000cf41b2eba699066b9eb9bc2172af37efd7351742fb646762f172d4c778cf9b057583c3a612dbb77f7462c70aca894d386a1081
7
- data.tar.gz: eba722ba78c620c688b4259962b1da42896ff13f65f10b7efd23399c4d55a2a3f2686494de213bd5f4c7ab04d9a8b6b621b25b6c6e9097911c97d85f97044bf8
6
+ metadata.gz: 4c9b2225374dc3626f14ef756c011438c0347e9e4787f53a3d74161e49c6875d9bcc2418e0fa4574e69b4b86d39c05c0348a52b58e78f4402028816ae81aae4b
7
+ data.tar.gz: 7c56c84f45d5c352e669e874a050fd62557a7c764e459d546c429f6cd544f9dcd7a28be55e2d0f116b49b90c265ee2c23fb03034b4b34a3dce8f19aa87ea3d8d
data/.autotest CHANGED
@@ -1,3 +1,3 @@
1
1
  Autotest.add_hook :initialize do |at|
2
- %w{.git spec/db}.each {|exception| at.add_exception(exception)}
2
+ %w{.git spec/db coverage}.each {|exception| at.add_exception(exception)}
3
3
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sandthorn (0.2.0)
4
+ sandthorn (0.3.0)
5
5
  dirty_hashy
6
6
 
7
7
  GEM
@@ -13,7 +13,6 @@ GEM
13
13
  multi_json (~> 1.3)
14
14
  thread_safe (~> 0.1)
15
15
  tzinfo (~> 0.3.37)
16
- atomic (1.1.16)
17
16
  autotest-standalone (4.5.11)
18
17
  awesome_print (1.2.0)
19
18
  coderay (1.1.0)
@@ -52,10 +51,10 @@ GEM
52
51
  rspec-expectations (2.14.5)
53
52
  diff-lcs (>= 1.1.3, < 2.0)
54
53
  rspec-mocks (2.14.6)
55
- sandthorn_driver_sequel (1.0.5)
54
+ sandthorn_driver_sequel (1.1.0)
56
55
  pg
57
56
  sequel
58
- sequel (4.8.0)
57
+ sequel (4.9.0)
59
58
  simplecov (0.8.2)
60
59
  docile (~> 1.1.0)
61
60
  multi_json
@@ -66,9 +65,8 @@ GEM
66
65
  term-ansicolor (1.3.0)
67
66
  tins (~> 1.0)
68
67
  thor (0.19.1)
69
- thread_safe (0.3.1)
70
- atomic (>= 1.1.7, < 2)
71
- tins (1.0.1)
68
+ thread_safe (0.3.3)
69
+ tins (1.1.0)
72
70
  tzinfo (0.3.39)
73
71
  yard (0.8.7.4)
74
72
 
@@ -86,5 +84,5 @@ DEPENDENCIES
86
84
  rake
87
85
  rspec
88
86
  sandthorn!
89
- sandthorn_driver_sequel
87
+ sandthorn_driver_sequel (~> 1.1)
90
88
  sqlite3
data/Rakefile CHANGED
@@ -6,6 +6,10 @@ RSpec::Core::RakeTask.new(:spec)
6
6
 
7
7
  task :default => :spec
8
8
 
9
+ task :benchmark do
10
+ sh "rspec --tag benchmark"
11
+ end
12
+
9
13
  task :console do
10
14
  require 'ap'
11
15
  require 'pry'
data/lib/sandthorn.rb CHANGED
@@ -55,6 +55,17 @@ module Sandthorn
55
55
  driver_for(class_name).get_aggregate_list_by_typename class_name
56
56
  end
57
57
 
58
+ def get_events aggregate_types: [], take: 0, after_sequence_number: 0
59
+ drivers = drivers_for_aggregate_types type_names: aggregate_types
60
+ raise Sandthorn::Errors::Error.new "Cannot get events from multiple contexts simultaneously, only one single context can be handled at a time." unless drivers.length == 1
61
+ driver = drivers.first
62
+ events = driver.get_events aggregate_types: aggregate_types, take: take, after_sequence_number: after_sequence_number
63
+ events.each do |event|
64
+ event[:event_args] = deserialize event[:event_data]
65
+ event.delete(:event_data)
66
+ end
67
+ events
68
+ end
58
69
  private
59
70
  def driver_for class_name, &block
60
71
  driver = identify_driver_from_class class_name
@@ -67,17 +78,16 @@ module Sandthorn
67
78
  pattern = class_name.to_s
68
79
  conf[:aggregate_pattern].nil? || r.match(pattern)
69
80
  end
70
- raise Sandthorn::Errors::ConfigurationError.new "Aggregate class #{class_name} is not configured for EventStore" if matches.empty?
81
+ raise Sandthorn::Errors::ConfigurationError.new "Aggregate class #{class_name} is not configured for Sandthorn" if matches.empty?
71
82
  first_match = matches.first
72
83
  first_match[:driver]
73
- #UpptecEventSequelDriver.driver_from_url url: first_match[:url], context: first_match[:context]
74
84
  end
75
- # def drivers_for_class_names class_names: []
76
- # return all_drivers if class_names.empty?
77
- # class_names.map { |e| driver_for e }.uniq { |d| { url: d.url, context: d.context } }
78
- # end
79
- # def all_drivers
80
- # configuration.map { |e| UpptecEventSequelDriver.driver_from_url url: e[:url], context: e[:context] }
81
- # end
85
+ def drivers_for_aggregate_types type_names: []
86
+ return all_drivers if type_names.empty?
87
+ type_names.map { |e| driver_for e }
88
+ end
89
+ def all_drivers
90
+ configuration.map { |e| e[:driver] }
91
+ end
82
92
  end
83
93
  end
@@ -1,3 +1,3 @@
1
1
  module Sandthorn
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/sandthorn.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "autotest-standalone"
29
29
  spec.add_development_dependency "sqlite3"
30
30
  spec.add_development_dependency "coveralls"
31
- spec.add_development_dependency "sandthorn_driver_sequel"
31
+ spec.add_development_dependency "sandthorn_driver_sequel", "~> 1.1"
32
32
 
33
33
  spec.add_runtime_dependency "dirty_hashy"
34
34
 
@@ -21,7 +21,7 @@ module Sandthorn
21
21
 
22
22
  end
23
23
 
24
- describe "benchmark" do
24
+ describe "benchmark", benchmark: true do
25
25
 
26
26
  let(:test_object) {
27
27
  o = TestClass.new().save
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ class AnAggregate
4
+ include Sandthorn::AggregateRoot
5
+ end
6
+
7
+ describe Sandthorn do
8
+ before(:each) { AnAggregate.new.save }
9
+ let(:events) { Sandthorn.get_events aggregate_types: [AnAggregate] }
10
+ context "when getting events using Sandthorn.get_events for an aggregate type" do
11
+ it "should return raw events" do
12
+ expect(events).to_not be_empty
13
+ end
14
+ end
15
+ end
data/spec/spec_helper.rb CHANGED
@@ -22,6 +22,7 @@ RSpec.configure do |config|
22
22
  config.treat_symbols_as_metadata_keys_with_true_values = true
23
23
  config.run_all_when_everything_filtered = true
24
24
  config.filter_run :focus
25
+ config.filter_run_excluding benchmark: true
25
26
 
26
27
  # Run specs in random order to surface order dependencies. If you find an
27
28
  # order dependency and want to debug it, you can fix the order by providing
@@ -32,7 +33,7 @@ RSpec.configure do |config|
32
33
  end
33
34
 
34
35
  def spec_db
35
- "sqlite://spec/db/sequel_driver.sqlite3"
36
+ "sqlite://spec/db/sequel_driver.sqlite3"
36
37
  end
37
38
  def sqlite_store_setup
38
39
  url = spec_db
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.2.0
4
+ version: 0.3.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-04-04 00:00:00.000000000 Z
12
+ date: 2014-04-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -155,16 +155,16 @@ dependencies:
155
155
  name: sandthorn_driver_sequel
156
156
  requirement: !ruby/object:Gem::Requirement
157
157
  requirements:
158
- - - ">="
158
+ - - "~>"
159
159
  - !ruby/object:Gem::Version
160
- version: '0'
160
+ version: '1.1'
161
161
  type: :development
162
162
  prerelease: false
163
163
  version_requirements: !ruby/object:Gem::Requirement
164
164
  requirements:
165
- - - ">="
165
+ - - "~>"
166
166
  - !ruby/object:Gem::Version
167
- version: '0'
167
+ version: '1.1'
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: dirty_hashy
170
170
  requirement: !ruby/object:Gem::Requirement
@@ -218,6 +218,7 @@ files:
218
218
  - spec/db/sequel_driver.sqlite3_old
219
219
  - spec/different_driver_spec.rb
220
220
  - spec/event_inspector_spec.rb
221
+ - spec/get_events_spec.rb
221
222
  - spec/spec_helper.rb
222
223
  - spec/tracing_spec.rb
223
224
  homepage: ''
@@ -253,6 +254,7 @@ test_files:
253
254
  - spec/db/sequel_driver.sqlite3_old
254
255
  - spec/different_driver_spec.rb
255
256
  - spec/event_inspector_spec.rb
257
+ - spec/get_events_spec.rb
256
258
  - spec/spec_helper.rb
257
259
  - spec/tracing_spec.rb
258
260
  has_rdoc: