ruby_event_store-rom 0.36.0 → 0.37.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: b0657b44931013a36c0db15e739957207921bc1344dceffd3046c6ab7636de06
4
- data.tar.gz: 52a47bed2d4bd98d83928a28f26e85446b7c1ee3cf574f30cbe773dd8ca08071
3
+ metadata.gz: cdb72faeabaf9d243e4007d4f178255d256e2539ed233ee64759040d2a7b164b
4
+ data.tar.gz: ed46bc64d97dd849acdcec553de83579b47ef82c519343c768604316cc6c600e
5
5
  SHA512:
6
- metadata.gz: 89d84ef8613d86632e570c0179ee3ef273eecd73c0f0e9779e237b0512c0d7690a44a958e5feccf34191bbbfddd10d4f479a520d96d450bf40506483db6a398a
7
- data.tar.gz: bc6bfc3cc17b4568b172f15eae603a888d0dcdfbd019a5b5b9620cde86a09c5f1511dbe7ee96611674fa6e175a0008ee59554ce90f3bdefba3fe3ab8f61706f0
6
+ metadata.gz: 50945fc17724bcb456eea6eed14eee8bac87fde62f0c04c8d65d383ba3fb5b5bca12daedb96f25bcde517d09dbf016a0bf5b63d810b1f52fb3f4de2cd07fb9a8
7
+ data.tar.gz: 07a8991a92e9be43e93eebdcd9b70d88c454d13f2cb0a34e285ea7018b659d05c2b2ed0491ed197cb38e2759398d6a2623c8e118899311581b23b7ce734ab3fc
@@ -65,12 +65,12 @@ module RubyEventStore
65
65
  end
66
66
 
67
67
  DIRECTION_MAP = {
68
- forward: [false, :>],
69
- backward: [true, :<]
68
+ forward: [false, :>, :<],
69
+ backward: [true, :<, :>]
70
70
  }.freeze
71
71
 
72
- def ordered(direction, stream, offset_entry_id = nil)
73
- reverse, operator = DIRECTION_MAP[direction]
72
+ def ordered(direction, stream, offset_entry_id = nil, stop_entry_id = nil)
73
+ reverse, operator_offset, operator_stop = DIRECTION_MAP[direction]
74
74
 
75
75
  raise ArgumentError, 'Direction must be :forward or :backward' if order.nil?
76
76
 
@@ -78,7 +78,8 @@ module RubyEventStore
78
78
  order_columns.delete(:position) if stream.global?
79
79
 
80
80
  query = by_stream(stream)
81
- query = query.restrict { |tuple| tuple[:id].public_send(operator, offset_entry_id) } if offset_entry_id
81
+ query = query.restrict { |tuple| tuple[:id].public_send(operator_offset, offset_entry_id) } if offset_entry_id
82
+ query = query.restrict { |tuple| tuple[:id].public_send(operator_stop, stop_entry_id) } if stop_entry_id
82
83
  query = query.order(*order_columns)
83
84
  query = new(query.dataset.reverse) if reverse
84
85
 
@@ -40,12 +40,12 @@ module RubyEventStore
40
40
  end
41
41
 
42
42
  DIRECTION_MAP = {
43
- forward: %i[asc >],
44
- backward: %i[desc <]
43
+ forward: %i[asc > <],
44
+ backward: %i[desc < >]
45
45
  }.freeze
46
46
 
47
- def ordered(direction, stream, offset_entry_id = nil)
48
- order, operator = DIRECTION_MAP[direction]
47
+ def ordered(direction, stream, offset_entry_id = nil, stop_entry_id = nil)
48
+ order, operator_offset, operator_stop = DIRECTION_MAP[direction]
49
49
 
50
50
  raise ArgumentError, 'Direction must be :forward or :backward' if order.nil?
51
51
 
@@ -53,7 +53,8 @@ module RubyEventStore
53
53
  order_columns.delete(:position) if stream.global?
54
54
 
55
55
  query = by_stream(stream)
56
- query = query.where { id.public_send(operator, offset_entry_id) } if offset_entry_id
56
+ query = query.where { id.public_send(operator_offset, offset_entry_id) } if offset_entry_id
57
+ query = query.where { id.public_send(operator_stop, stop_entry_id) } if stop_entry_id
57
58
  query.order { |r| order_columns.map { |c| r[:stream_entries][c].public_send(order) } }
58
59
  end
59
60
 
@@ -18,7 +18,7 @@ module RubyEventStore
18
18
  end
19
19
 
20
20
  def append_to_stream(events, stream, expected_version)
21
- events = normalize_to_array(events)
21
+ events = Array(events)
22
22
  event_ids = events.map(&:event_id)
23
23
 
24
24
  guard_for(:unique_violation) do
@@ -41,7 +41,7 @@ module RubyEventStore
41
41
  end
42
42
 
43
43
  def link_to_stream(event_ids, stream, expected_version)
44
- event_ids = normalize_to_array(event_ids)
44
+ event_ids = Array(event_ids)
45
45
 
