rails_event_store 0.17.0 → 0.18.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: e0fb5100ff7efa4af4bad4a6c1070f0d04dc97c7
4
- data.tar.gz: d7c211326f2287b7252649c7d84674850b557b5b
3
+ metadata.gz: eccacd2fff10347f058e4cbdbd4e7b61dfbde424
4
+ data.tar.gz: adc461690ebe4b0131d518941bd012bafc716aec
5
5
  SHA512:
6
- metadata.gz: ce4e5bc87fb238eb058b1cebb2f68a26854fe2ac7a2000316cad5a9206571ae246bac86480afb8eb2210a1bf6c2cce1b946632351514c75efcaa6cddac2b9035
7
- data.tar.gz: 0d62c42978350354c517008e2de21d123fb376e45aa9b164949fac3fec9604526f4439d71962de6e54f48b7f4c056af486114588e8896dc8e48676898c5d1b88
6
+ metadata.gz: bdef0a91207aee8129dc7b3a80648bef3e1221febac71cc98b1d6da5ab007a49074be8d369ad9ea150d6aa940e54ba4ae78442149d0a13bfaaa197bc7abbc240
7
+ data.tar.gz: 25aedf5586d981550cac1c8295cd2eaa60433440719d3c6475e44d4bfb5d8b4c46ecb08fea6859809982e0ffd2870b00543ab2b490ebb7e82731de3e6d112c54
data/Makefile CHANGED
@@ -1,24 +1,28 @@
1
- install-bundler: ## Install gem dependencies
1
+ GEM_VERSION = `cat ../RES_VERSION`
2
+
3
+ install: ## Install gem dependencies
2
4
  @echo "Installing gem dependencies"
3
5
  @bundle install
4
6
 
5
- install: install-bundler ## Prepare current development environment
6
-
7
7
  test: ## Run tests
8
8
  @echo "Running basic tests - beware: this won't guarantee build pass"
9
9
  @bundle exec rspec
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 rails_event_store --use rspec --ignore-subject "RailsEventStore.const_missing" "RailsEventStore*"
13
+ @bundle exec mutant --include lib --require rails_event_store --use rspec "RailsEventStore*" \
14
+ --ignore-subject "RailsEventStore.const_missing"
14
15
 
15
- release:
16
- @rake build
17
- @rake release:rubygem_push
16
+ build:
17
+ @gem build -V rails_event_store.gemspec
18
+ @mkdir -p pkg/
19
+ @mv rails_event_store-$(GEM_VERSION).gem pkg/
18
20
 
19
- .PHONY: help
21
+ release: build
22
+ @gem push pkg/rails_event_store-$(GEM_VERSION).gem
20
23
 
21
24
  help:
22
25
  @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
23
26
 
27
+ .PHONY: help
24
28
  .DEFAULT_GOAL := help
data/Rakefile CHANGED
@@ -1,13 +1,8 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
1
  require 'pry'
4
2
 
5
3
  EMPTY_DB = 'spec/test.sqlite3'
6
4
  DEV_DB = 'tmp/run.sqlite3'
7
5
 
8
- RSpec::Core::RakeTask.new(:spec)
9
- task default: :spec
10
-
11
6
  task :run do
12
7
  FileUtils.cp(EMPTY_DB, DEV_DB) unless File.exist?(DEV_DB)
13
8
  require 'rails_event_store'
@@ -0,0 +1,64 @@
1
+ require 'active_job'
2
+
3
+ module RailsEventStore
4
+ module AsyncProxyStrategy
5
+ class AfterCommit
6
+ def call(klass, event)
7
+ if ActiveRecord::Base.connection.transaction_open?
8
+ ActiveRecord::Base.
9
+ connection.
10
+ current_transaction.
11
+ add_record(AsyncRecord.new(klass, event))
12
+ else
13
+ klass.perform_later(YAML.dump(event))
14
+ end
15
+ end
16
+
17
+ private
18
+ class AsyncRecord
19
+ def initialize(klass, event)
20
+ @klass = klass
21
+ @event = event
22
+ end
23
+
24
+ def committed!
25
+ @klass.perform_later(YAML.dump(@event))
26
+ end
27
+ end
28
+ end
29
+
30
+ class Inline
31
+ def call(klass, event)
32
+ klass.perform_later(YAML.dump(event))
33
+ end
34
+ end
35
+ end
36
+
37
+ class ActiveJobDispatcher
38
+ def initialize(proxy_strategy: AsyncProxyStrategy::Inline.new)
39
+ @async_proxy_strategy = proxy_strategy
40
+ end
41
+
42
+ def call(subscriber, event)
43
+ subscriber.call(event)
44
+ end
45
+
46
+ def proxy_for(klass)
47
+ async_handler?(klass) ? async_proxy(klass) : sync_proxy(klass)
48
+ end
49
+
50
+ private
51
+ def async_handler?(klass)
52
+ klass < ActiveJob::Base
53
+ end
54
+
55
+ def sync_proxy(klass)
56
+ raise InvalidHandler.new(klass) unless klass.method_defined?(:call)
57
+ klass.new
58
+ end
59
+
60
+ def async_proxy(klass)
61
+ ->(e) { @async_proxy_strategy.call(klass, e) }
62
+ end
63
+ end
64
+ end
@@ -4,6 +4,7 @@ require 'rails_event_store/client'
4
4
  require 'rails_event_store/version'
