signum 0.6.0 → 0.7.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: 65ddec675d519cebd682d685b2da8fece2db0b66d4e3dddaa130eb292f2b6e89
4
- data.tar.gz: c02695a0e0b5978ff7e5b1595dcabcb034aace639682046899beb3fb34ec72a2
3
+ metadata.gz: 63cc9c70f252bac415cd89556051daffc3449d4175726cc272b26ba50a04d04b
4
+ data.tar.gz: 66eab14fd02f1cff3a5008bcaef2e9be94389e62a9a3c2f832243f2b4ac2a490
5
5
  SHA512:
6
- metadata.gz: 96b4491e10ccc698f14b52a0b11a94476fc3cd4652e798a1b1b3e782227f1d636d8c676c4485e24bed6d35bbd991f42c5c74bfbe6b17bed8896e613800aea8bf
7
- data.tar.gz: 0f826ed2651e4fce6a779fbefda95b6496b74416938deb2fdc271762ead8af55de799e6aa5abd0036912e936f90ad769579363d7dd126c87f8d574852c855275
6
+ metadata.gz: 0d88fa165327a524271be29b1163350df04d52736c60354378f2a7ef2226d8567d58380991ac0e12e3c8f318d660be892ff504e46d7edd1a369fefdb0c405064
7
+ data.tar.gz: 0333cebc07d9d42445be878c069528cb09f6bd272ed450479ac4168fbfa5c0ec483f561f1896dedba65bb0e1eb31406aa538a1b403c6e0f98ad4eace747bb71e
data/.rubocop.yml ADDED
@@ -0,0 +1,14 @@
1
+ # https://www.fastruby.io/blog/ruby/code-quality/how-we-use-rubocop-and-standardrb.html
2
+
3
+ require:
4
+ - standard
5
+
6
+ inherit_gem:
7
+ standard: config/base.yml
8
+
9
+ AllCops:
10
+ NewCops: enable
11
+ Exclude:
12
+ - node_modules/**/*
13
+ - public/**/*
14
+ - vendor/**/*
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
5
  git_source(:entdec) { |repo_name| "git@github.com:entdec/#{repo_name}.git" }
6
6
 
@@ -17,6 +17,6 @@ gemspec
17
17
  # To use a debugger
18
18
  # gem 'byebug', group: [:development, :test]
19
19
 
20
- gem 'auxilium', '~> 3', entdec: 'auxilium'
20
+ gem "auxilium", "~> 3", entdec: "auxilium"
21
21
 
22
22
  gem "sprockets-rails"
data/Gemfile.lock CHANGED
@@ -13,7 +13,7 @@ GIT
13
13
  PATH
14
14
  remote: .
15
15
  specs:
16
- signum (0.5.1)
16
+ signum (0.6.0)
17
17
  importmap-rails
18
18
  pg
19
19
  rails (> 6.0)
@@ -22,6 +22,7 @@ PATH
22
22
  stimulus-rails
23
23
  tailwindcss-rails
24
24
  turbo-rails
25
+ view_component
25
26
 
26
27
  GEM
27
28
  remote: https://rubygems.org/
@@ -100,6 +101,7 @@ GEM
100
101
  minitest (>= 5.1)
101
102
  mutex_m
102
103
  tzinfo (~> 2.0)
104
+ ast (2.4.2)
103
105
  base64 (0.2.0)
104
106
  bigdecimal (3.1.6)
105
107
  builder (3.2.4)
@@ -107,6 +109,7 @@ GEM
107
109
  connection_pool (2.4.1)
108
110
  crass (1.0.6)
109
111
  date (3.3.4)
112
+ debug (0.2.1)
110
113
  drb (2.2.0)
111
114
  ruby2_keywords
112
115
  erubi (1.12.0)
@@ -122,6 +125,9 @@ GEM
122
125
  irb (1.11.2)
123
126
  rdoc
124
127
  reline (>= 0.4.2)
128
+ json (2.7.2)
129
+ language_server-protocol (3.17.0.3)
130
+ lint_roller (1.1.0)
125
131
  loofah (2.22.0)
126
132
  crass (~> 1.0.2)
127
133
  nokogiri (>= 1.12.0)
@@ -131,6 +137,7 @@ GEM
131
137
  net-pop
132
138
  net-smtp
133
139
  marcel (1.0.4)
140
+ method_source (1.0.0)
134
141
  mini_mime (1.1.5)
135
142
  mini_portile2 (2.8.5)
136
143
  minitest (5.22.2)
