ruby_event_store-rom 0.34.0 → 0.35.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
  SHA256:
3
- metadata.gz: b97f2d7af4c76d5a8ead68d3e0de13706ee3eef22aff89b00f893bc5eeb567e8
4
- data.tar.gz: 866cb7371d871e67f6ec64ec95c1f43472f507821e65747edd7eccd12e7a1a90
3
+ metadata.gz: 3760c9bc0e5cbf84b824cab9d38fc9ab85db2aea9fca8cc1ead956a67504d08f
4
+ data.tar.gz: 520f6ee4fee9f63018c547276691f1c9b2c23ae55dd5384279d55302f2c7d3e8
5
5
  SHA512:
6
- metadata.gz: 8a1b09063c49c1fa846cbbf689096be665d863d7ac2f6ab4405cbc29033cdd19096be542db6bacb8f03f9a9733c83e05a7477473177e7b901695f66862b6b78a
7
- data.tar.gz: 2e66057a6f000e66322a7085ae9e55e9b138200326c8860cabfdec53f0ebb0ed9301130dd3f3a252fab223ceedb7e6d621381835476c63a0dc001ed1f1c5faee
6
+ metadata.gz: df638ec5c1bbb2ec850675769b601df6660c89ce5c1b98cef2a7fe3c05065c86c3176163d2fbd3eddaab116e6d63656a95e711a65acc75877e027ec9194e77f3
7
+ data.tar.gz: b1df8c60802b4cd81e564da16f707d2b6baa3929507d072c94a7c29196789954150073a4d1b3d2f766663b7c74ddc2a18c1bdc1a92be6f065e9330e164bed23c
data/Gemfile CHANGED
@@ -1,4 +1,11 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
+ eval_gemfile File.expand_path('../lib/Gemfile.shared', __dir__)
5
+
4
6
  gem 'ruby_event_store', path: '../ruby_event_store'
7
+ gem 'sqlite3', '1.3.13'
8
+ gem 'pg', '>= 0.21'
9
+ gem 'mysql2', '>= 0.4.10'
10
+ gem 'fakefs', '~> 0.11.2'
11
+ gem 'childprocess'
data/Makefile CHANGED
@@ -40,56 +40,8 @@ IGNORE = RubyEventStore::ROM::EventRepository\#initialize \
40
40
  SUBJECT ?= RubyEventStore::ROM*
41
41
  DATABASE_URL ?= sqlite::memory:
42
42
 
43
- install: ## Install gem dependencies
44
- @echo "Installing gem dependencies"
45
- @bundle install
46
-
47
- remove-lock:
48
- @echo "Removing resolved dependency versions"
49
- -rm Gemfile.lock
50
-
51
- reinstall: remove-lock install ## Removing resolved dependency versions
52
-
53
- test: ## Run unit tests
54
- @echo "Running unit tests"
55
- @bundle exec rspec
56
-
57
- test-fast: ## Run unit tests with --fail-fast
58
- @echo "Running unit tests with --fail-fast"
59
- @bundle exec rspec --fail-fast --order defined --backtrace
60
-
61
- mutate: test ## Run mutation tests
62
- @echo "Running mutation tests"
63
- @MUTATING=true DATABASE_URL=$(DATABASE_URL) bundle exec mutant --include lib \
64
- $(addprefix --require ,$(REQUIRE)) \
65
- $(addprefix --ignore-subject ,$(IGNORE)) \
66
- --use rspec "$(SUBJECT)"
67
-
68
- mutate-fast: ## Run mutation tests with --fail-fast
69
- @echo "Running mutation tests with --fail-fast"
70
- @MUTATING=true DATABASE_URL=$(DATABASE_URL) bundle exec mutant --include lib \
71
- $(addprefix --require ,$(REQUIRE)) \
72
- $(addprefix --ignore-subject ,$(IGNORE)) \
73
- --fail-fast \
74
- --use rspec "$(SUBJECT)"
75
-
76
- build:
77
- @echo "Building gem package"
78
- @gem build -V $(GEM_NAME).gemspec
79
- @mkdir -p pkg/
80
- @mv $(GEM_NAME)-$(GEM_VERSION).gem pkg/
81
-
82
- push:
83
- @echo "Pushing package to RubyGems"
84
- @gem push -k dev_arkency pkg/$(GEM_NAME)-$(GEM_VERSION).gem
85
-
86
- clean:
87
- @echo "Removing previously built package"
88
- -rm pkg/$(GEM_NAME)-$(GEM_VERSION).gem
89
-
90
- help:
91
- @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
92
-
93
- .PHONY: help
94
- .DEFAULT_GOAL := help
95
-
43
+ include ../lib/install.mk
44
+ include ../lib/test.mk
45
+ include ../lib/mutant.mk
46
+ include ../lib/gem.mk
47
+ include ../lib/help.mk
@@ -81,6 +81,12 @@ module RubyEventStore
81
81
  @events.read(specification)
