signum 0.3.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +50 -0
  4. data/Rakefile +36 -0
  5. data/app/channels/signum/application_cable/channel.rb +8 -0
  6. data/app/channels/signum/application_cable/connection.rb +24 -0
  7. data/app/components/signum/notification/component.html.slim +24 -0
  8. data/app/components/signum/notification/component.rb +17 -0
  9. data/app/components/signum/notification/component.scss +34 -0
  10. data/app/components/signum/notification_drawer/component.html.slim +12 -0
  11. data/app/components/signum/notification_drawer/component.rb +10 -0
  12. data/app/components/signum/notification_drawer/component.scss +7 -0
  13. data/app/components/signum/notification_drawer_item/component.html.slim +14 -0
  14. data/app/components/signum/notification_drawer_item/component.rb +9 -0
  15. data/app/components/signum/notification_drawer_item/component.scss +0 -0
  16. data/app/controllers/signum/api_controller.rb +4 -0
  17. data/app/controllers/signum/application_controller.rb +5 -0
  18. data/app/controllers/signum/signal_controller.rb +19 -0
  19. data/app/helpers/signum/application_helper.rb +4 -0
  20. data/app/jobs/signum/application_job.rb +4 -0
  21. data/app/jobs/signum/send_signals_job.rb +13 -0
  22. data/app/mailers/signum/application_mailer.rb +6 -0
  23. data/app/models/signum/application_record.rb +5 -0
  24. data/app/models/signum/signal.rb +38 -0
  25. data/config/routes.rb +4 -0
  26. data/db/migrate/20201125175035_create_signum_signals.rb +16 -0
  27. data/lib/signum/active_record_helpers.rb +37 -0
  28. data/lib/signum/configuration.rb +13 -0
  29. data/lib/signum/engine.rb +13 -0
  30. data/lib/signum/version.rb +5 -0
  31. data/lib/signum.rb +58 -0
  32. metadata +144 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bd53f73e635b3003fe096e759fab32eecf11150eaf860c3e26e49b6d19850a6b