@@ -148,6 +155,10 @@ GEM
148
155
  nokogiri (1.16.2)
149
156
  mini_portile2 (~> 2.8.2)
150
157
  racc (~> 1.4)
158
+ parallel (1.24.0)
159
+ parser (3.3.0.5)
160
+ ast (~> 2.4.1)
161
+ racc
151
162
  pg (1.5.6)
152
163
  psych (5.1.2)
153
164
  stringio
@@ -191,15 +202,35 @@ GEM
191
202
  rake (>= 12.2)
192
203
  thor (~> 1.0, >= 1.2.2)
193
204
  zeitwerk (~> 2.6)
205
+ rainbow (3.1.1)
194
206
  rake (13.1.0)
195
207
  rdoc (6.6.2)
196
208
  psych (>= 4.0.0)
209
+ regexp_parser (2.9.0)
197
210
  reline (0.4.3)
198
211
  io-console (~> 0.5)
199
212
  responders (3.1.1)
200
213
  actionpack (>= 5.2)
201
214
  railties (>= 5.2)
215
+ rexml (3.2.6)
202
216
  rolify (6.0.1)
217
+ rubocop (1.62.1)
218
+ json (~> 2.3)
219
+ language_server-protocol (>= 3.17.0)
220
+ parallel (~> 1.10)
221
+ parser (>= 3.3.0.2)
222
+ rainbow (>= 2.2.2, < 4.0)
223
+ regexp_parser (>= 1.8, < 3.0)
224
+ rexml (>= 3.2.5, < 4.0)
225
+ rubocop-ast (>= 1.31.1, < 2.0)
226
+ ruby-progressbar (~> 1.7)
227
+ unicode-display_width (>= 2.4.0, < 3.0)
228
+ rubocop-ast (1.31.2)
229
+ parser (>= 3.3.0.4)
230
+ rubocop-performance (1.20.2)
231
+ rubocop (>= 1.48.1, < 2.0)
232
+ rubocop-ast (>= 1.30.0, < 2.0)
233
+ ruby-progressbar (1.13.0)
203
234
  ruby2_keywords (0.0.5)
204
235
  slim (5.2.1)
205
236
  temple (~> 0.10.0)
@@ -217,6 +248,18 @@ GEM
217
248
  sprockets (>= 3.0.0)
218
249
  sqlite3 (1.7.2)
219
250
  mini_portile2 (~> 2.8.0)
251
+ standard (1.35.1)
252
+ language_server-protocol (~> 3.17.0.2)
253
+ lint_roller (~> 1.0)
254
+ rubocop (~> 1.62.0)
255
+ standard-custom (~> 1.0.0)
256
+ standard-performance (~> 1.3)
257
+ standard-custom (1.0.2)
258
+ lint_roller (~> 1.0)
259
+ rubocop (~> 1.50)
260
+ standard-performance (1.3.1)
261
+ lint_roller (~> 1.1)
262
+ rubocop-performance (~> 1.20.2)
220
263
  state_machines (0.6.0)
221
264
  state_machines-activemodel (0.9.0)
222
265
  activemodel (>= 6.0)
@@ -227,7 +270,7 @@ GEM
227
270
  stimulus-rails (1.3.3)
228
271
  railties (>= 6.0.0)
229
272
  stringio (3.1.0)
230
- tailwindcss-rails (2.3.0)
273
+ tailwindcss-rails (2.4.0)
231
274
  railties (>= 6.0.0)
232
275
  temple (0.10.3)
233
276
  thor (1.3.1)
@@ -239,6 +282,11 @@ GEM
239
282
  railties (>= 6.0.0)
240
283
  tzinfo (2.0.6)
241
284
  concurrent-ruby (~> 1.0)
285
+ unicode-display_width (2.5.0)
286
+ view_component (3.11.0)
287
+ activesupport (>= 5.2.0, < 8.0)
288
+ concurrent-ruby (~> 1.0)
289
+ method_source (~> 1.0)
242
290
  webrick (1.8.1)
243
291
  websocket-driver (0.7.6)
244
292
  websocket-extensions (>= 0.1.0)
@@ -250,9 +298,12 @@ PLATFORMS
250
298
 
251
299
  DEPENDENCIES
252
300
  auxilium (~> 3)!
301
+ debug (~> 0)
302
+ rubocop (~> 1)
253
303
  signum!
254
304
  sprockets-rails
255
305
  sqlite3
306
+ standard (~> 1)
256
307
 
257
308
  BUNDLED WITH
258
309
  2.3.17
