ruby_event_store 0.20.0 → 0.21.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: 1ce3d71e182f3a66da41357e70d63e7a263cec63
4
- data.tar.gz: b90774755a72d60fd27c3a59652fce02222cfcdb
3
+ metadata.gz: cfb0772fe901e15fc75b778a04a4dd73192b0407
4
+ data.tar.gz: '07929227f6b1964589cef0962edce96e47cb4198'
5
5
  SHA512:
6
- metadata.gz: 98b5e5b21d3bed4f32702a4153177c554453c2413a6213ec33086e9c5158f93f9987de347ff0574e5379a057a2476c64c2777a050ede6da884b30a4688ec8bac
7
- data.tar.gz: a1de4d1c609d379f35b98b8f409fefe4e60553a0e376671f66dc02440bb00b4b78e863937db0096a47a8839871d380bfd21f3cdbf794f0e9bcfa2f89687722d3
6
+ metadata.gz: b7207f55c941d2e1bcd48cf656ef001750c9a17617507f38438e671ab8e2b288a6b045a5aec2731ff7da28462e872e76628094dbe80a6f8696238e67fa35ee72
7
+ data.tar.gz: ee9af3042920d3a5fb9fe407eb0b0e47a6f46cb0fdf160f1a26f245ee5e057a433b3a1f35eda6afa72c77ef09a7a2423d3e8b7c3b573aeb835c912be2250ce2d
@@ -6,6 +6,7 @@ require 'ruby_event_store/errors'
6
6
  require 'ruby_event_store/constants'
7
7
  require 'ruby_event_store/client'
8
8
  require 'ruby_event_store/event'
9
+ require 'ruby_event_store/stream'
9
10
  require 'ruby_event_store/deprecations'
10
11
  require 'ruby_event_store/serialized_record'
11
12
  require 'ruby_event_store/mappers/default'
@@ -69,6 +69,14 @@ module RubyEventStore
69
69
  repository.read_all_streams_backward(page.start, page.count)
70
70
  end
71
71
 
72
+ def read_event(event_id)
73
+ repository.read_event(event_id)
74
+ end
75
+
76
+ def get_all_streams
77
+ repository.get_all_streams
78
+ end
79
+
72
80
  def subscribe(subscriber, event_types, &proc)
73
81
  event_broker.add_subscriber(subscriber, event_types).tap do |unsub|
74
82
  handle_subscribe(unsub, &proc)
@@ -65,6 +65,14 @@ module RubyEventStore
65
65
  read_batch(all.reverse, start_event_id, count)
66
66
  end
67
67
 
68
+ def read_event(event_id)
69
+ all.find { |e| event_id.equal?(e.event_id) } or raise EventNotFound
70
+ end
71
+
72
+ def get_all_streams
73
+ [Stream.new("all")] + streams.keys.map { |name| Stream.new(name) }
74
+ end
75
+
68
76
  private
69
77
  attr_accessor :streams, :all
70
78
 
@@ -25,8 +25,11 @@ module RubyEventStore
25
25
  self
26
26
  end
27
27
 
28
- def when(event, handler)
29
- @handlers[event] = handler
28
+ def when(events, handler)
29
+ Array(events).each do |event|
30
+ @handlers[event] = handler
31
+ end
32
+
30
33
  self
31
34
  end
32
35
 
@@ -432,4 +432,26 @@ RSpec.shared_examples :event_repository do |repository_class|
432
432
  end.to raise_error(RubyEventStore::WrongExpectedEventVersion)
433
433
  expect(repository.has_event?('9bedf448-e4d0-41a3-a8cd-f94aec7aa763')).to be_falsey
434
434
  end
435
+
436
+ specify "all stream always present" do
437
+ expect(repository.get_all_streams).to match_array([RubyEventStore::Stream.new("all")])
438
+ end
439
+
440
+ specify "reading all existing stream names" do
441
+ repository.append_to_stream(TestDomainEvent.new, "test", -1)
442
+ repository.append_to_stream(TestDomainEvent.new, "test", 0)
443
+ expect(repository.get_all_streams).to match_array([RubyEventStore::Stream.new("all"), RubyEventStore::Stream.new("test")])
444
+ end
445
+
446
+ specify 'reading particular event' do
447
+ test_event = TestDomainEvent.new
448
+ repository.append_to_stream(TestDomainEvent.new, "test", -1)
449
+ repository.append_to_stream(test_event, "test", 0)
450
+
451
+ expect(repository.read_event(test_event.event_id)).to eq(test_event)
452
+ end
453
+
454
+ specify 'reading non-existent event' do
455
+ expect{repository.read_event('72922e65-1b32-4e97-8023-03ae81dd3a27')}.to raise_error(RubyEventStore::EventNotFound)
456
+ end
435
457
  end
@@ -0,0 +1,3 @@
1
+ module RubyEventStore
2
+ Stream = Struct.new(:name)
3
+ end
@@ -1,3 +1,3 @@
1
1
  module RubyEventStore
2
- VERSION = "0.20.0"
2
+ VERSION = "0.21.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_event_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arkency
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-24 00:00:00.000000000 Z
11
+ date: 2017-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -106,6 +106,7 @@ files:
106
106
  - lib/ruby_event_store/spec/dispatcher_lint.rb
107
107
  - lib/ruby_event_store/spec/event_broker_lint.rb
108
108
  - lib/ruby_event_store/spec/event_repository_lint.rb
109
+ - lib/ruby_event_store/stream.rb
109
110
  - lib/ruby_event_store/version.rb
110
111
  - ruby_event_store.gemspec
111
112
  homepage: https://github.com/RailsEventStore/ruby_event_store