82
82
  end
83
83
 
84
+ def count(specification)
85
+ raise ReservedInternalName if specification.stream.name.eql?(@stream_entries.stream_entries.class::SERIALIZED_GLOBAL_STREAM_NAME)
86
+
87
+ @events.count(specification)
88
+ end
89
+
84
90
  def streams_of(event_id)
85
91
  @stream_entries.streams_of(event_id)
86
92
  .map{|name| Stream.new(name)}
@@ -42,29 +42,15 @@ module RubyEventStore
42
42
  end
43
43
 
44
44
  def read(specification)
45
- unless specification.head?
46
- offset_entry_id = stream_entries.by_stream_and_event_id(specification.stream, specification.start).fetch(:id)
47
- end
48
-
49
- direction = specification.forward? ? :forward : :backward
50
-
51
- limit = specification.limit if specification.limit?
52
-
53
- if specification.last? && specification.head?
54
- direction = specification.forward? ? :backward : :forward
55
- end
56
-
57
- query = stream_entries.ordered(direction, specification.stream, offset_entry_id)
58
-
59
- query = query.by_event_id(specification.with_ids) if specification.with_ids
60
- query = query.by_event_type(specification.with_types) if specification.with_types?
45
+ query = read_scope(specification)
61
46
 
62
47
  if specification.batched?
63
48
  reader = ->(offset, limit) do
64
49
  query_builder(query, offset: offset, limit: limit).to_ary
65
50
  end
66
- BatchEnumerator.new(specification.batch_size, limit || Float::INFINITY, reader).each
51
+ BatchEnumerator.new(specification.batch_size, specification.limit, reader).each
67
52
  else
53
+ limit = specification.limit if specification.limit?
68
54
  query = query_builder(query, limit: limit)
69
55
  if specification.head?
70
56
  specification.first? || specification.last? ? query.first : query.each
@@ -78,8 +64,32 @@ module RubyEventStore
78
64
  end
79
65
  end
80
66
 
67
+ def count(specification)
68
+ query = read_scope(specification)
69
+ query = query.take(specification.limit) if specification.limit?
70
+ query.count
71
+ end
72
+
81
73
  protected
82
74
 
75
+ def read_scope(specification)
76
+ unless specification.head?
77
+ offset_entry_id = stream_entries.by_stream_and_event_id(specification.stream, specification.start).fetch(:id)
78
+ end
79
+
80
+ direction = specification.forward? ? :forward : :backward
81
+
82
+ if specification.last? && specification.head?
83
+ direction = specification.forward? ? :backward : :forward
84
+ end
85
+
86
+ query = stream_entries.ordered(direction, specification.stream, offset_entry_id)
87
+
88
+ query = query.by_event_id(specification.with_ids) if specification.with_ids
89
+ query = query.by_event_type(specification.with_types) if specification.with_types?
90
+ query
91
+ end
92
+
83
93
  def query_builder(query, offset: nil, limit: nil)
84
94
  query = query.offset(offset) if offset
85
95
  query = query.take(limit) if limit
@@ -1,5 +1,5 @@
1
1
  module RubyEventStore
