esse-active_record 0.2.0 → 0.2.1

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: 78a881c4b488d3a39ae25270bde1fc26444ba3369779257c385237933314e9c6
4
- data.tar.gz: 25e90b2d8820ab109a23812449b4fbd076081c843b3891ea1373977b48a85df6
3
+ metadata.gz: 1f0c8cdcc6995c22670eb1083dbccd260c76f5caa453e08b1cb8cc3c4cd3f6b8
4
+ data.tar.gz: 0f412a70e5a7f26fcede5aaf8c88017665d17bea11363be2ab3174882c6f1e07
5
5
  SHA512:
6
- metadata.gz: f9fba8e83ea38bae6667071fd9f416326af17227dc11061d41ae28305b35101d60babddd2ad8c02169876f673cf6cb712f68832f08d8b39dadbc448e2a0ae332
7
- data.tar.gz: 654fac3ac8f2eb1e52d977ee576a5565a0b3d9ce45ba239ab1fd0dd7a5c876ce42936f8270becfcbac6a7d12d82544bfcd7a7708f125bf76c9159ac9fc8ec6cd
6
+ metadata.gz: '079289f4c4bda72b3e97874775e8e1d32691d3a4f65d2412b155a9fbd8c71120b4e7596e14a6da0e44b5efc744c2522593fea7fc89f0533f11fbaa2de009bd20'
7
+ data.tar.gz: b1a7fe2d08f3eaee49595974efcad29d8da109504f71d9e1654db092a6e4391a23653814df892d77a9e50d45cb7a59f225b22ceffb1d28082cbeb8d292e1abc4
data/.rubocop.yml CHANGED
@@ -31,9 +31,6 @@ RSpec/MessageSpies:
31
31
  RSpec/FilePath:
32
32
  Enabled: false
33
33
 
34
- RSpec/SpecFilePathFormat:
35
- Enabled: false
36
-
37
34
  Layout/SpaceInsideHashLiteralBraces:
38
35
  Enabled: false
39
36
 
@@ -49,3 +46,6 @@ Style/TrailingCommaInHashLiteral:
49
46
  Style/StringLiterals:
50
47
  Enabled: true
51
48
  EnforcedStyle: single_quotes
49
+
50
+ RSpec/MultipleMemoizedHelpers:
51
+ Max: 10
data/Gemfile CHANGED
@@ -3,7 +3,7 @@
3
3
  source 'https://rubygems.org'
4
4
 
5
5
  gem 'esse', '~> 0.2.4'
6
- gem 'sqlite3', '~> 1.3.6'
6
+ gem 'sqlite3', '~> 1.7.3'
7
7
  gem 'activerecord', '~> 5.2'
8
8
  gem 'esse-rspec', '~> 0.0.6'
9
9
  gem 'elasticsearch', '~> 7.17', '>= 7.17.10'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- esse-active_record (0.2.0)
4
+ esse-active_record (0.2.1)
5
5
  activerecord (>= 4.2, < 8)
6
6
  esse (>= 0.2.3)
7
7
 
@@ -45,8 +45,6 @@ GEM
45
45
  esse-rspec (0.0.6)
46
46
  esse (>= 0.2.4)
47
47
  rspec (>= 3)
48
- factory_bot (6.2.0)
49
- activesupport (>= 5.0.0)
50
48
  faraday (2.8.1)
51
49
  base64
52
50
  faraday-net_http (>= 2.0, < 3.1)
@@ -59,6 +57,7 @@ GEM
59
57
  language_server-protocol (3.17.0.3)
60
58
  lint_roller (1.1.0)
61
59
  method_source (1.0.0)
60
+ mini_portile2 (2.8.7)
62
61
  minitest (5.21.2)
63
62
  multi_json (1.15.0)
64
63
  parallel (1.24.0)
@@ -109,7 +108,8 @@ GEM
109
108
  rubocop-capybara (~> 2.17)
110
109
  ruby-progressbar (1.13.0)
111
110
  ruby2_keywords (0.0.5)
112
- sqlite3 (1.3.13)
111
+ sqlite3 (1.7.3)
112
+ mini_portile2 (~> 2.8.0)
113
113
  standard (1.28.5)
114
114
  language_server-protocol (~> 3.17.0.2)
