loco-rails 6.1.0 → 7.0.0.pre

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: 7b045cea0f5c6f123854c0a40b8953e869b18d0f97b31f332f96fd9b5d8c9d31
4
- data.tar.gz: 9ee0e7159ede72b756f29a25adbd1982363f27f26f803f1d3f4d9c8cfbae2a3a
3
+ metadata.gz: 91fa43946b21c98653c94fb289209737014410626b912cd81a02d646a4fd1ca3
4
+ data.tar.gz: f05761f0f25b0a3a554e05c0530add2c1c7a17a0445a8934cf0da12772f13595
5
5
  SHA512:
6
- metadata.gz: 236a3ddae5fcc7fb45f17bbfe8f0e48a8a9ac152cb83a4b53a4b9b5e4416a078ec7e4aaa65d5a31ac69a422574e63857787dac57f240f8c0397bfc42be25dfc4
7
- data.tar.gz: 3857fd4ee3754ab803707ddeb86bc1cbaa7aead76f389202b43146ac11a76a71600a5e238a05dc1b80e6b67f7495374b20ed63ec45d653389b95126d22cc42b5
6
+ metadata.gz: bc352f8f3ca53406196967df78b1f8ef428beeb7b7a61c1005a0cb7ed99dba3ffc571431c6869676f688c2d4e069a8d7ef5faa2f7a12d579e8d500cb361ed149
7
+ data.tar.gz: 6ee7da804147b2ac32cb8ef11558b604ea2a6822fd946f8a91b242d113f55a0ab7b7070956f2e54851f0159a512e86c9474dea1d6245bbc728a2d10e53d265cb
@@ -33,7 +33,7 @@ module Loco
33
33
  protected
34
34
 
35
35
  def update_connections
36
- PermissionsPresenter.indexed(loco_permissions, except: :uuid).each do |_, resource|
36
+ PermissionsPresenter.indexed(loco_permissions, except: :uuid).each_value do |resource|
37
37
  WsConnectionManager.new(resource).update(@uuid)
38
38
  end
39
39
  end
@@ -22,7 +22,7 @@ module Loco
22
22
  return
23
23
  end
24
24
  fetcher = Notification::Fetcher.new({ synced_at: params[:synced_at],
25
- permissions: permissions,
25
+ permissions:,
26
26
  recipient_token: params[:token] })
27
27
  render json: [fetcher.formatted_notifications, fetcher.next_sync_time.iso8601(6)]
28
28
  end
@@ -7,7 +7,7 @@ module Loco
7
7
 
8
8
  attr_reader :obj
9
9
 
10
- serialize :data, JSON
10
+ serialize :data, coder: JSON if ActiveRecord::Base.connection.adapter_name != 'PostgreSQL'
11
11
 
12
12
  validates :obj_class, presence: true
13
13
  validates :event, presence: true
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class CreateLocoNotifications < ActiveRecord::Migration[5.0]
3
+ class CreateLocoNotifications < ActiveRecord::Migration[6.1]
4
4
  def change
5
- create_table :loco_notifications do |t|
5
+ create_table :loco_notifications, id: false do |t|
6
6
  t.string :obj_class
7
- t.integer :obj_id
7
+ t.bigint :obj_id
8
8
  t.string :event
