ruby_event_store 0.19.0 → 0.20.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: cf38d679db05a58d03f5cf03128e1515a44ae1e1
4
- data.tar.gz: ffabae418e7ec0fb99fe6b546790a155d2a1c361
3
+ metadata.gz: 1ce3d71e182f3a66da41357e70d63e7a263cec63
4
+ data.tar.gz: b90774755a72d60fd27c3a59652fce02222cfcdb
5
5
  SHA512:
6
- metadata.gz: 7ab222cbac66327aa236df8dc5c8f5b789854559d59a2d731914e031f1874f861ce9743b51a4d6c2a5f0351458f83b6fa0c6bbce16f887de69d600d8ee70a406
7
- data.tar.gz: 0b89629ee2da94623d4bb04998e0e686e424d94a1a05f306e168b1d0afb51d19ffd16ccb72d989249821bf0688a991237e99ce41d3d2746cba2cc664ea8a9455
6
+ metadata.gz: 98b5e5b21d3bed4f32702a4153177c554453c2413a6213ec33086e9c5158f93f9987de347ff0574e5379a057a2476c64c2777a050ede6da884b30a4688ec8bac
7
+ data.tar.gz: a1de4d1c609d379f35b98b8f409fefe4e60553a0e376671f66dc02440bb00b4b78e863937db0096a47a8839871d380bfd21f3cdbf794f0e9bcfa2f89687722d3
data/Makefile CHANGED
@@ -10,7 +10,7 @@ test: ## Run tests
10
10
 
11
11
  mutate: test ## Run mutation tests
12
12
  @echo "Running mutation tests - only 100% free mutation will be accepted"
13
- @bundle exec mutant --include lib --require ruby_event_store --use rspec "RubyEventStore*" --ignore-subject "RubyEventStore.const_missing" --ignore-subject "RubyEventStore::InMemoryRepository#append_with_synchronize" --ignore-subject "RubyEventStore::InMemoryRepository#normalize_to_array" --ignore-subject "RubyEventStore::Client#normalize_to_array"
13
+ @bundle exec mutant --include lib --require ruby_event_store --use rspec "RubyEventStore*" --ignore-subject "RubyEventStore.const_missing" --ignore-subject "RubyEventStore::InMemoryRepository#append_with_synchronize" --ignore-subject "RubyEventStore::InMemoryRepository#normalize_to_array" --ignore-subject "RubyEventStore::Client#normalize_to_array" --ignore-subject "RubyEventStore::SerializedRecord"
14
14
 
15
15
  build:
16
16
  @gem build -V ruby_event_store.gemspec
@@ -7,4 +7,6 @@ require 'ruby_event_store/constants'
7
7
  require 'ruby_event_store/client'
8
8
  require 'ruby_event_store/event'
9
9
  require 'ruby_event_store/deprecations'
10
+ require 'ruby_event_store/serialized_record'
11
+ require 'ruby_event_store/mappers/default'
10
12
  require 'ruby_event_store/version'
@@ -0,0 +1,35 @@
1
+ require 'yaml'
2
+ require 'active_support'
3
+
4
+ module RubyEventStore
5
+ module Mappers
6
+ class Default
7
+ def initialize(serializer: YAML, events_class_remapping: {})
8
+ @serializer = serializer
9
+ @events_class_remapping = events_class_remapping
10
+ end
11
+
12
+ def event_to_serialized_record(domain_event)
13
+ SerializedRecord.new(
14
+ event_id: domain_event.event_id,
15
+ metadata: serializer.dump(domain_event.metadata),
16
+ data: serializer.dump(domain_event.data),
17
+ event_type: domain_event.class.name
18
+ )
19
+ end
20
+
21
+ def serialized_record_to_event(record)
22
+ event_type = events_class_remapping.fetch(record.event_type) { record.event_type }
23
+ ActiveSupport::Inflector.constantize(event_type).new(
24
+ event_id: record.event_id,
25
+ metadata: serializer.load(record.metadata),
26
+ data: serializer.load(record.data)
27
+ )
28
+ end
29
+
30
+ private
31
+
32
+ attr_reader :serializer, :events_class_remapping
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,15 @@
1
+ module RubyEventStore
2
+ class SerializedRecord
3
+ StringsRequired = Class.new(StandardError)
4
+ def initialize(event_id:, data:, metadata:, event_type:)
5
+ raise StringsRequired unless [event_id, data, metadata, event_type].all? { |v| v.instance_of?(String) }
6
+ @event_id = event_id
7
+ @data = data
8
+ @metadata = metadata
9
+ @event_type = event_type
10
+ freeze
11
+ end
12
+
13
+ attr_reader :event_id, :data, :metadata, :event_type
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module RubyEventStore
2
- VERSION = "0.19.0"
2
+ VERSION = "0.20.0"
3
3
  end
@@ -12,13 +12,15 @@ Gem::Specification.new do |spec|
12
12
 
13
13
  spec.summary = %q{Event Store in Ruby}
14
14
  spec.description = %q{Implementation of Event Store in Ruby}
15
- spec.homepage = 'https://github.com/arkency/ruby_event_store'
15
+ spec.homepage = 'https://github.com/RailsEventStore/ruby_event_store'
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
18
  spec.bindir = 'exe'
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ['lib']
21
21
 
22
+
23
+ spec.add_dependency 'activesupport'
22
24
  spec.add_development_dependency 'bundler', '~> 1.15'
23
25
  spec.add_development_dependency 'rake', '~> 10.0'
24
26
  spec.add_development_dependency 'rspec', '~> 3.6'
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_event_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0
4
+ version: 0.20.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-06 00:00:00.000000000 Z
11
+ date: 2017-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -84,15 +98,17 @@ files:
84
98
  - lib/ruby_event_store/errors.rb
85
99
  - lib/ruby_event_store/event.rb
86
100
  - lib/ruby_event_store/in_memory_repository.rb
101
+ - lib/ruby_event_store/mappers/default.rb
87
102
  - lib/ruby_event_store/projection.rb
88
103
  - lib/ruby_event_store/pub_sub/broker.rb
89
104
  - lib/ruby_event_store/pub_sub/dispatcher.rb
105
+ - lib/ruby_event_store/serialized_record.rb
90
106
  - lib/ruby_event_store/spec/dispatcher_lint.rb
91
107
  - lib/ruby_event_store/spec/event_broker_lint.rb
92
108
  - lib/ruby_event_store/spec/event_repository_lint.rb
93
109
  - lib/ruby_event_store/version.rb
94
110
  - ruby_event_store.gemspec
95
- homepage: https://github.com/arkency/ruby_event_store
111
+ homepage: https://github.com/RailsEventStore/ruby_event_store
96
112
  licenses:
97
113
  - MIT
98
114
  metadata: {}
@@ -112,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
128
  version: '0'
113
129
  requirements: []
114
130
  rubyforge_project:
115
- rubygems_version: 2.6.12
131
+ rubygems_version: 2.6.11
116
132
  signing_key:
117
133
  specification_version: 4
118
134
  summary: Event Store in Ruby