115
115
  lint_roller (~> 1.0)
@@ -145,14 +145,13 @@ DEPENDENCIES
145
145
  esse (~> 0.2.4)
146
146
  esse-active_record!
147
147
  esse-rspec (~> 0.0.6)
148
- factory_bot
149
148
  pry
150
149
  rake
151
150
  rspec
152
151
  rubocop
153
152
  rubocop-performance
154
153
  rubocop-rspec
155
- sqlite3 (~> 1.3.6)
154
+ sqlite3 (~> 1.7.3)
156
155
  standard
157
156
  webmock
158
157
  yard
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- esse-active_record (0.2.0)
4
+ esse-active_record (0.2.1)
5
5
  activerecord (>= 4.2, < 8)
6
6
  esse (>= 0.2.3)
7
7
 
@@ -157,4 +157,4 @@ DEPENDENCIES
157
157
  yard
158
158
 
159
159
  BUNDLED WITH
160
- 2.3.21
160
+ 2.3.22
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- esse-active_record (0.2.0)
4
+ esse-active_record (0.2.1)
5
5
  activerecord (>= 4.2, < 8)
6
6
  esse (>= 0.2.3)
7
7
 
@@ -43,10 +43,8 @@ GEM
43
43
  esse-rspec (0.0.6)
44
44
  esse (>= 0.2.4)
45
45
  rspec (>= 3)
46
- faraday (2.9.0)
47
- faraday-net_http (>= 2.0, < 3.2)
48
- faraday-net_http (3.1.0)
49
- net-http
46
+ faraday (2.0.0)
47
+ ruby2_keywords (>= 0.0.4)
50
48
  hashdiff (1.1.0)
51
49
  i18n (1.14.1)
52
50
  concurrent-ruby (~> 1.0)
@@ -54,10 +52,9 @@ GEM
54
52
  language_server-protocol (3.17.0.3)
55
53
  lint_roller (1.1.0)
56
54
  method_source (1.0.0)
55
+ mini_portile2 (2.8.7)
57
56
  minitest (5.21.2)
58
57
  multi_json (1.15.0)
59
- net-http (0.4.1)
60
- uri
61
58
  parallel (1.24.0)
62
59
  parser (3.3.0.5)
63
60
  ast (~> 2.4.1)
@@ -109,7 +106,9 @@ GEM
109
106
  rubocop-capybara (~> 2.17)
110
107
  rubocop-factory_bot (~> 2.22)
111
108
  ruby-progressbar (1.13.0)
112
- sqlite3 (1.7.0-x86_64-linux)
109
+ ruby2_keywords (0.0.5)
110
+ sqlite3 (1.7.3)
111
+ mini_portile2 (~> 2.8.0)
113
112
  standard (1.33.0)
114
113
  language_server-protocol (~> 3.17.0.2)
115
114
  lint_roller (~> 1.0)
@@ -126,7 +125,6 @@ GEM
126
125
  tzinfo (2.0.6)
127
126
  concurrent-ruby (~> 1.0)
128
127
  unicode-display_width (2.5.0)
129
- uri (0.13.0)
130
128
  webmock (3.19.1)
131
129
  addressable (>= 2.8.0)
132
130
  crack (>= 0.3.2)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- esse-active_record (0.2.0)
4
+ esse-active_record (0.2.1)
5
5
  activerecord (>= 4.2, < 8)
6
6
  esse (>= 0.2.3)
7
7
 
@@ -43,10 +43,8 @@ GEM
43
43
  esse-rspec (0.0.6)
44
44
  esse (>= 0.2.4)
45
45
  rspec (>= 3)
46
- faraday (2.9.0)
47
- faraday-net_http (>= 2.0, < 3.2)
48
- faraday-net_http (3.1.0)
49
- net-http
46
+ faraday (2.0.0)
47
+ ruby2_keywords (>= 0.0.4)
50
48
  hashdiff (1.1.0)
51
49
  i18n (1.14.1)
52
50
  concurrent-ruby (~> 1.0)
@@ -54,10 +52,9 @@ GEM
54
52
  language_server-protocol (3.17.0.3)
55
53
  lint_roller (1.1.0)
56
54
  method_source (1.0.0)