2
2
  module ROM
3
- VERSION = "0.34.0"
3
+ VERSION = "0.35.0"
4
4
  end
5
5
  end
@@ -59,6 +59,8 @@ module RubyEventStore::ROM
59
59
  expect{ repository.read(specification.stream("all").backward.result) }.to raise_error(RubyEventStore::ReservedInternalName)
60
60
  expect{ repository.read(specification.stream("all").from(:head).limit(5).result) }.to raise_error(RubyEventStore::ReservedInternalName)
61
61
  expect{ repository.read(specification.stream("all").from(:head).limit(5).backward.result) }.to raise_error(RubyEventStore::ReservedInternalName)
62
+
63
+ expect{ repository.count(specification.stream("all").result) }.to raise_error(RubyEventStore::ReservedInternalName)
62
64
  end
63
65
 
64
66
  specify "explicit sorting by position rather than accidental" do
@@ -25,18 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ['lib']
27
27
 
28
- spec.add_development_dependency 'bundler', '~> 1.15'
29
- spec.add_development_dependency 'rake', '~> 10.0'
30
- spec.add_development_dependency 'rspec', '~> 3.6'
31
- spec.add_development_dependency 'sqlite3', '1.3.13'
32
- spec.add_development_dependency 'pg', '>= 0.21'
33
- spec.add_development_dependency 'mysql2', '>= 0.4.10'
34
- spec.add_development_dependency 'mutant-rspec', '>= 0.8.14'
35
- spec.add_development_dependency 'fakefs', '~> 0.11.2'
36
- spec.add_development_dependency 'childprocess'
37
- spec.add_development_dependency 'google-protobuf', '~> 3.5.1.2'
38
-
39
- spec.add_dependency 'ruby_event_store', '= 0.34.0'
28
+ spec.add_dependency 'ruby_event_store', '= 0.35.0'
40
29
  spec.add_dependency 'sequel', '>= 4.49'
41
30
  spec.add_dependency 'dry-types', '~> 0.12.2'
42
31
  spec.add_dependency 'dry-initializer', '= 2.5.0'
metadata CHANGED
@@ -1,169 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_event_store-rom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.34.0
4
+ version: 0.35.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Van Horn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-23 00:00:00.000000000 Z
11
+ date: 2018-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.15'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.15'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '10.0'
41
- - !ruby/object:Gem::Dependency
42
- name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '3.6'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '3.6'
55
- - !ruby/object:Gem::Dependency
56
- name: sqlite3
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - '='
60
- - !ruby/object:Gem::Version
61
- version: 1.3.13
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '='
67
- - !ruby/object:Gem::Version
68
- version: 1.3.13
69
- - !ruby/object:Gem::Dependency
70
- name: pg
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0.21'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0.21'
83
- - !ruby/object:Gem::Dependency
84
- name: mysql2
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: 0.4.10
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: 0.4.10
97
- - !ruby/object:Gem::Dependency
98
- name: mutant-rspec
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: 0.8.14
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: 0.8.14
111
- - !ruby/object:Gem::Dependency
112
- name: fakefs
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: 0.11.2
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: 0.11.2
125
- - !ruby/object:Gem::Dependency
126
- name: childprocess
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: google-protobuf
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: 3.5.1.2
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: 3.5.1.2
153
13
  - !ruby/object:Gem::Dependency
154
14
  name: ruby_event_store
155
15
  requirement: !ruby/object:Gem::Requirement
156
16
  requirements:
157
17
  - - '='
158
18
  - !ruby/object:Gem::Version
159
- version: 0.34.0
19
+ version: 0.35.0
160
20
  type: :runtime
161
21
  prerelease: false
162
22
  version_requirements: !ruby/object:Gem::Requirement
163
23
  requirements:
164
24
  - - '='
165
25
  - !ruby/object:Gem::Version
166
- version: 0.34.0
26
+ version: 0.35.0
167
27
  - !ruby/object:Gem::Dependency
168
28
  name: sequel
169
29
  requirement: !ruby/object:Gem::Requirement