data/README.md CHANGED
@@ -70,6 +70,18 @@ s = Signum.success(Current.user, text: "Hello World New", title: "this is test t
70
70
 
71
71
  Signum returns you the signal object. You can update these signals and they will be rebroadcasted again.
72
72
 
73
+ ### Keys
74
+
75
+ Next to using a User (or any other model) another option is to use keys instead. You could signal all users using the following:
76
+ ```ruby
77
+ s = Signum.signal(:all, text: "Hello World New", title: "Icon", icon:'fa-regular fa-t-rex')
78
+ ```
79
+
80
+ The key all is supported out of the box, any other key needs you to pass it in the Notifications::Component, here we're using the session.id:
81
+ ```slim
82
+ = render(Signum::Notifications::Component.new([request.session.id]))
83
+ ```
84
+
73
85
  ## Contributing
74
86
 
75
87
  Contribution directions go here.
data/Rakefile CHANGED
@@ -1,36 +1,36 @@
1
1
  begin
2
- require 'bundler/setup'
2
+ require "bundler/setup"
3
3
  rescue LoadError
4
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
4
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
5
5
  end
6
6
 
7
- require 'rdoc/task'
7
+ require "rdoc/task"
8
8
 
9
9
  RDoc::Task.new(:rdoc) do |rdoc|
10
- rdoc.rdoc_dir = 'rdoc'
11
- rdoc.title = 'Signum'
12
- rdoc.options << '--line-numbers'
13
- rdoc.rdoc_files.include('README.md')
14
- rdoc.rdoc_files.include('lib/**/*.rb')
10
+ rdoc.rdoc_dir = "rdoc"
11
+ rdoc.title = "Signum"
12
+ rdoc.options << "--line-numbers"
13
+ rdoc.rdoc_files.include("README.md")
14
+ rdoc.rdoc_files.include("lib/**/*.rb")
15
15
  end
16
16
 
17
17
  APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
18
- load 'rails/tasks/engine.rake'
18
+ load "rails/tasks/engine.rake"
19
19
 
20
- load 'rails/tasks/statistics.rake'
20
+ load "rails/tasks/statistics.rake"
21
21
 
22
- require 'bundler/gem_tasks'
22
+ require "bundler/gem_tasks"
23
23
 
24
- require 'rake/testtask'
24
+ require "rake/testtask"
25
25
 
26
26
  Rake::TestTask.new(:test) do |t|
27
- t.libs << 'test'
28
- t.pattern = 'test/**/*_test.rb'
27
+ t.libs << "test"
28
+ t.pattern = "test/**/*_test.rb"
29
29
  t.verbose = false
30
30
  end
31
31
 
32
32
  task default: :test
33
33
 
34
34
  # Adds the Auxilium semver task
35
- spec = Gem::Specification.find_by_name 'auxilium'
35
+ spec = Gem::Specification.find_by_name "auxilium"
36
36
  load "#{spec.gem_dir}/lib/tasks/semver.rake"
@@ -1,8 +1,8 @@
1
1
  div.text-left[data-controller="signum-notification-drawer" data-action="mouseover->signum-notification-drawer#show mouseleave->signum-notification-drawer#hide click->signum-notification-drawer#closeNotifications"]
2
- button.signum-notification-drawer-button
3
- i class="hidden #{Signum.config.icons[:unread_main]}" data-signum-notification-drawer-target='alertbellicon'
4
- i class="#{Signum.config.icons[:read_main]}" data-signum-notification-drawer-target='bellicon'
5
- i.hidden.fas.fa-times.cross-icon.text-xs.absolute.top-5.right-15#crossIcon data-signum-notification-drawer-target="crossicon"
2
+ button.signum-notification-drawer-button data-action="click->signum-notification-drawer#closeNotifications"
3
+ i class="hidden #{Signum.config.icons[:unread_main]}" data-signum-notification-drawer-target='alertBellIcon'
4
+ i class="#{Signum.config.icons[:read_main]}" data-signum-notification-drawer-target='bellIcon'
5
+ i.hidden.fas.fa-times.cross-icon.text-xs.absolute.top-5.right-15#crossIcon data-signum-notification-drawer-target="crossIcon" data-action="click->signum-notification-drawer#closeNotifications"
6
6
 
7
- .signum-notification-drawer-tray.hidden[data-signum-notification-drawer-target="submenu" id="#{Signum.config.drawer_notifications_container_id.call}"]
8
- = render(Signum::NotificationDrawerItem::Component.with_collection(signals))
7
+ .signum-notification-drawer-tray.hidden[data-signum-notification-drawer-target="submenu" id="#{Signum.config.drawer_notifications_container_id.call}"]
8
+ = render(Signum::NotificationDrawerItem::Component.with_collection(signals))
@@ -2,7 +2,7 @@ import ApplicationController from "signum/controllers/application_controller"
2
2
 
3
3
  export default class extends ApplicationController {
4
4
 
5
- static targets = ["alertbellicon", "bellicon", "submenu", "item", "crossicon"]
5
+ static targets = ["alertBellIcon", "bellIcon", "submenu", "item", "crossIcon"]
6
6
 
7
7
  connect() {
8
8
  this.bounditemActivity = this.itemActivity.bind(this)
@@ -21,11 +21,7 @@ export default class extends ApplicationController {
21
21
  show(event) {
22
22
  if (this.submenuTarget.children.length > 0) {
23
23
  this.submenuTarget.classList.remove("hidden")
24
- if (event.altKey) {
25
- this.crossiconTarget.style.display = 'inline-block'
26
- } else {
27
- this.crossiconTarget.style.display = 'none'
28
- }
24
+ this.crossIconTarget.classList.remove("hidden")
29
25
  } else {
30
26
  this.submenuTarget.classList.add("hidden")
31
27
  }
@@ -33,17 +29,13 @@ export default class extends ApplicationController {
33
29
 
34
30
  hide(event) {
35
31
  this.submenuTarget.classList.add("hidden")
36
- this.crossiconTarget.style.display = 'none'
32
+ this.crossIconTarget.classList.add("hidden")
37
33
  if (this.submenuTarget.children.length < 0) {
38
- this.alertbelliconTarget.classList.add("hidden")
39
- }
40
- if (event.altKey) {
41
- this.crossiconTarget.style.display = 'none'
34
+ this.alertBellIconTarget.classList.add("hidden")
42
35
  }
43
36
  }
44
37
 
45
38
  closeNotifications(event) {
46
- if (event.altKey) {
47
39
  fetch("/signal/close_all", {
48
40
  method: "GET",
49
41
  headers: {
@@ -54,10 +46,9 @@ export default class extends ApplicationController {
54
46
  .catch((err) => {
55
47
  console.log(err)
56
48
  })
57
- this.crossiconTarget.style.display = 'none';
58
- this.belliconTarget.style.display = 'inline-block'
59
- this.alertbelliconTarget.style.display = 'none';
60
- }
49
+ this.crossIconTarget.style.display = 'none';
50
+ this.bellIconTarget.style.display = 'inline-block'
51
+ this.alertBellIconTarget.style.display = 'none';
61
52
  }
62
53
 
63
54
  itemActivity(event) {
@@ -70,11 +61,11 @@ export default class extends ApplicationController {
70
61
 
71
62
  manageBellIcon() {
72
63
  if (this.submenuTarget.children.length > 0) {
73
- this.alertbelliconTarget.classList.remove("hidden")
74
- this.belliconTarget.classList.add("hidden")
64
+ this.alertBellIconTarget.classList.remove("hidden")
65
+ this.bellIconTarget.classList.add("hidden")
75
66
  } else {
76
- this.alertbelliconTarget.classList.add("hidden")
77
- this.belliconTarget.classList.remove("hidden")
67
+ this.alertBellIconTarget.classList.add("hidden")
68
+ this.bellIconTarget.classList.remove("hidden")
78
69
  }
79
70
  }
80
71
  }
@@ -1,5 +1,8 @@
1
1
  = helpers.turbo_stream_from :signals
2
2
 
3
3
  .pointer-events-none.fixed.inset-0.flex.items-end.px-2.py-6.sm:items-start.sm:p-6.z-10 data-turbo-permanent="true" id="signum_notifications"
4
- #notifications_all.flex.w-full.flex-col.items-center.space-y-2.sm:items-end
4
+ / #notifications_all.flex.w-full.flex-col.items-center.space-y-2.sm:items-end
5
5
  div.flex.w-full.flex-col.items-center.space-y-2.sm:items-end[id="#{Signum.config.balloon_notifications_container_id.call}"]
6
+ div.flex.w-full.flex-col.items-center.space-y-2.sm:items-end[id="notifications_all"]
7
+ - keys&.each do |key|
8
+ div.flex.w-full.flex-col.items-center.space-y-2.sm:items-end[id="notifications_#{key}"]
@@ -1,8 +1,9 @@
1
1
  module Signum
2
2
  module Notifications
3
3
  class Component < ViewComponent::Base
4
-
5
- def initialize()
4
+ attr_reader :keys
5
+ def initialize(keys = nil)
6
+ @keys = keys
6
7
  end
7
8
  end
8
9
  end
@@ -13,7 +13,7 @@ module Signum
13
13
  end
14
14
 
15
15
  def close_all
16
- signals = current_user.signals.where.not(state: 'closed')
16
+ signals = current_user.signals.where.not(state: "closed")
17
17
  signals.each(&:close!)
18
18
  head :ok
19
19
  end
@@ -1,6 +1,6 @@
1
1
  module Signum
2
2
  class ApplicationMailer < ActionMailer::Base
3
- default from: 'from@example.com'
4
- layout 'mailer'
3
+ default from: "from@example.com"
4
+ layout "mailer"
5
5
  end
6
6
  end
@@ -1,8 +1,10 @@
1
1
  module Signum
2
2
  class Signal < ApplicationRecord
3
- belongs_to :signalable, polymorphic: true
3
+ belongs_to :signalable, polymorphic: true, optional: true
4
4
  belongs_to :subjectable, polymorphic: true, optional: true
5
5
 
6
+ validates :signalable, presence: true, if: -> { key.blank? }
7
+
6
8
  has_many_attached :attachments
7
9
 
8
10
  after_create_commit :broadcast_create
@@ -11,11 +13,11 @@ module Signum
11
13
  def broadcast_create
12
14
  broadcast! if can_broadcast?
13
15
 
14
- broadcast_prepend_to(:signals, target: Signum.config.balloon_notifications_container_id.call(signalable, id),
15
- html: ApplicationController.render(Signum::Notification::Component.new(self)))
16
+ broadcast_prepend_to(:signals, target: Signum.config.balloon_notifications_container_id.call(key || signalable, id),
17
+ html: ApplicationController.render(Signum::Notification::Component.new(self)))
16
18
 
17
- broadcast_prepend_to(:signals, target: Signum.config.drawer_notifications_container_id.call(signalable, id),
18
- html: ApplicationController.render(Signum::NotificationDrawerItem::Component.new(signal: self)))
19
+ broadcast_prepend_to(:signals, target: Signum.config.drawer_notifications_container_id.call(key || signalable, id),
20
+ html: ApplicationController.render(Signum::NotificationDrawerItem::Component.new(signal: self)))
19
21
  end
20
22
 
21
23
  def broadcast_update
@@ -26,10 +28,10 @@ module Signum
26
28
  return
27
29
  end
28
30
 
29
- broadcast_replace_to(:signals, target: "notification_balloon_#{signalable_id}_#{id}",
30
- html: ApplicationController.render(Signum::NotificationBody::Component.new(self, { type: :balloon, timeout: 5 })))
31
- broadcast_replace_to(:signals, target: "notification_drawer_item_#{signalable_id}_#{id}",
32
- html: ApplicationController.render(Signum::NotificationBody::Component.new(self, { type: :drawer_item, timeout: 5 })))
31
+ broadcast_replace_to(:signals, target: Signum.config.balloon_notifications_container_id.call(key || signalable, id),
32
+ html: ApplicationController.render(Signum::NotificationBody::Component.new(self, {type: :balloon, timeout: 5})))
33
+ broadcast_replace_to(:signals, target: Signum.config.drawer_notifications_container_id.call(key || signalable, id),
34
+ html: ApplicationController.render(Signum::NotificationBody::Component.new(self, {type: :drawer_item, timeout: 5})))
33
35
  end
34
36
 
35
37
  validates :text, presence: true
data/config/routes.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  Signum::Engine.routes.draw do
2
- post 'signal/show', to: 'signal#show'
3
- post 'signal/close', to: 'signal#close'
4
- get 'signal/close_all', to: 'signal#close_all'
5
- post 'signal/open_stickies', to: 'signal#open_stickies'
2
+ post "signal/show", to: "signal#show"
3
+ post "signal/close", to: "signal#close"
4
+ get "signal/close_all", to: "signal#close_all"
5
+ post "signal/open_stickies", to: "signal#open_stickies"
6
6
  end
@@ -1,10 +1,10 @@
1
1
  class CreateSignumSignals < ActiveRecord::Migration[6.0]
2
2
  def change
3
3
  create_table :signum_signals, id: :uuid do |t|
4
- t.string :state, default: 'pending'
4
+ t.string :state, default: "pending"
5
5
  t.references :signalable, polymorphic: true, optional: false, null: false, type: :uuid
6
6
 
7
- t.string :kind, default: 'notice'
7
+ t.string :kind, default: "notice"
8
8
  t.boolean :sticky
9
9
  t.string :icon
10
10
  t.string :title
@@ -0,0 +1,21 @@
1
+ class AddKeyToSignal < ActiveRecord::Migration[7.1]
2
+ def change
3
+ add_column :signum_signals, :key, :string
4
+ add_index :signum_signals, :key
5
+ # t.references :signalable, polymorphic: true, optional: false, null: false, type: :uuid
6
+ # t.string "signalable_type", null: false
7
+ # t.uuid "signalable_id", null: false
8
+ change_column_null :signum_signals, :signalable_type, true
9
+ change_column_null :signum_signals, :signalable_id, true
10
+ end
11
+
12
+ def down
13
+ remove_column :signum_signals, :key, :string
14
+ remove_index :signum_signals, :key
15
+ # t.references :signalable, polymorphic: true, optional: false, null: false, type: :uuid
16
+ # t.string "signalable_type", null: false
17
+ # t.uuid "signalable_id", null: false
18
+ change_column_null :signum_signals, :signalable_type, false
19
+ change_column_null :signum_signals, :signalable_id, false
20
+ end
21
+ end
@@ -1,10 +1,10 @@
1
- require 'rails/generators/base'
1
+ require "rails/generators/base"
2
2
 
3
3
  module Signum
4
4
  module Generators
5
5
  class TailwindConfigGenerator < Rails::Generators::Base
6
- source_root File.expand_path('../templates', __dir__)
7
- desc 'Configures tailwind.config.js and application.tailwindcss.css'
6
+ source_root File.expand_path("../templates", __dir__)
7
+ desc "Configures tailwind.config.js and application.tailwindcss.css"
8
8
 
9
9
  def add_content_to_tailwind_config
10
10
  inject_into_file "config/tailwind.config.js", before: "],\n theme: {" do
@@ -6,7 +6,7 @@ module Signum
6
6
 
7
7
  class_methods do
8
8
  def signalable
9
- has_many :signals, as: :signalable, class_name: 'Signum::Signal'
9
+ has_many :signals, as: :signalable, class_name: "Signum::Signal"
10
10
 
11
11
  send :include, Signum::ActiveRecordHelpers::InstanceMethods
12
12
  extend(Signum::ActiveRecordHelpers::ClassMethods)
@@ -18,19 +18,19 @@ module Signum
18
18
 
19
19
  module InstanceMethods
20
20
  def online!
21
- update(presence: 'online')
21
+ update(presence: "online")
22
22
  end
23
23
 
24
24
  def offline!
25
- update(presence: 'offline')
25
+ update(presence: "offline")
26
26
  end
27
27
 
28
28
  def appeared!
29
- update(presence: 'appeared')
29
+ update(presence: "appeared")
30
30
  end
31
31
 
32
32
  def away!
33
- update(presence: 'away')
33
+ update(presence: "away")
34
34
  end
35
35
  end
36
36
  end
@@ -16,7 +16,7 @@ module Signum
16
16
 
17
17
  def set_defaults!
18
18
  self.class.schema.each do |name, default|
19
- instance_variable_set("@#{name}", default)
19
+ instance_variable_set(:"@#{name}", default)
20
20
  end
21
21
  end
22
22
 
@@ -29,21 +29,21 @@ module Signum
29
29
  include Options
30
30
 
31
31
  option :logger, default: Rails.logger
32
- option :user_model_name, default: 'User'
32
+ option :user_model_name, default: "User"
33
33
  option :hide_after, default: 3000
34
- option :base_controller, default: '::ApplicationController'
35
- option :base_service, default: '::ApplicationService'
36
- option :base_service_context, default: '::ApplicationContext'
34
+ option :base_controller, default: "::ApplicationController"
35
+ option :base_service, default: "::ApplicationService"
36
+ option :base_service_context, default: "::ApplicationContext"
37
37
  option :current_user, default: -> {}
38
38
  option :drawer_notifications_container_id, default: ->(signalable = nil, id = nil) {}
39
39
  option :balloon_notifications_container_id, default: ->(signalable = nil, id = nil) {}
40
40
  option :icons,
41
- default: { info: 'fa-solid fa-circle-info fa-lg',
42
- error: 'fa-solid fa-square-xmark fa-lg',
43
- success: 'fa-solid fa-circle-check fa-lg',
44
- warning: 'fa-solid fa-triangle-exclamation fa-lg',
45
- unread_main: 'fa-solid fa-bell-ring',
46
- read_main: 'fa-solid fa-bell' }
41
+ default: {info: "fa-solid fa-circle-info fa-lg",
42
+ error: "fa-solid fa-square-xmark fa-lg",
43
+ success: "fa-solid fa-circle-check fa-lg",
44
+ warning: "fa-solid fa-triangle-exclamation fa-lg",
45
+ unread_main: "fa-solid fa-bell-ring",
46
+ read_main: "fa-solid fa-bell"}
47
47
 
48
48
  def initialize
49
49
  set_defaults!
@@ -60,7 +60,7 @@ module Signum
60
60
  def configure
61
61
  yield(config)
62
62
  end
63
- alias setup configure
63
+ alias_method :setup, :configure
64
64
 
65
65
  def reset_config!
66
66
  @config = Configuration.new
data/lib/signum/engine.rb CHANGED
@@ -1,21 +1,23 @@
1
- require 'slim'
2
- require 'tailwindcss-rails'
1
+ require "slim"
2
+ require "tailwindcss-rails"
3
3
  require "importmap-rails"
4
4
  require "turbo-rails"
5
5
  require "stimulus-rails"
6
+ require "state_machines-activerecord"
7
+ require "view_component"
6
8
 
7
9
  module Signum
8
10
  class Engine < ::Rails::Engine
9
11
  isolate_namespace Signum
10
12
 
11
- initializer 'signum.assets' do |app|
13
+ initializer "signum.assets" do |app|
12
14
  app.config.assets.paths << root.join("app/javascript")
13
15
  app.config.assets.paths << root.join("app/components")
14
16
  app.config.assets.paths << root.join("vendor/javascript")
15
17
  app.config.assets.precompile += %w[signum_manifest]
16
18
  end
17
19
 
18
- initializer 'signum.importmap', before: "importmap" do |app|
20
+ initializer "signum.importmap", before: "importmap" do |app|
19
21
  app.config.importmap.paths << root.join("config/importmap.rb")
20
22
  app.config.importmap.cache_sweepers << root.join("app/javascript")
21
23
  app.config.importmap.cache_sweepers << root.join("app/components")
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Signum
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.0"
5
5
  end
data/lib/signum.rb CHANGED
@@ -1,6 +1,6 @@
1
- require 'signum/engine'
2
- require 'signum/active_record_helpers'
3
- require 'signum/configuration'
1
+ require "signum/engine"
2
+ require "signum/active_record_helpers"
3
+ require "signum/configuration"
4
4
 
5
5
  module Signum
6
6
  class Error < StandardError
@@ -30,6 +30,8 @@ module Signum
30
30
  elsif signalable_receiver.respond_to?(:each)
31
31
  signalable_receiver.each { |signalable| signal(signalable, options) }
32
32
  nil
33
+ else
34
+ Signal.create!(options.merge(key: signalable_receiver.to_s))
33
35
  end
34
36
  end
35
37
 
@@ -37,28 +39,28 @@ module Signum
37
39
  def info(signalable, options)
38
40
  return unless signalable
39
41
 
40
- signal(signalable, options.merge(kind: 'info', icon: Signum.config.icons[:info]))
42
+ signal(signalable, options.merge(kind: "info", icon: Signum.config.icons[:info]))
41
43
  end
42
44
 
43
45
  # Signal about an error
44
46
  def error(signalable, options)
45
47
  return unless signalable
46
48
 
47
- signal(signalable, options.merge(kind: 'error', icon: Signum.config.icons[:error]))
49
+ signal(signalable, options.merge(kind: "error", icon: Signum.config.icons[:error]))
48
50
  end
49
51
 
50
52
  # Signal about something that went sucessfully
51
53
  def success(signalable, options)
52
54
  return unless signalable
53
55
 
54
- signal(signalable, options.merge(kind: 'success', icon: Signum.config.icons[:success]))
56
+ signal(signalable, options.merge(kind: "success", icon: Signum.config.icons[:success]))
55
57
  end
56
58
 
57
59
  # Signal about something that could go wrong
58
60
  def warning(signalable, options)
59
61
  return unless signalable
60
62
 
61
- signal(signalable, options.merge(kind: 'warning', icon: Signum.config.icons[:warning]))
63
+ signal(signalable, options.merge(kind: "warning", icon: Signum.config.icons[:warning]))
62
64
  end
63
65
  end
64
66
 
@@ -10,4 +10,4 @@ end
10
10
  if Rake::Task.task_defined?("tailwindcss:build")
11
11
  Rake::Task["tailwindcss:build"].enhance(["signum:tailwindcss:config"])
12
12
  Rake::Task["tailwindcss:watch"].enhance(["signum:tailwindcss:config"])
13
- end
13
+ end
data/signum.gemspec CHANGED
@@ -1,33 +1,37 @@
1
- $:.push File.expand_path('lib', __dir__)
1
+ $:.push File.expand_path("lib", __dir__)
2
2
 
3
3
  # Maintain your gem's version:
4
- require 'signum/version'
4
+ require "signum/version"
5
5
 
6
6
  # Describe your gem and declare its dependencies:
7
7
  Gem::Specification.new do |spec|
8
- spec.name = 'signum'
9
- spec.version = Signum::VERSION
10
- spec.authors = ['Tom de Grunt']
11
- spec.email = ['tom@degrunt.nl']
12
- spec.homepage = 'https://github.com/entdec/signum'
13
- spec.summary = 'Replacement for flash messages, also from background jobs'
14
- spec.description = 'Rails engine with replacement for flash messages, Signum allows for messages from background jobs.'
15
- spec.license = 'MIT'
8
+ spec.name = "signum"
9
+ spec.version = Signum::VERSION
10
+ spec.authors = ["Tom de Grunt"]
11
+ spec.email = ["tom@degrunt.nl"]
12
+ spec.homepage = "https://github.com/entdec/signum"
13
+ spec.summary = "Replacement for flash messages, also from background jobs"
14
+ spec.description = "Rails engine with replacement for flash messages, Signum allows for messages from background jobs."
15
+ spec.license = "MIT"
16
16
 
17
17
  spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
18
18
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
19
  end
20
20
 
21
- spec.add_dependency 'pg'
22
- spec.add_dependency 'rails', '> 6.0'
23
- spec.add_dependency 'state_machines-activerecord'
21
+ spec.add_dependency "pg"
22
+ spec.add_dependency "rails", "> 6.0"
23
+ spec.add_dependency "state_machines-activerecord"
24
24
 
25
- spec.add_development_dependency 'auxilium', '~> 3'
26
- spec.add_development_dependency 'sqlite3'
25
+ spec.add_development_dependency "auxilium", "~> 3"
26
+ spec.add_development_dependency "sqlite3"
27
27
 
28
28
  spec.add_dependency "slim-rails", "~> 3"
29
- spec.add_dependency 'tailwindcss-rails'
30
- spec.add_dependency 'importmap-rails'
31
- spec.add_dependency 'turbo-rails'
32
- spec.add_dependency 'stimulus-rails'
29
+ spec.add_dependency "tailwindcss-rails"
30
+ spec.add_dependency "importmap-rails"
31
+ spec.add_dependency "turbo-rails"
32
+ spec.add_dependency "stimulus-rails"
33
+ spec.add_dependency "view_component"
34
+ spec.add_development_dependency "debug", "~> 0"
35
+ spec.add_development_dependency "rubocop", "~> 1"
36
+ spec.add_development_dependency "standard", "~> 1"
33
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: signum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom de Grunt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-05 00:00:00.000000000 Z
11
+ date: 2024-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -150,6 +150,62 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: view_component
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: debug
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: rubocop
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '1'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '1'
195
+ - !ruby/object:Gem::Dependency
196
+ name: standard
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '1'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '1'
153
209
  description: Rails engine with replacement for flash messages, Signum allows for messages
154
210
  from background jobs.
155
211
  email:
@@ -160,6 +216,7 @@ extra_rdoc_files: []
160
216
  files:
161
217
  - ".github/workflows/gem-push.yml"
162
218
  - ".gitignore"
219
+ - ".rubocop.yml"
163
220
  - Gemfile
164
221
  - Gemfile.lock
165
222
  - MIT-LICENSE
@@ -205,6 +262,7 @@ files:
205
262
  - db/migrate/20230317123138_add_columns_to_signum_signal.rb
206
263
  - db/migrate/20231218095011_add_subject_to_signals.rb
207
264
  - db/migrate/20240405112807_add_links_and_buttons_to_signals.rb
265
+ - db/migrate/20240410100722_add_key_to_signal.rb
208
266
  - lib/generators/signum/install_generator.rb
209
267
  - lib/generators/signum/tailwind_config_generator.rb
210
268
  - lib/generators/signum/templates/config/initializers/signum.rb