46
46
  # Validate event IDs
47
47
  @events
@@ -100,14 +100,6 @@ module RubyEventStore
100
100
  @stream_entries.streams_of(event_id)
101
101
  .map { |name| Stream.new(name) }
102
102
  end
103
-
104
- private
105
-
106
- def normalize_to_array(events)
107
- return events if events.is_a?(Enumerable)
108
-
109
- [events]
110
- end
111
103
  end
112
104
  end
113
105
  end
@@ -45,7 +45,7 @@ module RubyEventStore
45
45
  ).each
46
46
  else
47
47
  query = query_builder(query, limit: (specification.limit if specification.limit?))
48
- if specification.head?
48
+ if specification.head? && !specification.stop
49
49
  specification.first? || specification.last? ? query.first : query.each
50
50
  elsif specification.last?
51
51
  query.to_ary.last
@@ -65,14 +65,15 @@ module RubyEventStore
65
65
 
66
66
  def read_scope(specification)
67
67
  offset_entry_id = stream_entries.by_stream_and_event_id(specification.stream, specification.start).fetch(:id) unless specification.head?
68
+ stop_entry_id = stream_entries.by_stream_and_event_id(specification.stream, specification.stop).fetch(:id) if specification.stop
68
69
 
69
70
  direction = specification.forward? ? :forward : :backward
70
71
 
71
- if specification.last? && specification.head?
72
+ if specification.last? && specification.head? && !specification.stop
72
73
  direction = specification.forward? ? :backward : :forward
73
74
  end
74
75
 
75
- query = stream_entries.ordered(direction, specification.stream, offset_entry_id)
76
+ query = stream_entries.ordered(direction, specification.stream, offset_entry_id, stop_entry_id)
76
77
  query = query.by_event_id(specification.with_ids) if specification.with_ids
77
78
  query = query.by_event_type(specification.with_types) if specification.with_types?
78
79
  query
@@ -1,5 +1,5 @@
1
1
  module RubyEventStore
2
2
  module ROM
3
- VERSION = "0.36.0"
3
+ VERSION = "0.37.0"
4
4
  end
5
5
  end
@@ -15,8 +15,6 @@ module RubyEventStore::ROM
15
15
 
16
16
  let(:test_race_conditions_auto) { rom_helper.has_connection_pooling? }
17
17
  let(:test_race_conditions_any) { rom_helper.has_connection_pooling? }
18
- let(:test_expected_version_auto) { true }
19
- let(:test_link_events_to_stream) { true }
20
18
  let(:test_binary) { false }
21
19
  let(:test_change) { rom_helper.supports_upsert? }
22
20
 
@@ -27,7 +25,8 @@ module RubyEventStore::ROM
27
25
  let(:reader) { RubyEventStore::SpecificationReader.new(repository, mapper) }
28
26
  let(:specification) { RubyEventStore::Specification.new(reader) }
29
27
 
30
- it_behaves_like :event_repository, repository_class
28
+ require 'ruby_event_store/rom/sql'
29
+ it_behaves_like :event_repository, repository_class, [ROM::SQL::Error]
31
30
 
32
31
  specify '#initialize requires ROM::Env' do
33
32
  expect { repository_class.new(rom: nil) }.to raise_error do |err|
@@ -26,9 +26,10 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_dependency 'dry-initializer', '= 2.5.0'
28
28
  spec.add_dependency 'dry-types', '~> 0.12.2'
29
+ spec.add_dependency 'dry-container', '< 0.7.0'
29
30
  spec.add_dependency 'rom-changeset', '>= 1.0'
30
31
  spec.add_dependency 'rom-repository', '>= 2.0'
31
32
  spec.add_dependency 'rom-sql', '>= 2.4'
32
- spec.add_dependency 'ruby_event_store', '= 0.36.0'
33
+ spec.add_dependency 'ruby_event_store', '= 0.37.0'
33
34
  spec.add_dependency 'sequel', '>= 5.11.0'
34
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_event_store-rom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.36.0
4
+ version: 0.37.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: 2019-01-22 00:00:00.000000000 Z
11
+ date: 2019-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-initializer
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.12.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: dry-container
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "<"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.7.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "<"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.7.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rom-changeset
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +100,14 @@ dependencies:
86
100
  requirements:
87
101
  - - '='
88
102
  - !ruby/object:Gem::Version
89
- version: 0.36.0
103
+ version: 0.37.0
90
104
  type: :runtime
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - '='
95
109
  - !ruby/object:Gem::Version
96
- version: 0.36.0
110
+ version: 0.37.0
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: sequel
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -182,7 +196,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
196
  - !ruby/object:Gem::Version
183
197
  version: '0'
184
198
  requirements: []
185
- rubygems_version: 3.0.2
199
+ rubyforge_project:
200
+ rubygems_version: 2.7.6
186
201
  signing_key:
187
202
  specification_version: 4
188
203
  summary: ROM events repository for Ruby Event Store