ruby_event_store-rom 0.39.0 → 0.40.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: '09d23ab19b18dde2c940ff44c4e801bd947dcd3b0084f1952ebb3e841c08764f'
4
- data.tar.gz: 3b4a6944ee281dd7a19db514493f4854db851c3df5423309921247620c8378db
3
+ metadata.gz: 93e5cd45e5a2b089e08face73b1208bea7372beccea31eeb5a93853daaa0c3af
4
+ data.tar.gz: c5140402ae0991b2659b90b4f58e8b907e84fcb4a3cb55c6e9b5edf76ce1aeb2
5
5
  SHA512:
6
- metadata.gz: bb6329728b35a4ead04583b6a9e4826b872253373931651b8421a0198917a2cea3a27365e5d401258579384d51b4901ada69f6439a4e8be5f33967377b6454fd
7
- data.tar.gz: c8f94b6a130ba920b2391eac4548bcc6a384cbee518b13aee954a56bfb459ebe9a2daf98d3bff005278df10484713e45813383ca57a499bf2d81035577737751
6
+ metadata.gz: b45bdc9846968d2d34250bdce821c2dbeeb381651ef62e35ddfa4f4eb31def75746c744ee6f6b9518dcf68663b23947a34bb5de059147653efd94c53286285fc
7
+ data.tar.gz: a0ad08b7f19f8854a0e25271897ea1ec418cb66baa5003c329df7aedbfae8bd6bd3567e1c07264c975d0eefd44fb5dfe12d533bcb93ea60b16cf268d93fad0e1
@@ -1,5 +1,4 @@
1
1
  require 'rom-changeset'
2
- require 'rom-mapper'
3
2
  require 'rom-repository'
4
3
  require 'ruby_event_store'
5
4
  require 'ruby_event_store/rom/types'
@@ -14,40 +13,43 @@ require 'ruby_event_store/rom/version'
14
13
  module RubyEventStore
15
14
  module ROM
16
15
  class Env
17
- attr_accessor :container
16
+ include Dry::Container::Mixin
18
17
 
19
- def initialize(container)
20
- @container = container
18
+ attr_accessor :rom_container
21
19
 
22
- container.register(:unique_violation_error_handlers, Set.new)
23
- container.register(:not_found_error_handlers, Set.new)
24
- container.register(:logger, Logger.new(STDOUT).tap { |logger| logger.level = Logger::WARN })
20
+ def initialize(rom_container)
21
+ @rom_container = rom_container
22
+
23
+ register(:unique_violation_error_handlers, Set.new)
24
+ register(:not_found_error_handlers, Set.new)
25
+ register(:logger, Logger.new(STDOUT).tap { |logger| logger.level = Logger::WARN })
25
26
  end
26
27
 
27
28
  def logger
28
- container[:logger]
29
+ resolve(:logger)
29
30
  end
30
31
 
31
32
  def unit_of_work(&block)
32
- options = container[:unit_of_work_options].dup
33
+ options = resolve(:unit_of_work_options).dup
33
34
  options.delete(:class) { UnitOfWork }.new(rom: self).call(**options, &block)
34
35
  end
35
36
 
36
37
  def register_unit_of_work_options(options)
37
- container.register(:unit_of_work_options, options)
38
+ register(:unit_of_work_options, options)
38
39
  end
39
40
 
40
41
  def register_error_handler(type, handler)
41
- container[:"#{type}_error_handlers"] << handler
42
+ resolve(:"#{type}_error_handlers") << handler
42
43
  end
43
44
 
44
45
  def handle_error(type, *args, swallow: [])
45
46
  yield
46
- rescue StandardError => ex
47
+ rescue StandardError => e
47
48
  begin
48
- container[:"#{type}_error_handlers"].each { |h| h.call(ex, *args) }
49
- raise ex
49
+ resolve(:"#{type}_error_handlers").each { |h| h.call(e, *args) }
50
+ raise e
50
51
  rescue *swallow
52
+ # swallow
51
53
  end
52
54
  end
53
55
  end
@@ -94,7 +96,7 @@ module RubyEventStore
94
96
  end
95
97
  }
96
98
 
97
- find_adapters(env.container.gateways).each do |adapter|
99
+ find_adapters(env.rom_container.gateways).each do |adapter|
98
100
  adapter.configure(env)
99
101
  end
100
102
  end
@@ -4,9 +4,9 @@ module RubyEventStore
4
4
  module Relations
5
5
  class StreamEntries < ::ROM::Relation[:memory]
6
6
  schema(:stream_entries) do
