noticed 3.1.1 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fc2c6ab467bf073d0c2a6a12ffc732e954fcd54d3f0099610453cc392029663f
|
|
4
|
+
data.tar.gz: 3d2aa10edb60dd0fe9305e17a1900085cac0f11fcd6a7c047197f39ffa14c5e7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bfc027430d08fdfd7c42a10cac55a68b6f615e4a3a925f8e65dae39af4c6d324a50732c470c71b50f7ad809b27c0359a7978da19c14f3a4314fc946ab7ec8698
|
|
7
|
+
data.tar.gz: db2689fd76253d9af75f2e9db3fa09178e49bd047dfb5bc8d71d68c25abeedd0a0bf45d239efcf8a816b93aae34b84885fc87b98133a636e361061e9edd2499a
|
data/README.md
CHANGED
|
@@ -76,6 +76,20 @@ To start, generate a Notifier:
|
|
|
76
76
|
rails generate noticed:notifier NewCommentNotifier
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
+
The generator also creates `app/notifiers/application_notifier.rb`, unless `ApplicationNotifier` is already defined (for example, by an engine). To inherit from another class instead, pass `--parent`:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
rails generate noticed:notifier NewCommentNotifier --parent BaseNotifier
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
To change the parent for every generated notifier, set it in `config/application.rb`:
|
|
86
|
+
|
|
87
|
+
```ruby
|
|
88
|
+
config.generators do |g|
|
|
89
|
+
g.notifier parent: "BaseNotifier"
|
|
90
|
+
end
|
|
91
|
+
```
|
|
92
|
+
|
|
79
93
|
### Usage Contents
|
|
80
94
|
- [Notifier Objects](#notifier-objects)
|
|
81
95
|
- [Delivery Method Configuration](#delivery-method-configuration)
|
|
@@ -612,7 +626,7 @@ If you want to build your own delivery method to deliver notifications to a spec
|
|
|
612
626
|
rails generate noticed:delivery_method Discord
|
|
613
627
|
```
|
|
614
628
|
|
|
615
|
-
This will generate a new `
|
|
629
|
+
This will generate a new `DeliveryMethods::Discord` class inside the `app/notifiers/delivery_methods` folder, which can be used to deliver notifications to Discord, plus an `ApplicationDeliveryMethod` if your app doesn’t already define one.
|
|
616
630
|
|
|
617
631
|
```ruby
|
|
618
632
|
class DeliveryMethods::Discord < ApplicationDeliveryMethod
|
|
@@ -15,13 +15,22 @@ module Noticed
|
|
|
15
15
|
|
|
16
16
|
def generate_notification
|
|
17
17
|
if options[:bulk]
|
|
18
|
-
|
|
18
|
+
generate_abstract_class "ApplicationBulkDeliveryMethod"
|
|
19
19
|
template "bulk_delivery_method.rb", "app/notifiers/bulk_delivery_methods/#{singular_name}.rb"
|
|
20
20
|
else
|
|
21
|
-
|
|
21
|
+
generate_abstract_class "ApplicationDeliveryMethod"
|
|
22
22
|
template "delivery_method.rb", "app/notifiers/delivery_methods/#{singular_name}.rb"
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
# The abstract class may be defined elsewhere, such as in an engine
|
|
29
|
+
def generate_abstract_class(name)
|
|
30
|
+
path = "app/notifiers/#{name.underscore}.rb"
|
|
31
|
+
return if name.safe_constantize || File.exist?(File.join(destination_root, path))
|
|
32
|
+
template "#{name.underscore}.rb", path
|
|
33
|
+
end
|
|
25
34
|
end
|
|
26
35
|
end
|
|
27
36
|
end
|
|
@@ -13,9 +13,15 @@ module Noticed
|
|
|
13
13
|
|
|
14
14
|
desc "Generates a notification with the given NAME."
|
|
15
15
|
|
|
16
|
+
class_option :parent, type: :string, default: "ApplicationNotifier", desc: "The parent class for the generated notifier"
|
|
17
|
+
|
|
18
|
+
# ApplicationNotifier may be defined elsewhere, such as in an engine
|
|
16
19
|
def generate_abstract_class
|
|
17
|
-
return
|
|
18
|
-
|
|
20
|
+
return unless parent == "ApplicationNotifier"
|
|
21
|
+
|
|
22
|
+
path = "app/notifiers/application_notifier.rb"
|
|
23
|
+
return if parent.safe_constantize || File.exist?(File.join(destination_root, path))
|
|
24
|
+
template "application_notifier.rb", path
|
|
19
25
|
end
|
|
20
26
|
|
|
21
27
|
def generate_notification
|
|
@@ -27,6 +33,10 @@ module Noticed
|
|
|
27
33
|
def file_name # :doc:
|
|
28
34
|
@_file_name ||= super.sub(/_notifier\z/i, "")
|
|
29
35
|
end
|
|
36
|
+
|
|
37
|
+
def parent
|
|
38
|
+
options[:parent]
|
|
39
|
+
end
|
|
30
40
|
end
|
|
31
41
|
end
|
|
32
42
|
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
#
|
|
3
3
|
# <%= class_name %>Notifier.with(record: @post, message: "New post").deliver(User.all)
|
|
4
4
|
|
|
5
|
-
class <%= class_name %>Notifier <
|
|
5
|
+
class <%= class_name %>Notifier < <%= parent %>
|
|
6
6
|
# Add your delivery methods
|
|
7
7
|
#
|
|
8
8
|
# deliver_by :email do |config|
|
data/lib/noticed/version.rb
CHANGED