4
+ data.tar.gz: 7f483ba2ac476e62ac4bcfa664e95f734ac95d3c49c914fe3d936157520f50c8
5
+ SHA512:
6
+ metadata.gz: 61f04881271d2d6225144e60703f075c6b8f12265105b25f763f330edae371ee7e07d8edbe742fea57171a5d952fa3e3d6b9b5c2944b4c51305d234d5076abd4
7
+ data.tar.gz: 30284aaec38f11795f56635d9863c5220ab1b455ee554372521660746b1c685fd3d45737cce933c8e7821ce619e32dd6b12d5660b1bfae01b17647c8226bc416
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2020 Tom de Grunt
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # Signum
2
+
3
+ Short description and motivation.
4
+
5
+ ## Usage
6
+
7
+ How to use my plugin.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'signum'
15
+ ```
16
+
17
+ Add signum to your package.json:
18
+
19
+ ```
20
+ yarn add signum
21
+ ```
22
+
23
+ Add signum to your application.js:
24
+
25
+ ```
26
+ import { Signum } from "@entdec/signum"
27
+ // application is a Stimulus application
28
+ Signum.start(application)
29
+ ```
30
+
31
+ ## Use
32
+
33
+ In controllers, or from background jobs, basically anywhere you want you can use the following methods:
34
+
35
+ ```ruby
36
+ Signum.signal(Current.user, text: "Hello world!")
37
+ Signum.info(Current.user, text: "We're still here!")
38
+ Signum.error(Current.user, text: "Houston, we have a problem!")
39
+ Signum.success(Current.user, text: "The Eagle has landed!")
40
+ ```
41
+
42
+ Above we used the `Current.user` as the user to signal to.
43
+
44
+ ## Contributing
45
+
46
+ Contribution directions go here.
47
+
48
+ ## License
49
+
50
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,36 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
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')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+ load 'rails/tasks/statistics.rake'
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'test'
28
+ t.pattern = 'test/**/*_test.rb'
29
+ t.verbose = false
30
+ end
31
+
32
+ task default: :test
33
+
34
+ # Adds the Auxilium semver task
35
+ spec = Gem::Specification.find_by_name 'auxilium'
36
+ load "#{spec.gem_dir}/lib/tasks/semver.rake"
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Signum
4
+ module ApplicationCable
5
+ class Channel < ActionCable::Channel::Base
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Signum
4
+ module ApplicationCable
5
+ class Connection < ActionCable::Connection::Base
6
+ identified_by :current_user
7
+
8
+ def connect
9
+ self.current_user = find_verified_user
10
+ logger.add_tags 'ActionCable', current_user.name
11
+ end
12
+
13
+ private
14
+
15
+ def find_verified_user
16
+ if verified_user = env['warden'].user
17
+ verified_user
18
+ else
19
+ reject_unauthorized_connection
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ .signum-notification.hidden data-notification-timeout=@data[:timeout] data-controller="notification"
2
+ .p-4
3
+ .flex.items-start
4
+ .flex-shrink-0
5
+ - if @signal.kind == "success"
6
+ svg.signum-notification-icon-success[xmlns="http://www.w3.org/2000/svg" fill="none" viewbox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true"]
7
+ path[stroke-linecap="round" stroke-linejoin="round" d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"]
8
+ - elsif @signal.kind == "error"
9
+ svg.signum-notification-icon-error[xmlns="http://www.w3.org/2000/svg" fill="none" viewbox="0 0 24 24" stroke-width="1.5" stroke="currentColor"]
10
+ path[stroke-linecap="round" stroke-linejoin="round" d="M9.75 9.75l4.5 4.5m0-4.5l-4.5 4.5M21 12a9 9 0 11-18 0 9 9 0 0118 0z"]
11
+ - else
12
+ svg.svg.signum-notification-icon-info[xmlns="http://www.w3.org/2000/svg" fill="none" viewbox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true"]
13
+ path[stroke-linecap="round" stroke-linejoin="round" d="M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"]
14
+ .ml-3.w-0.flex-1.pt-0.5
15
+ p.signum-notification-title
16
+ = sanitize @signal.title
17
+ p.signum-notification-body
18
+ = sanitize @signal.text
19
+ .ml-4.flex.flex-shrink-0
20
+ button.signum-notification-button-close[type="button" data-action="notification#close"]
21
+ span.sr-only
22
+ | Close
23
+ svg.h-5.w-5[xmlns="http://www.w3.org/2000/svg" viewbox="0 0 20 20" fill="currentColor" aria-hidden="true"]
24
+ path[d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"]
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @param type [String] Classic notification type `error`, `alert` and `info` + custom `success`
4
+ # @param data [String, Hash] `String` for backward compatibility,
5
+ # `Hash` for the new functionality `{title: '', body: '', timeout: 5, countdown: false, action: { url: '', method: '', name: ''}}`.
6
+ # The `title` attribute for `Hash` is mandatory.
7
+ module Signum
8
+ module Notification
9
+ class Component < ViewComponent::Base
10
+ def initialize(signal, data: nil)
11
+ @signal = signal
12
+ @data = data.nil? ? {} : data.deep_symbolize_keys
13
+ @data[:timeout] ||= 5
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,34 @@
1
+ .signum-notification{
2
+ @apply pointer-events-auto w-full max-w-sm overflow-hidden rounded-lg bg-white shadow-lg ring-1 ring-black ring-opacity-5 mt-1;
3
+ }
4
+
5
+ .signum-notification-icon{
6
+ @apply h-6 w-6;
7
+ }
8
+
9
+ .signum-notification-icon-success{
10
+ @extend .signum-notification-icon;
11
+ @apply text-green-400;
12
+ }
13
+
14
+ .signum-notification-icon-error{
15
+ @extend .signum-notification-icon;
16
+ @apply text-red-400;
17
+ }
18
+
19
+ .signum-notification-icon-info{
20
+ @extend .signum-notification-icon;
21
+ @apply text-sky-400;
22
+ }
23
+
24
+ .signum-notification-title{
25
+ @apply text-sm font-medium text-gray-900;
26
+ }
27
+
28
+ .signum-notification-body{
29
+ @apply mt-1 text-sm text-gray-500;
30
+ }
31
+
32
+ .signum-notification-button-close{
33
+ @apply inline-flex rounded-md bg-white text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2;
34
+ }
@@ -0,0 +1,12 @@
1
+ div.text-left[data-controller="notification-drawer" data-action="mouseover->notification-drawer#show mouseleave->notification-drawer#hide"]
2
+ button.signum-notification-drawer-button
3
+ svg.w-6.h-6.hidden[xmlns="http://www.w3.org/2000/svg" fill="none" viewbox="0 0 24 24" stroke-width="1.5" stroke="currentColor" data-notification-drawer-target="alertbellicon"]
4
+ path[stroke-linecap="round" stroke-linejoin="round" d="M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75v-.7V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0M3.124 7.5A8.969 8.969 0 015.292 3m13.416 0a8.969 8.969 0 012.168 4.5"]
5
+
6
+ svg.w-6.h-6[xmlns="http://www.w3.org/2000/svg" fill="none" viewbox="0 0 24 24" stroke-width="1.5" stroke="currentColor" data-notification-drawer-target="bellicon"]
7
+ path[stroke-linecap="round" stroke-linejoin="round" d="M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75v-.7V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0"]
8
+
9
+ .signum-notification-drawer-tray.hidden[data-notification-drawer-target="submenu" id="#{@notification_container_id}"]
10
+ - if @signals.present?
11
+ - @signals.each do |signal|
12
+ = render(Signum::NotificationDrawerItem::Component.new(signal))
@@ -0,0 +1,10 @@
1
+ module Signum
2
+ module NotificationDrawer
3
+ class Component < ViewComponent::Base
4
+ def initialize(signals, notification_container_id)
5
+ @signals = signals
6
+ @notification_container_id = notification_container_id
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ .signum-notification-drawer-button{
2
+ @apply w-8 h-8 bg-white m-0 rounded-full text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 dark:bg-gray-900 dark:border-gray-700
3
+ }
4
+
5
+ .signum-notification-drawer-tray{
6
+ @apply absolute right-0 z-10 mx-1 w-1/3 origin-top-right divide-y divide-gray-100 rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 overflow-y-auto max-h-screen
7
+ }
@@ -0,0 +1,14 @@
1
+ .py-1.hover:bg-gray-50[data-controller="notification-drawer-item" data-action="click->notification-drawer-item#markRead" data-notification-drawer-target="item" class=('font-bold' if @signal.state != 'closed') data-notification-drawer-item-signal-state-value="#{@signal.state}" data-notification-drawer-item-signal-id-value="#{@signal.id}"]
2
+ .flex.items-center.px-4.py-2.text-sm.text-gray-500
3
+ .w-6.h-6.mr-1
4
+ - if @signal.kind == "success"
5
+ svg.signum-notification-icon-success[xmlns="http://www.w3.org/2000/svg" fill="none" viewbox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true"]
6
+ path[stroke-linecap="round" stroke-linejoin="round" d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"]
7
+ - elsif @signal.kind == "error"
8
+ svg.signum-notification-icon-error[xmlns="http://www.w3.org/2000/svg" fill="none" viewbox="0 0 24 24" stroke-width="1.5" stroke="currentColor"]
9
+ path[stroke-linecap="round" stroke-linejoin="round" d="M9.75 9.75l4.5 4.5m0-4.5l-4.5 4.5M21 12a9 9 0 11-18 0 9 9 0 0118 0z"]
10
+ - else
11
+ svg.signum-notification-icon-info[xmlns="http://www.w3.org/2000/svg" fill="none" viewbox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true"]
12
+ path[stroke-linecap="round" stroke-linejoin="round" d="M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"]
13
+ p
14
+ = sanitize @signal.text
@@ -0,0 +1,9 @@
1
+ module Signum
2
+ module NotificationDrawerItem
3
+ class Component < ViewComponent::Base
4
+ def initialize(signal)
5
+ @signal = signal
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,4 @@
1
+ module Signum
2
+ class ApiController < ActionController::API
3
+ end
4
+ end
@@ -0,0 +1,5 @@
1
+ module Signum
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+ end
5
+ end
@@ -0,0 +1,19 @@
1
+ module Signum
2
+ class SignalController < ApiController
3
+ def show
4
+ signal = Signum::Signal.find(signal_params[:id])
5
+ signal.show! if signal.broadcasted?
6
+ end
7
+
8
+ def close
9
+ signal = Signum::Signal.find(signal_params[:id])
10
+ signal.close!
11
+ end
12
+
13
+ private
14
+
15
+ def signal_params
16
+ params.require(:signal).permit(:id)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,4 @@
1
+ module Signum
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Signum
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Signum
4
+ class SendSignalsJob < ApplicationJob
5
+ def perform(signal)
6
+ signal.broadcast!
7
+ Turbo::StreamsChannel.broadcast_prepend_to(:signals, target: "notifications_#{signal.signalable_id}",
8
+ html: ApplicationController.render(Signum::Notification::Component.new(signal)))
9
+ Turbo::StreamsChannel.broadcast_prepend_to(:signals, target: "drawer_notifications_#{signal.signalable_id}",
10
+ html: ApplicationController.render(Signum::NotificationDrawerItem::Component.new(signal)))
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,6 @@
1
+ module Signum
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: 'from@example.com'
4
+ layout 'mailer'
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Signum
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,38 @@
1
+ module Signum
2
+ class Signal < ApplicationRecord
3
+ belongs_to :signalable, polymorphic: true
4
+ after_commit :signal
5
+
6
+ validates :text, presence: true
7
+
8
+ scope :pending, -> { with_state(:pending) }
9
+ scope :shown, -> { with_state(:shown) }
10
+ scope :closed, -> { with_state(:closed) }
11
+
12
+ state_machine initial: :pending do
13
+ state :pending
14
+ state :broadcasted
15
+ state :shown
16
+ state :closed
17
+
18
+ event :broadcast do
19
+ transition any => :broadcasted
20
+ end
21
+
22
+ event :show do
23
+ transition any => :shown
24
+ end
25
+
26
+ event :close do
27
+ # We allow pending, sent and shown, because the user could close, before we process
28
+ transition any => :closed
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def signal
35
+ Signum::SendSignalsJob.perform_later(self) if pending?
36
+ end
37
+ end
38
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ Signum::Engine.routes.draw do
2
+ post 'signal/show', to: 'signal#show'
3
+ post 'signal/close', to: 'signal#close'
4
+ end
@@ -0,0 +1,16 @@
1
+ class CreateSignumSignals < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :signum_signals, id: :uuid do |t|
4
+ t.string :state, default: 'pending'
5
+ t.references :signalable, polymorphic: true, optional: false, null: false, type: :uuid
6
+
7
+ t.string :kind, default: 'notice'
8
+ t.boolean :sticky
9
+ t.string :icon
10
+ t.string :title
11
+ t.text :text
12
+
13
+ t.timestamps
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Signum
4
+ module ActiveRecordHelpers
5
+ extend ActiveSupport::Concern
6
+
7
+ class_methods do
8
+ def signalable
9
+ has_many :signals, as: :signalable, class_name: 'Signum::Signal'
10
+
11
+ send :include, Signum::ActiveRecordHelpers::InstanceMethods
12
+ extend(Signum::ActiveRecordHelpers::ClassMethods)
13
+ end
14
+ end
15
+
16
+ module ClassMethods
17
+ end
18
+
19
+ module InstanceMethods
20
+ def online!
21
+ update(presence: 'online')
22
+ end
23
+
24
+ def offline!
25
+ update(presence: 'offline')
26
+ end
27
+
28
+ def appeared!
29
+ update(presence: 'appeared')
30
+ end
31
+
32
+ def away!
33
+ update(presence: 'away')
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Signum
4
+ class Configuration
5
+ attr_accessor :hide_after
6
+ attr_accessor :user_model_name
7
+
8
+ def initialize
9
+ @user_model_name = "User"
10
+ @hide_after = 3000
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module Signum
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Signum
4
+
5
+ initializer :append_migrations do |app|
6
+ unless app.root.to_s.match? root.to_s
7
+ config.paths['db/migrate'].expanded.each do |expanded_path|
8
+ app.config.paths['db/migrate'] << expanded_path
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Signum
4
+ VERSION = '0.3.12'
5
+ end
data/lib/signum.rb ADDED
@@ -0,0 +1,58 @@
1
+ require "signum/engine"
2
+ require "signum/active_record_helpers"
3
+ require "signum/configuration"
4
+
5
+ module Signum
6
+ class Error < StandardError
7
+ end
8
+
9
+ class << self
10
+ def config
11
+ @config ||= Configuration.new
12
+ end
13
+
14
+ def setup
15
+ @config = Configuration.new
16
+ yield config
17
+ end
18
+
19
+ # def i18n_store
20
+ # @i18n_store ||= Nuntius::I18nStore.new
21
+ # end
22
+
23
+ # Generic notice
24
+ def signal(signalable_receiver, options)
25
+ return unless signalable_receiver
26
+
27
+ if signalable_receiver.is_a?(Signum.config.user_model_name.constantize)
28
+ signalable_receiver.signals.create!(options)
29
+ elsif signalable_receiver.respond_to?(:each)
30
+ signalable_receiver.each { |signalable| signal(signalable, options) }
31
+ end
32
+ end
33
+
34
+ # Signal about something that happened
35
+ def info(signalable, options)
36
+ return unless signalable
37
+
38
+ signal(signalable, options.merge(kind: "info"))
39
+ end
40
+
41
+ # Signal about an error
42
+ def error(signalable, options)
43
+ return unless signalable
44
+
45
+ signal(signalable, options.merge(kind: "error"))
46
+ end
47
+
48
+ # Signal about something that went sucessfully
49
+ def success(signalable, options)
50
+ return unless signalable
51
+
52
+ signal(signalable, options.merge(kind: "success"))
53
+ end
54
+ end
55
+
56
+ # Include helpers
57
+ ActiveSupport.on_load(:active_record) { include ActiveRecordHelpers }
58
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: signum
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.12
5
+ platform: ruby
6
+ authors:
7
+ - Tom de Grunt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-12-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pg
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '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'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">"
32
+ - !ruby/object:Gem::Version
33
+ version: '6.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">"
39
+ - !ruby/object:Gem::Version
40
+ version: '6.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: state_machines-activemodel
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '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'
55
+ - !ruby/object:Gem::Dependency
56
+ name: auxilium
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sqlite3
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Rails engine with replacement for flash messages, Signum allows for messages
84
+ from background jobs.
85
+ email:
86
+ - tom@degrunt.nl
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - MIT-LICENSE
92
+ - README.md
93
+ - Rakefile
94
+ - app/channels/signum/application_cable/channel.rb
95
+ - app/channels/signum/application_cable/connection.rb
96
+ - app/components/signum/notification/component.html.slim
97
+ - app/components/signum/notification/component.rb
98
+ - app/components/signum/notification/component.scss
99
+ - app/components/signum/notification_drawer/component.html.slim
100
+ - app/components/signum/notification_drawer/component.rb
101
+ - app/components/signum/notification_drawer/component.scss
102
+ - app/components/signum/notification_drawer_item/component.html.slim
103
+ - app/components/signum/notification_drawer_item/component.rb
104
+ - app/components/signum/notification_drawer_item/component.scss
105
+ - app/controllers/signum/api_controller.rb
106
+ - app/controllers/signum/application_controller.rb
107
+ - app/controllers/signum/signal_controller.rb
108
+ - app/helpers/signum/application_helper.rb
109
+ - app/jobs/signum/application_job.rb
110
+ - app/jobs/signum/send_signals_job.rb
111
+ - app/mailers/signum/application_mailer.rb
112
+ - app/models/signum/application_record.rb
113
+ - app/models/signum/signal.rb
114
+ - config/routes.rb
115
+ - db/migrate/20201125175035_create_signum_signals.rb
116
+ - lib/signum.rb
117
+ - lib/signum/active_record_helpers.rb
118
+ - lib/signum/configuration.rb
119
+ - lib/signum/engine.rb
120
+ - lib/signum/version.rb
121
+ homepage: https://github.com/entdec/signum
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubygems_version: 3.3.7
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: Replacement for flash messages, also from background jobs
144
+ test_files: []