7
- attribute(:id, ::ROM::Types::Strict::Int.meta(primary_key: true).default { RubyEventStore::ROM::Memory.fetch_next_id })
7
+ attribute(:id, ::ROM::Types::Strict::Integer.meta(primary_key: true).default { RubyEventStore::ROM::Memory.fetch_next_id })
8
8
  attribute :stream, ::ROM::Types::Strict::String
9
- attribute :position, ::ROM::Types::Strict::Int.optional
9
+ attribute :position, ::ROM::Types::Strict::Integer.optional
10
10
  attribute :event_id, ::ROM::Types::Strict::String.meta(foreign_key: true, relation: :events)
11
11
  attribute :created_at, RubyEventStore::ROM::Types::DateTime
12
12
 
@@ -13,7 +13,7 @@ module RubyEventStore
13
13
  begin
14
14
  until changesets.empty?
15
15
  changeset = changesets.shift
16
- relation = env.container.relations[changeset.relation.name]
16
+ relation = env.rom_container.relations[changeset.relation.name]
17
17
 
18
18
  committed << [changeset, relation]
19
19
 
@@ -5,7 +5,7 @@ module RubyEventStore
5
5
  class UpdateEvents < ::ROM::Changeset::Create
6
6
  include ROM::Changesets::UpdateEvents::Defaults
7
7
 
8
- UPSERT_COLUMNS = %i[event_type data metadata created_at]
8
+ UPSERT_COLUMNS = %i[event_type data metadata created_at].freeze
9
9
 
10
10
  def commit
11
11
  if SQL.supports_on_duplicate_key_update?(relation.dataset.db)
@@ -5,7 +5,7 @@ MIGRATIONS_PATH = 'db/migrate'.freeze
5
5
  desc 'Setup ROM EventRespository environment'
6
6
  task 'db:setup' do
7
7
  Dir.chdir(Dir.pwd)
8
- ROM::SQL::RakeSupport.env = ::RubyEventStore::ROM.configure(:sql).container
8
+ ROM::SQL::RakeSupport.env = ::RubyEventStore::ROM.configure(:sql).rom_container
9
9
  end
10
10
 
11
11
  desc 'Copy RubyEventStore SQL migrations to db/migrate'
@@ -13,8 +13,8 @@ module RubyEventStore
13
13
  raise ArgumentError, 'Must specify rom' unless rom && rom.instance_of?(Env)
14
14
 
15
15
  @rom = rom
16
- @events = Repositories::Events.new(rom.container)
17
- @stream_entries = Repositories::StreamEntries.new(rom.container)
16
+ @events = Repositories::Events.new(rom.rom_container)
17
+ @stream_entries = Repositories::StreamEntries.new(rom.rom_container)
18
18
  end
19
19
 
20
20
  def append_to_stream(events, stream, expected_version)
@@ -52,7 +52,7 @@ module RubyEventStore
52
52
  end
53
53
 
54
54
  def gateway
55
- env.container.gateways.fetch(:default)
55
+ env.rom_container.gateways.fetch(:default)
56
56
  end
57
57
 
58
58
  def drop_gateway_schema
@@ -63,7 +63,7 @@ module RubyEventStore
63
63
 
64
64
  def supports_upsert?(db)
65
65
  supports_on_duplicate_key_update?(db) ||
66
- supports_insert_conflict_update?(db)
66
+ supports_insert_conflict_update?(db)
67
67
  end
68
68
 
69
69
  def supports_on_duplicate_key_update?(db)
@@ -76,7 +76,7 @@ module RubyEventStore
76
76
  true
77
77
  when :sqlite
78
78
  # Sqlite 3.24.0+ supports PostgreSQL upsert syntax
79
- db.sqlite_version >= 32400
79
+ db.sqlite_version >= 32_400
80
80
  else
81
81
  false
82
82
  end
@@ -91,7 +91,7 @@ module RubyEventStore
91
91
  :sql,
92
92
  database_uri,
93
93
  max_connections: database_uri =~ /sqlite/ ? 1 : 5,
94
- preconnect: :concurrently,
94
+ preconnect: :concurrently
95
95
  # sql_mode: %w[NO_AUTO_VALUE_ON_ZERO STRICT_ALL_TABLES]
96
96
  )
97
97
  # $stdout.sync = true
@@ -113,7 +113,7 @@ module RubyEventStore
113
113
  end
114
114
 
115
115
  def gateway
116
- env.container.gateways.fetch(:default)
116
+ env.rom_container.gateways.fetch(:default)
117
117
  end
118
118
 
119
119
  def gateway_type?(name)
@@ -2,7 +2,16 @@ module RubyEventStore
2
2
  module ROM
3
3
  module Types
4
4
  DateTime = ::ROM::Types::DateTime