5
5
  require 'rails_event_store/railtie'
6
6
  require 'rails_event_store/deprecations'
7
+ require 'rails_event_store/active_job_dispatcher'
7
8
 
8
9
  module RailsEventStore
9
10
  Event = RubyEventStore::Event
@@ -1,3 +1,3 @@
1
1
  module RailsEventStore
2
- VERSION = "0.17.0"
2
+ VERSION = "0.18.0"
3
3
  end
@@ -19,18 +19,19 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ['lib']
21
21
 
22
- spec.add_development_dependency 'bundler', '~> 1.9'
22
+ spec.add_development_dependency 'bundler', '~> 1.15'
23
23
  spec.add_development_dependency 'rake', '~> 10.0'
24
- spec.add_development_dependency 'pry'
25
- spec.add_development_dependency 'rspec'
24
+ spec.add_development_dependency 'rspec', '~> 3.6'
26
25
  spec.add_development_dependency 'rails', '~> 4.2'
26
+ spec.add_development_dependency 'pry'
27
27
  spec.add_development_dependency 'sqlite3'
28
28
  spec.add_development_dependency 'rack-test'
29
+ spec.add_development_dependency 'mutant-rspec', '~> 0.8.14'
29
30
 
30
- spec.add_dependency 'ruby_event_store', '= 0.17.0'
31
- spec.add_dependency 'rails_event_store_active_record', '= 0.17.0'
32
- spec.add_dependency 'aggregate_root', '= 0.17.0'
31
+ spec.add_dependency 'ruby_event_store', '= 0.18.0'
32
+ spec.add_dependency 'rails_event_store_active_record', '= 0.18.0'
33
+ spec.add_dependency 'aggregate_root', '= 0.18.0'
33
34
  spec.add_dependency 'activesupport', '>= 3.0'
34
35
  spec.add_dependency 'activemodel', '>= 3.0'
35
- spec.add_development_dependency 'mutant-rspec', '~> 0.8.11'
36
+ spec.add_dependency 'activejob', '>= 3.0'
36
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_event_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.18.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-09-15 00:00:00.000000000 Z
11
+ date: 2017-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.9'
19
+ version: '1.15'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.9'
26
+ version: '1.15'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -39,47 +39,47 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: pry
42
+ name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '3.6'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '3.6'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec
56
+ name: rails
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '4.2'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '4.2'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rails
70
+ name: pry
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '4.2'
75
+ version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '4.2'
82
+ version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: sqlite3
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -108,48 +108,62 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: mutant-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.8.14
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.8.14
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: ruby_event_store
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
129
  - - '='
116
130
  - !ruby/object:Gem::Version
117
- version: 0.17.0
131
+ version: 0.18.0
118
132
  type: :runtime
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
136
  - - '='
123
137
  - !ruby/object:Gem::Version
124
- version: 0.17.0
138
+ version: 0.18.0
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: rails_event_store_active_record
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - '='
130
144
  - !ruby/object:Gem::Version
131
- version: 0.17.0
145
+ version: 0.18.0
132
146
  type: :runtime
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
150
  - - '='
137
151
  - !ruby/object:Gem::Version
138
- version: 0.17.0
152
+ version: 0.18.0
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: aggregate_root
141
155
  requirement: !ruby/object:Gem::Requirement
142
156
  requirements:
143
157
  - - '='
144
158
  - !ruby/object:Gem::Version
145
- version: 0.17.0
159
+ version: 0.18.0
146
160
  type: :runtime
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
164
  - - '='
151
165
  - !ruby/object:Gem::Version
152
- version: 0.17.0
166
+ version: 0.18.0
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: activesupport
155
169
  requirement: !ruby/object:Gem::Requirement
@@ -179,19 +193,19 @@ dependencies:
179
193
  - !ruby/object:Gem::Version
180
194
  version: '3.0'
181
195
  - !ruby/object:Gem::Dependency
182
- name: mutant-rspec
196
+ name: activejob
183
197
  requirement: !ruby/object:Gem::Requirement
184
198
  requirements:
185
- - - "~>"
199
+ - - ">="
186
200
  - !ruby/object:Gem::Version
187
- version: 0.8.11
188
- type: :development
201
+ version: '3.0'
202
+ type: :runtime
189
203
  prerelease: false
190
204
  version_requirements: !ruby/object:Gem::Requirement
191
205
  requirements:
192
- - - "~>"
206
+ - - ">="
193
207
  - !ruby/object:Gem::Version
194
- version: 0.8.11
208
+ version: '3.0'
195
209
  description: Implementation of Event Store in Ruby
196
210
  email:
197
211
  - dev@arkency.com
@@ -205,6 +219,7 @@ files:
205
219
  - README.md
206
220
  - Rakefile
207
221
  - lib/rails_event_store.rb
222
+ - lib/rails_event_store/active_job_dispatcher.rb
208
223
  - lib/rails_event_store/all.rb
209
224
  - lib/rails_event_store/client.rb
210
225
  - lib/rails_event_store/deprecations.rb