55
+ mini_portile2 (2.8.7)
57
56
  minitest (5.21.2)
58
57
  multi_json (1.15.0)
59
- net-http (0.4.1)
60
- uri
61
58
  parallel (1.24.0)
62
59
  parser (3.3.0.5)
63
60
  ast (~> 2.4.1)
@@ -109,7 +106,9 @@ GEM
109
106
  rubocop-capybara (~> 2.17)
110
107
  rubocop-factory_bot (~> 2.22)
111
108
  ruby-progressbar (1.13.0)
112
- sqlite3 (1.7.0-x86_64-linux)
109
+ ruby2_keywords (0.0.5)
110
+ sqlite3 (1.7.3)
111
+ mini_portile2 (~> 2.8.0)
113
112
  standard (1.33.0)
114
113
  language_server-protocol (~> 3.17.0.2)
115
114
  lint_roller (~> 1.0)
@@ -126,7 +125,6 @@ GEM
126
125
  tzinfo (2.0.6)
127
126
  concurrent-ruby (~> 1.0)
128
127
  unicode-display_width (2.5.0)
129
- uri (0.13.0)
130
128
  webmock (3.19.1)
131
129
  addressable (>= 2.8.0)
132
130
  crack (>= 0.3.2)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- esse-active_record (0.2.0)
4
+ esse-active_record (0.2.1)
5
5
  activerecord (>= 4.2, < 8)
6
6
  esse (>= 0.2.3)
7
7
 
@@ -43,10 +43,8 @@ GEM
43
43
  esse-rspec (0.0.6)
44
44
  esse (>= 0.2.4)
45
45
  rspec (>= 3)
46
- faraday (2.9.0)
47
- faraday-net_http (>= 2.0, < 3.2)
48
- faraday-net_http (3.1.0)
49
- net-http
46
+ faraday (2.0.0)
47
+ ruby2_keywords (>= 0.0.4)
50
48
  hashdiff (1.1.0)
51
49
  i18n (1.14.1)
52
50
  concurrent-ruby (~> 1.0)
@@ -54,10 +52,9 @@ GEM
54
52
  language_server-protocol (3.17.0.3)
55
53
  lint_roller (1.1.0)
56
54
  method_source (1.0.0)
55
+ mini_portile2 (2.8.7)
57
56
  minitest (5.21.2)
58
57
  multi_json (1.15.0)
59
- net-http (0.4.1)
60
- uri
61
58
  parallel (1.24.0)
62
59
  parser (3.3.0.5)
63
60
  ast (~> 2.4.1)
@@ -109,7 +106,9 @@ GEM
109
106
  rubocop-capybara (~> 2.17)
110
107
  rubocop-factory_bot (~> 2.22)
111
108
  ruby-progressbar (1.13.0)
112
- sqlite3 (1.7.0-x86_64-linux)
109
+ ruby2_keywords (0.0.5)
110
+ sqlite3 (1.7.3)
111
+ mini_portile2 (~> 2.8.0)
113
112
  standard (1.33.0)
114
113
  language_server-protocol (~> 3.17.0.2)
115
114
  lint_roller (~> 1.0)
@@ -126,7 +125,6 @@ GEM
126
125
  tzinfo (2.0.6)
127
126
  concurrent-ruby (~> 1.0)
128
127
  unicode-display_width (2.5.0)
129
- uri (0.13.0)
130
128
  webmock (3.19.1)
131
129
  addressable (>= 2.8.0)
132
130
  crack (>= 0.3.2)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- esse-active_record (0.2.0)
4
+ esse-active_record (0.2.1)
5
5
  activerecord (>= 4.2, < 8)
6
6
  esse (>= 0.2.3)
7
7
 
@@ -53,10 +53,8 @@ GEM
53
53
  esse-rspec (0.0.6)
54
54
  esse (>= 0.2.4)
55
55
  rspec (>= 3)
56
- faraday (2.9.0)
57
- faraday-net_http (>= 2.0, < 3.2)
58
- faraday-net_http (3.1.0)
59
- net-http
56
+ faraday (2.0.0)
57
+ ruby2_keywords (>= 0.0.4)
60
58
  hashdiff (1.1.0)
61
59
  i18n (1.14.1)
62
60
  concurrent-ruby (~> 1.0)