5
- .constructor { |value| value.is_a?(::String) ? ::DateTime.iso8601(value) : value }
5
+ .constructor do |value|
6
+ case value
7
+ when nil
8
+ Dry::Core::Constants::Undefined
9
+ when ::String
10
+ ::DateTime.iso8601(value)
11
+ else
12
+ value
13
+ end
14
+ end
6
15
  .default { ::DateTime.now.new_offset(0) }
7
16
 
8
17
  SerializedRecordSerializer = ::ROM::Types::String
@@ -8,7 +8,7 @@ module RubyEventStore
8
8
  end
9
9
 
10
10
  def call(**options)
11
- gateway = @env.container.gateways.fetch(options.delete(:gateway) { :default })
11
+ gateway = @env.rom_container.gateways.fetch(options.delete(:gateway) { :default })
12
12
 
13
13
  yield(changesets = [])
14
14
 
@@ -1,5 +1,5 @@
1
1
  module RubyEventStore
2
2
  module ROM
3
- VERSION = "0.39.0"
3
+ VERSION = "0.40.0"
4
4
  end
5
5
  end
@@ -6,8 +6,8 @@ module RubyEventStore::ROM
6
6
  subject(:repository) { repository_class.new(rom: env) }
7
7
 
8
8
  let(:env) { rom_helper.env }
9
- let(:container) { env.container }
10
- let(:rom_db) { container.gateways[:default] }
9
+ let(:rom_container) { env.rom_container }
10
+ let(:rom_db) { rom_container.gateways[:default] }
11
11
 
12
12
  around(:each) do |example|
13
13
  rom_helper.run_lifecycle { example.run }
@@ -68,7 +68,7 @@ module RubyEventStore::ROM
68
68
  RubyEventStore::SRecord.new(event_id: u3 = SecureRandom.uuid)
69
69
  ]
70
70
 
71
- repo = Repositories::Events.new(container)
71
+ repo = Repositories::Events.new(rom_container)
72
72
  repo.create_changeset(events).commit
73
73
 
74
74
  expect(repo.events.to_a.size).to eq(3)
@@ -100,7 +100,7 @@ module RubyEventStore::ROM
100
100
  RubyEventStore::SRecord.new(event_id: u3 = SecureRandom.uuid)
101
101
  ]
102
102
 
103
- repo = Repositories::Events.new(container)
103
+ repo = Repositories::Events.new(rom_container)
104
104
  repo.create_changeset(events).commit
105
105
 
106
106
  expect(repo.events.to_a.size).to eq(3)
@@ -145,9 +145,9 @@ module RubyEventStore::ROM
145
145
 
146
146
  # TODO: Port from AR to ROM
147
147
  def additional_limited_concurrency_for_auto_check
148
- positions = container.relations[:stream_entries]
149
- .ordered(:forward, default_stream)
150
- .map { |entity| entity[:position] }
148
+ positions = rom_container.relations[:stream_entries]
149
+ .ordered(:forward, default_stream)
150
+ .map { |entity| entity[:position] }
151
151
  expect(positions).to eq((0..positions.size - 1).to_a)
152
152
  end
153
153
 
@@ -1,9 +1,9 @@
1
1
  RSpec.shared_examples :events_relation do |_relation_class|
2
- subject(:relation) { container.relations[:events] }
2
+ subject(:relation) { rom_container.relations[:events] }
3
3
 
4
4
  let(:env) { rom_helper.env }
5
- let(:container) { env.container }
6
- let(:rom_db) { container.gateways[:default] }
5
+ let(:rom_container) { env.rom_container }
6
+ let(:rom_db) { rom_container.gateways[:default] }
7
7
 
8
8
  around(:each) do |example|
9
9
  rom_helper.run_lifecycle { example.run }
@@ -1,9 +1,9 @@
1
1
  RSpec.shared_examples :stream_entries_relation do |_relation_class|
2
- subject(:relation) { container.relations[:stream_entries] }
2
+ subject(:relation) { rom_container.relations[:stream_entries] }
3
3
 
4
4
  let(:env) { rom_helper.env }
5
- let(:container) { env.container }
6
- let(:rom_db) { container.gateways[:default] }
5
+ let(:rom_container) { env.rom_container }
6
+ let(:rom_db) { rom_container.gateways[:default] }
7
7
 
8
8
  around(:each) do |example|
9
9
  rom_helper.run_lifecycle { example.run }
@@ -1,15 +1,15 @@
1
1
  module RubyEventStore::ROM
2
2
  RSpec.shared_examples :rom_spec_helper do |_rom_spec_helper_class|
3
3
  let(:env) { rom_helper.env }