9
- t.string :data
9
+ t.column :data, (ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' ? :jsonb : :text)
10
10
  t.string :recipient_class
11
- t.integer :recipient_id
11
+ t.bigint :recipient_id
12
12
  t.string :recipient_token
13
13
 
14
14
  t.timestamps null: false, limit: 6
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddIndexesToLocoNotifications < ActiveRecord::Migration[6.1]
4
+ def change
5
+ add_index :loco_notifications, %i[created_at recipient_class recipient_id],
6
+ name: 'index_loco_notifications_on_created_at_and_recipient'
7
+
8
+ add_index :loco_notifications, %i[created_at recipient_token],
9
+ name: 'index_loco_notifications_on_created_at_and_recipient_token'
10
+ end
11
+ end
@@ -7,7 +7,6 @@ module Loco
7
7
  def install
8
8
  generate 'loco:initializer'
9
9
  generate 'loco:file_injector'
10
- generate 'loco:core:file_injector'
11
10
  generate 'loco:notification_center'
12
11
  rake 'loco:install:migrations'
13
12
  end
@@ -22,9 +22,9 @@ module Loco
22
22
  def send_notifications(obj, event, recipients, payload)
23
23
  recipients.each do |recipient|
24
24
  notification = Notification.create!(
25
- obj: obj,
26
- event: event,
27
- recipient: recipient,
25
+ obj:,
26
+ event:,
27
+ recipient:,
28
28
  data: payload
29
29
  )
30
30
  sync_time = notification.created_at.iso8601(6)
@@ -43,10 +43,10 @@ module Loco
43
43
  def send_notification(recipient, notification, sync_time)
44
44
  if notification.recipient_id
45
45
  Sender.(recipient, loco: { notification: notification.compact })
46
- Sender.(recipient, loco: { sync_time: sync_time })
46
+ Sender.(recipient, loco: { sync_time: })
47
47
  else
48
48
  SenderJob.perform_later(recipient, loco: { notification: notification.compact })
49
- SenderJob.perform_later(recipient, loco: { sync_time: sync_time })
49
+ SenderJob.perform_later(recipient, loco: { sync_time: })
50
50
  end
51
51
  end
52
52
  end
data/lib/loco/config.rb CHANGED
@@ -13,22 +13,9 @@ module Loco
13
13
  self.silence_logger = config.silence_logger if config.silence_logger
14
14
  self.notifications_size = config.notifications_size if config.notifications_size
15
15
  self.app_name = config.app_name if config.app_name
16
- configure_redis config.redis_instance
16
+ self.redis_instance = config.redis_instance
17
17
  ensure
18
18
  true
19
19
  end
20
-
21
- def self.configure_redis(redis_instance)
22
- if redis_instance
23
- self.redis_instance = redis_instance
24
- return
25
- end
26
- return unless defined? Redis
27
-
28
- Redis.current.get 'random_redis_key'
29
- self.redis_instance = Redis.current
30
- rescue Redis::CannotConnectError
31
- self.redis_instance = nil
32
- end
33
20
  end
34
21
  end
data/lib/loco/hub.rb CHANGED
@@ -58,7 +58,7 @@ module Loco
58
58
  def members
59
59
  raw_members.map do |serialized|
60
60
  klass, id = serialized.split(':')
61
- klass.classify.constantize.find_by(id: id)
61
+ klass.classify.constantize.find_by(id:)
62
62
  end
63
63
  end
64
64
  end
@@ -9,7 +9,7 @@ module Loco
9
9
  o.class.name.downcase.to_sym
10
10
  end
11
11
  if opts[:except] == :uuid
12
- h.reject { |k, _| k == :string }
12
+ h.except(:string)
13
13
  else
14
14
  h
15
15
  end
data/lib/loco/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Loco
4
- VERSION = '6.1.0'
4
+ VERSION = '7.0.0.pre'
5
5
  end
@@ -59,8 +59,8 @@ module Loco
59
59
  end
60
60
  end
61
61
 
62
- def scan_hash(key, &block)
63
- storage.hscan_each(proper_key("h:#{key}"), &block)
62
+ def scan_hash(key, &)
63
+ storage.hscan_each(proper_key("h:#{key}"), &)
64
64
  end
65
65
 
66
66
  def hlen(key)
data/lib/loco-rails.rb CHANGED
@@ -1,12 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'loco-rails-core'
4
-
5
3
  require 'loco/broadcaster'
6
4
  require 'loco/config'
7
5
  require 'loco/emitter'
8
6
  require 'loco/rails/engine'
9
- require 'loco/helpers'
10
7
  require 'loco/hub'
11
8
  require 'loco/permissions_presenter'
12
9
  require 'loco/sender'
metadata CHANGED
@@ -1,253 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loco-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.0
4
+ version: 7.0.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zbigniew Humeniuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-04 00:00:00.000000000 Z
11
+ date: 2024-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: loco-rails-core
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 0.2.0
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 0.2.0
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rails
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - ">="
32
18
  - !ruby/object:Gem::Version
33
- version: '5.0'
19
+ version: '6.1'
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - ">="
39
25
  - !ruby/object:Gem::Version
40
- version: '5.0'
41
- - !ruby/object:Gem::Dependency
42
- name: bcrypt
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 3.1.16
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 3.1.16
55
- - !ruby/object:Gem::Dependency
56
- name: capybara
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 3.36.0
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 3.36.0
69
- - !ruby/object:Gem::Dependency
70
- name: database_cleaner
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 2.0.1
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 2.0.1
83
- - !ruby/object:Gem::Dependency
84
- name: jbuilder
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 2.11.5
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 2.11.5
97
- - !ruby/object:Gem::Dependency
98
- name: listen
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: 3.7.1
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: 3.7.1
111
- - !ruby/object:Gem::Dependency
112
- name: mysql2
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: 0.5.3
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: 0.5.3
125
- - !ruby/object:Gem::Dependency
126
- name: puma
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: 5.6.2
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: 5.6.2
139
- - !ruby/object:Gem::Dependency
140
- name: redis
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: 4.5.1
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: 4.5.1
153
- - !ruby/object:Gem::Dependency
154
- name: rspec-expectations
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - "~>"
158
- - !ruby/object:Gem::Version
159
- version: 3.10.2
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - "~>"
165
- - !ruby/object:Gem::Version
166
- version: 3.10.2
167
- - !ruby/object:Gem::Dependency
168
- name: rspec-mocks
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - "~>"
172
- - !ruby/object:Gem::Version
173
- version: 3.10.2
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - "~>"
179
- - !ruby/object:Gem::Version
180
- version: 3.10.2
181
- - !ruby/object:Gem::Dependency
182
- name: rubocop
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - ">="
186
- - !ruby/object:Gem::Version
187
- version: '0'
188
- type: :development
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - ">="
193
- - !ruby/object:Gem::Version
194
- version: '0'
195
- - !ruby/object:Gem::Dependency
196
- name: rubocop-rails
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - ">="
200
- - !ruby/object:Gem::Version
201
- version: '0'
202
- type: :development
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - ">="
207
- - !ruby/object:Gem::Version
208
- version: '0'
209
- - !ruby/object:Gem::Dependency
210
- name: selenium-webdriver
211
- requirement: !ruby/object:Gem::Requirement
212
- requirements:
213
- - - "~>"
214
- - !ruby/object:Gem::Version
215
- version: 4.1.0
216
- type: :development
217
- prerelease: false
218
- version_requirements: !ruby/object:Gem::Requirement
219
- requirements:
220
- - - "~>"
221
- - !ruby/object:Gem::Version
222
- version: 4.1.0
223
- - !ruby/object:Gem::Dependency
224
- name: sprockets-rails
225
- requirement: !ruby/object:Gem::Requirement
226
- requirements:
227
- - - "~>"
228
- - !ruby/object:Gem::Version
229
- version: 3.4.2
230
- type: :development
231
- prerelease: false
232
- version_requirements: !ruby/object:Gem::Requirement
233
- requirements:
234
- - - "~>"
235
- - !ruby/object:Gem::Version
236
- version: 3.4.2
237
- - !ruby/object:Gem::Dependency
238
- name: will_paginate
239
- requirement: !ruby/object:Gem::Requirement
240
- requirements:
241
- - - "~>"
242
- - !ruby/object:Gem::Version
243
- version: 3.3.1
244
- type: :development
245
- prerelease: false
246
- version_requirements: !ruby/object:Gem::Requirement
247
- requirements:
248
- - - "~>"
249
- - !ruby/object:Gem::Version
250
- version: 3.3.1
26
+ version: '6.1'
251
27
  description: Rails is awesome, but modern web needs Loco-motive.
252
28
  email:
253
29
  - hello@artofcode.co
@@ -265,6 +41,7 @@ files:
265
41
  - app/services/loco/notification/fetcher.rb
266
42
  - config/routes.rb
267
43
  - db/migrate/20150927133812_create_loco_notifications.rb
44
+ - db/migrate/20240211210452_add_indexes_to_loco_notifications.rb
268
45
  - lib/generators/loco/file_injector/USAGE
269
46
  - lib/generators/loco/file_injector/file_injector_generator.rb
270
47
  - lib/generators/loco/file_injector/templates/application_controller.rb
@@ -281,7 +58,6 @@ files:
281
58
  - lib/loco/broadcaster.rb
282
59
  - lib/loco/config.rb
283
60
  - lib/loco/emitter.rb
284
- - lib/loco/helpers.rb
285
61
  - lib/loco/hub.rb
286
62
  - lib/loco/permissions_presenter.rb
287
63
  - lib/loco/rails/engine.rb
@@ -305,14 +81,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
305
81
  requirements:
306
82
  - - ">="
307
83
  - !ruby/object:Gem::Version
308
- version: 2.7.0
84
+ version: 3.1.0
309
85
  required_rubygems_version: !ruby/object:Gem::Requirement
310
86
  requirements:
311
87
  - - ">="
312
88
  - !ruby/object:Gem::Version
313
89
  version: '0'
314
90
  requirements: []
315
- rubygems_version: 3.3.7
91
+ rubygems_version: 3.5.6
316
92
  signing_key:
317
93
  specification_version: 4
318
94
  summary: Framework on top of Rails.
data/lib/loco/helpers.rb DELETED
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Loco
4
- module Helpers
5
- include Loco::Core::Helpers
6
- end
7
- end