@@ -64,11 +62,10 @@ GEM
64
62
  language_server-protocol (3.17.0.3)
65
63
  lint_roller (1.1.0)
66
64
  method_source (1.0.0)
65
+ mini_portile2 (2.8.7)
67
66
  minitest (5.21.2)
68
67
  multi_json (1.15.0)
69
68
  mutex_m (0.2.0)
70
- net-http (0.4.1)
71
- uri
72
69
  parallel (1.24.0)
73
70
  parser (3.3.0.5)
74
71
  ast (~> 2.4.1)
@@ -121,7 +118,8 @@ GEM
121
118
  rubocop-factory_bot (~> 2.22)
122
119
  ruby-progressbar (1.13.0)
123
120
  ruby2_keywords (0.0.5)
124
- sqlite3 (1.7.0-x86_64-linux)
121
+ sqlite3 (1.7.3)
122
+ mini_portile2 (~> 2.8.0)
125
123
  standard (1.33.0)
126
124
  language_server-protocol (~> 3.17.0.2)
127
125
  lint_roller (~> 1.0)
@@ -139,7 +137,6 @@ GEM
139
137
  tzinfo (2.0.6)
140
138
  concurrent-ruby (~> 1.0)
141
139
  unicode-display_width (2.5.0)
142
- uri (0.13.0)
143
140
  webmock (3.19.1)
144
141
  addressable (>= 2.8.0)
145
142
  crack (>= 0.3.2)
@@ -38,7 +38,7 @@ module Esse
38
38
  Esse::ActiveRecord::Hooks.register_model(self)
39
39
 
40
40
  if_enabled = -> { Esse::ActiveRecord::Hooks.enabled?(index_repo_name) && Esse::ActiveRecord::Hooks.enabled_for_model?(self.class, index_repo_name) }
41
- (on & %i[create update]).each do |event|
41
+ (on & %i[create]).each do |event|
42
42
  after_commit(on: event, if: if_enabled) do
43
43
  opts = self.class.esse_index_repos.fetch(index_repo_name).fetch(operation_name)
44
44
  record = opts.fetch(:record)
@@ -49,6 +49,34 @@ module Esse
49
49
  true
50
50
  end
51
51
  end
52
+ (on & %i[update]).each do |event|
53
+ after_commit(on: event, if: if_enabled) do
54
+ opts = self.class.esse_index_repos.fetch(index_repo_name).fetch(operation_name)
55
+ record = opts.fetch(:record)
56
+ record = instance_exec(&record) if record.respond_to?(:call)
57
+ repo = Esse::ActiveRecord::Hooks.resolve_index_repository(index_repo_name)
58
+ document = repo.serialize(record)
59
+ next true unless document
60
+
61
+ repo.index.index(document, **opts[:options])
62
+ next true unless document.routing
63
+
64
+ prev_record = self.class.new(attributes.merge(previous_changes.transform_values(&:first))).tap(&:readonly!)
65
+ prev_document = repo.serialize(prev_record)
66
+
67
+ next true unless prev_document
68
+ next true if [prev_document.id, prev_document.routing].include?(nil)
69
+ next true if prev_document.routing == document.routing
70
+ next true if prev_document.id != document.id
71
+
72
+ begin
73
+ repo.index.delete(prev_document, **opts[:options])
74
+ rescue Esse::Transport::NotFoundError
75
+ end
76
+
77
+ true
78
+ end
79
+ end
52
80
  (on & %i[destroy]).each do |event|
53
81
  after_commit(on: event, if: if_enabled) do
54
82
  opts = self.class.esse_index_repos.fetch(index_repo_name).fetch(operation_name)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Esse
4
4
  module ActiveRecord
5
- VERSION = '0.2.0'
5
+ VERSION = '0.2.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esse-active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcos G. Zimmermann
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-24 00:00:00.000000000 Z
11
+ date: 2024-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: esse
@@ -250,7 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
250
250
  - !ruby/object:Gem::Version
251
251
  version: '0'
252
252
  requirements: []
253
- rubygems_version: 3.2.32
253
+ rubygems_version: 3.1.6
254
254
  signing_key:
255
255
  specification_version: 4
256
256
  summary: ActiveRecord extensions for Esse