4
- let(:container) { env.container }
5
- let(:rom_db) { container.gateways[:default] }
4
+ let(:rom_container) { env.rom_container }
5
+ let(:rom_db) { rom_container.gateways[:default] }
6
6
 
7
7
  around(:each) do |example|
8
8
  rom_helper.run_lifecycle { example.run }
9
9
  end
10
10
 
11
11
  specify '#env gives access to ROM container' do
12
- expect(subject.env.container).to be_a(::ROM::Container)
12
+ expect(subject.env.rom_container).to be_a(::ROM::Container)
13
13
  end
14
14
  end
15
15
  end
@@ -3,15 +3,15 @@ module RubyEventStore::ROM
3
3
  subject(:unit_of_work) { unit_of_work_class.new(rom: env) }
4
4
 
5
5
  let(:env) { rom_helper.env }
6
- let(:container) { env.container }
7
- let(:rom_db) { container.gateways[:default] }
6
+ let(:v) { env.rom_container }
7
+ let(:rom_db) { rom_container.gateways[:default] }
8
8
 
9
9
  around(:each) do |example|
10
10
  rom_helper.run_lifecycle { example.run }
11
11
  end
12
12
 
13
13
  specify '#env gives access to ROM container' do
14
- expect(subject.env.container).to be_a(::ROM::Container)
14
+ expect(subject.env.rom_container).to be_a(::ROM::Container)
15
15
  end
16
16
 
17
17
  specify '#call to throw an exeption' do
@@ -24,12 +24,14 @@ Gem::Specification.new do |spec|
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ['lib']
26
26
 
27
- spec.add_dependency 'dry-initializer', '= 2.5.0'
28
- spec.add_dependency 'dry-types', '~> 0.12.2'
29
- spec.add_dependency 'dry-container', '< 0.7.0'
30
- spec.add_dependency 'rom-changeset', '>= 1.0'
31
- spec.add_dependency 'rom-repository', '>= 2.0'
32
- spec.add_dependency 'rom-sql', '>= 2.4'
33
- spec.add_dependency 'ruby_event_store', '= 0.39.0'
27
+ spec.required_ruby_version = '>= 2.4'
28
+
29
+ spec.add_dependency 'dry-container', '>= 0.6'
30
+ spec.add_dependency 'dry-initializer', '>= 3.0'
31
+ spec.add_dependency 'dry-types', '>= 1.0'
32
+ spec.add_dependency 'rom-changeset', '>= 5.0'
33
+ spec.add_dependency 'rom-repository', '>= 5.0'
34
+ spec.add_dependency 'rom-sql', '>= 3.0'
35
+ spec.add_dependency 'ruby_event_store', '= 0.40.0'
34
36
  spec.add_dependency 'sequel', '>= 5.11.0'
35
37
  end
metadata CHANGED
@@ -1,113 +1,113 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_event_store-rom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.39.0
4
+ version: 0.40.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-04-24 00:00:00.000000000 Z
11
+ date: 2019-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: dry-initializer
14
+ name: dry-container
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 2.5.0
19
+ version: '0.6'
20
20
  type: :runtime
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: 2.5.0
26
+ version: '0.6'
27
27
  - !ruby/object:Gem::Dependency
28
- name: dry-types
28
+ name: dry-initializer
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.12.2
33
+ version: '3.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.12.2
40
+ version: '3.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: dry-container
42
+ name: dry-types
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "<"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 0.7.0
47
+ version: '1.0'
48
48
  type: :runtime
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.7.0
54
+ version: '1.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rom-changeset
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '1.0'
61
+ version: '5.0'
62
62
  type: :runtime
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: '1.0'
68
+ version: '5.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rom-repository
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '2.0'
75
+ version: '5.0'
76
76
  type: :runtime
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: '2.0'
82
+ version: '5.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rom-sql
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '2.4'
89
+ version: '3.0'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '2.4'
96
+ version: '3.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: ruby_event_store
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: 0.39.0
103
+ version: 0.40.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: 0.39.0
110
+ version: 0.40.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: sequel
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -189,14 +189,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
189
189
  requirements:
190
190
  - - ">="
191
191
  - !ruby/object:Gem::Version
192
- version: '0'
192
+ version: '2.4'
193
193
  required_rubygems_version: !ruby/object:Gem::Requirement
194
194
  requirements:
195
195
  - - ">="
196
196
  - !ruby/object:Gem::Version
197
197
  version: '0'
198
198
  requirements: []
199
- rubygems_version: 3.0.3
199
+ rubygems_version: 3.0.1
200
200
  signing_key:
201
201
  specification_version: 4
202
202
  summary: ROM events repository for Ruby Event Store