noticed 1.6.0 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/noticed/model/base_generator.rb +48 -0
- data/lib/generators/noticed/model/mysql_generator.rb +18 -0
- data/lib/generators/noticed/model/postgresql_generator.rb +18 -0
- data/lib/generators/noticed/model/sqlite3_generator.rb +18 -0
- data/lib/noticed/delivery_methods/email.rb +3 -3
- data/lib/noticed/model.rb +5 -1
- data/lib/noticed/version.rb +1 -1
- data/lib/rails_6_polyfills/actioncable/test_helper.rb +1 -1
- metadata +7 -73
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dec51920d13ba117cce592dc0545e22d5618528033e736b267238a8456cf8341
|
4
|
+
data.tar.gz: 503d20af8d1640173e066e99fe3c8794155666d1f84456731253de6524f1d8e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d05f0f58b8d10e06782472cca617de0ba0140e42ffa0a7995adf80467fa88ae49f7656e0dd3c52d4e3130e9c3908543e5b72d05884431940422b092c50b7258
|
7
|
+
data.tar.gz: 602e15164492cf2de75d6b3b43a33d67312fdd18fa0cd42fd1b3a6d4f3397ab5d283b2346a3b019dfb9dd7f79b265387b927e135fb41e560fb3fa13ba0d99d7a
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/generators/named_base"
|
4
|
+
|
5
|
+
module Noticed
|
6
|
+
module Generators
|
7
|
+
module Model
|
8
|
+
class BaseGenerator < Rails::Generators::NamedBase
|
9
|
+
include Rails::Generators::ResourceHelpers
|
10
|
+
|
11
|
+
source_root File.expand_path("../templates", __FILE__)
|
12
|
+
|
13
|
+
desc "Generates a Notification model for storing notifications."
|
14
|
+
|
15
|
+
argument :name, type: :string, default: "Notification", banner: "Notification"
|
16
|
+
argument :attributes, type: :array, default: [], banner: "field:type field:type"
|
17
|
+
|
18
|
+
def generate_notification
|
19
|
+
binding.irb
|
20
|
+
generate :model, name, "recipient:references{polymorphic}", "type", "params:#{json_column_type}", "read_at:datetime:index", *attributes
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_noticed_model
|
24
|
+
inject_into_class model_path, class_name, " include Noticed::Model\n"
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_not_nullable
|
28
|
+
migration_path = Dir.glob(Rails.root.join("db/migrate/*")).max_by { |f| File.mtime(f) }
|
29
|
+
|
30
|
+
# Force is required because null: false already exists in the file and Thor isn't smart enough to tell the difference
|
31
|
+
insert_into_file migration_path, after: "t.string :type", force: true do
|
32
|
+
", null: false"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def done
|
37
|
+
readme "README" if behavior == :invoke
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def model_path
|
43
|
+
@model_path ||= File.join("app", "models", "#{file_path}.rb")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/generators/named_base"
|
4
|
+
require_relative "base_generator"
|
5
|
+
|
6
|
+
module Noticed
|
7
|
+
module Generators
|
8
|
+
module Model
|
9
|
+
class MysqlGenerator < BaseGenerator
|
10
|
+
private
|
11
|
+
|
12
|
+
def json_column_type
|
13
|
+
"json"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/generators/named_base"
|
4
|
+
require_relative "base_generator"
|
5
|
+
|
6
|
+
module Noticed
|
7
|
+
module Generators
|
8
|
+
module Model
|
9
|
+
class PostgresqlGenerator < BaseGenerator
|
10
|
+
private
|
11
|
+
|
12
|
+
def json_column_type
|
13
|
+
"jsonb"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/generators/named_base"
|
4
|
+
require_relative "base_generator"
|
5
|
+
|
6
|
+
module Noticed
|
7
|
+
module Generators
|
8
|
+
module Model
|
9
|
+
class Sqlite3Generator < BaseGenerator
|
10
|
+
private
|
11
|
+
|
12
|
+
def json_column_type
|
13
|
+
"json"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -5,9 +5,9 @@ module Noticed
|
|
5
5
|
|
6
6
|
def deliver
|
7
7
|
if options[:enqueue]
|
8
|
-
mailer.with(format).send(
|
8
|
+
mailer.with(format).send(mailer_method.to_sym).deliver_later
|
9
9
|
else
|
10
|
-
mailer.with(format).send(
|
10
|
+
mailer.with(format).send(mailer_method.to_sym).deliver_now
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -33,7 +33,7 @@ module Noticed
|
|
33
33
|
# If notification responds to symbol, call that method and use return value
|
34
34
|
# If notification does not respond to symbol, use the symbol for the mailer method
|
35
35
|
# Otherwise, use the underscored notification class name as the mailer method
|
36
|
-
def
|
36
|
+
def mailer_method
|
37
37
|
method_name = options[:method]&.to_sym
|
38
38
|
if method_name.present?
|
39
39
|
notification.respond_to?(method_name) ? notification.send(method_name) : method_name
|
data/lib/noticed/model.rb
CHANGED
@@ -13,7 +13,11 @@ module Noticed
|
|
13
13
|
included do
|
14
14
|
self.inheritance_column = nil
|
15
15
|
|
16
|
-
|
16
|
+
if Rails.gem_version >= Gem::Version.new("7.1")
|
17
|
+
serialize :params, coder: noticed_coder
|
18
|
+
else
|
19
|
+
serialize :params, noticed_coder
|
20
|
+
end
|
17
21
|
|
18
22
|
belongs_to :recipient, polymorphic: true
|
19
23
|
|
data/lib/noticed/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: noticed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Oliver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -38,76 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 4.0.0
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: pg
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
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: standard
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: webmock
|
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
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: mysql2
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: sqlite3
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
41
|
description: Database, browser, realtime ActionCable, Email, SMS, Slack notifications,
|
112
42
|
and more for Rails apps
|
113
43
|
email:
|
@@ -120,6 +50,10 @@ files:
|
|
120
50
|
- README.md
|
121
51
|
- Rakefile
|
122
52
|
- lib/generators/noticed/delivery_method_generator.rb
|
53
|
+
- lib/generators/noticed/model/base_generator.rb
|
54
|
+
- lib/generators/noticed/model/mysql_generator.rb
|
55
|
+
- lib/generators/noticed/model/postgresql_generator.rb
|
56
|
+
- lib/generators/noticed/model/sqlite3_generator.rb
|
123
57
|
- lib/generators/noticed/model_generator.rb
|
124
58
|
- lib/generators/noticed/notification_generator.rb
|
125
59
|
- lib/generators/noticed/templates/README
|
@@ -170,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
104
|
- !ruby/object:Gem::Version
|
171
105
|
version: '0'
|
172
106
|
requirements: []
|
173
|
-
rubygems_version: 3.
|
107
|
+
rubygems_version: 3.4.12
|
174
108
|
signing_key:
|
175
109
|
specification_version: 4
|
176
110
|
summary: Notifications for Ruby on Rails applications
|