gossiper 0.3.4 → 0.3.5
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 +4 -4
- data/app/models/gossiper/notification.rb +11 -14
- data/db/migrate/20131206162038_create_gossiper_notifications.rb +1 -1
- data/lib/generators/gossiper/install/templates/initializer.rb +5 -3
- data/lib/generators/gossiper/notification_type/templates/notification_type.rb +15 -4
- data/lib/gossiper/configuration.rb +1 -0
- data/lib/gossiper/email_config.rb +10 -2
- data/lib/gossiper/mailer.rb +6 -15
- data/lib/gossiper/version.rb +1 -1
- metadata +2 -3
- data/app/helpers/gossiper/application_helper.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc1480aab310d0621df06090ef44c953c3422cc6
|
4
|
+
data.tar.gz: f0bf08f5a7c011c1110435016dde51829bb1d53b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f033f5024be39161393719659a7408a3c4b4cea217a1457f2dcbfb1193f7ae95cc78cd51ab8f1d334a2fb9e83868bdaa8af3a18537d1a2d72fb617236a1a8e33
|
7
|
+
data.tar.gz: b3cc4b64668113a7fe3f7c7caad4010a550d02b51fca04a5fcbd3217ca6a3b526f4fa4b58b3a6211d89d1689c7e2d65a2c44e02f1b257fa6dfa5415e95de78c7
|
@@ -6,20 +6,7 @@ module Gossiper
|
|
6
6
|
serialize :data, JSON
|
7
7
|
|
8
8
|
validates :kind, presence: true
|
9
|
-
|
10
|
-
def user=(user)
|
11
|
-
@user = user
|
12
|
-
self.user_class = user.class.to_s
|
13
|
-
self.user_id = user.id
|
14
|
-
end
|
15
|
-
|
16
|
-
def user
|
17
|
-
@user ||= user_class.constantize.find(user_id)
|
18
|
-
end
|
19
|
-
|
20
|
-
def user_class
|
21
|
-
read_attribute(:user_class).presence || Gossiper.configuration.default_notification_user_class
|
22
|
-
end
|
9
|
+
belongs_to :user, polymorphic: true
|
23
10
|
|
24
11
|
def status
|
25
12
|
read_attribute(:status).presence || STATUSES.first
|
@@ -44,6 +31,16 @@ module Gossiper
|
|
44
31
|
write_attribute(:kind, value)
|
45
32
|
end
|
46
33
|
|
34
|
+
def config
|
35
|
+
begin
|
36
|
+
klass = "Notifications::#{kind.classify}Notification"
|
37
|
+
klass.constantize.new(self)
|
38
|
+
rescue NameError
|
39
|
+
klass = Gossiper.configuration.default_notification_config_class
|
40
|
+
klass.constantize.new(self)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
47
44
|
def method_missing(method, *args, &block)
|
48
45
|
STATUSES.each do |status|
|
49
46
|
if method.to_s == "#{status}?"
|
@@ -1,14 +1,16 @@
|
|
1
1
|
<%- test_folder = defined?(RSpec) ? 'spec' : 'test' -%>
|
2
2
|
Gossiper.configure do |config|
|
3
|
-
# Change the default user class
|
4
|
-
config.default_notification_user_class = 'User'
|
5
3
|
|
6
4
|
# change the default class of the configurations
|
7
5
|
config.default_notification_config_class = 'Gossiper::EmailConfig'
|
8
6
|
|
9
|
-
#
|
7
|
+
# the email sender
|
10
8
|
config.default_from = 'from@example.com'
|
11
9
|
|
10
|
+
# the default reply to
|
11
|
+
# when not present, it defaults to the same email addres ass the default_from
|
12
|
+
# config.default_reply_to = 'reply@example.com'
|
13
|
+
|
12
14
|
# The list of emails to send copies to
|
13
15
|
# config.default_cc = ['user@example.com']
|
14
16
|
|
@@ -1,13 +1,19 @@
|
|
1
1
|
module Notifications
|
2
2
|
class <%= class_name %>Notification < Gossiper::EmailConfig
|
3
3
|
|
4
|
-
# def
|
4
|
+
# def initialize(notification)
|
5
5
|
# end
|
6
6
|
|
7
|
-
# def
|
7
|
+
# def from
|
8
8
|
# end
|
9
9
|
|
10
|
-
# def
|
10
|
+
# def reply_to
|
11
|
+
# end
|
12
|
+
|
13
|
+
# def to
|
14
|
+
# end
|
15
|
+
|
16
|
+
# def bcc
|
11
17
|
# end
|
12
18
|
|
13
19
|
# def cc
|
@@ -21,12 +27,17 @@ module Notifications
|
|
21
27
|
|
22
28
|
# def subject
|
23
29
|
# end
|
30
|
+
#
|
31
|
+
# def subject_variables
|
32
|
+
# {}
|
33
|
+
# end
|
24
34
|
|
25
35
|
# def attachments
|
36
|
+
# {}
|
26
37
|
# end
|
27
38
|
|
28
39
|
# def instance_variables
|
40
|
+
# {}
|
29
41
|
# end
|
30
|
-
|
31
42
|
end
|
32
43
|
end
|
@@ -4,13 +4,17 @@ module Gossiper
|
|
4
4
|
|
5
5
|
def initialize(notification)
|
6
6
|
@notification = notification
|
7
|
-
@user
|
7
|
+
@user = notification.user rescue nil
|
8
8
|
end
|
9
9
|
|
10
10
|
def from
|
11
11
|
config.default_from
|
12
12
|
end
|
13
13
|
|
14
|
+
def reply_to
|
15
|
+
config.default_reply_to.presence || config.default_from
|
16
|
+
end
|
17
|
+
|
14
18
|
def to
|
15
19
|
if user.respond_to?(:name)
|
16
20
|
["#{user.name} <#{user.email}>"]
|
@@ -36,7 +40,7 @@ module Gossiper
|
|
36
40
|
end
|
37
41
|
|
38
42
|
def subject
|
39
|
-
I18n.t("gossiper.notifications.#{notification.kind}.subject")
|
43
|
+
I18n.t("gossiper.notifications.#{notification.kind}.subject", subject_variables)
|
40
44
|
end
|
41
45
|
|
42
46
|
def attachments
|
@@ -47,6 +51,10 @@ module Gossiper
|
|
47
51
|
{}
|
48
52
|
end
|
49
53
|
|
54
|
+
def subject_variables
|
55
|
+
{}
|
56
|
+
end
|
57
|
+
|
50
58
|
private
|
51
59
|
def config
|
52
60
|
Gossiper.configuration
|
data/lib/gossiper/mailer.rb
CHANGED
@@ -2,7 +2,7 @@ module Gossiper
|
|
2
2
|
class Mailer < ActionMailer::Base
|
3
3
|
|
4
4
|
def mail_for(notification)
|
5
|
-
config =
|
5
|
+
config = notification.config
|
6
6
|
|
7
7
|
config.attachments.each do |filename, file|
|
8
8
|
attachments[filename] = file
|
@@ -15,25 +15,16 @@ module Gossiper
|
|
15
15
|
end
|
16
16
|
|
17
17
|
mail(
|
18
|
-
from:
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
from: config.from,
|
19
|
+
reply_to: config.reply_to,
|
20
|
+
to: config.to,
|
21
|
+
cc: config.cc,
|
22
|
+
bcc: config.bcc,
|
22
23
|
subject: config.subject,
|
23
24
|
template_name: config.template_name,
|
24
25
|
template_path: config.template_path
|
25
26
|
)
|
26
27
|
end
|
27
28
|
|
28
|
-
def config_for(notification)
|
29
|
-
begin
|
30
|
-
klass = "Notifications::#{notification.kind.classify}Notification"
|
31
|
-
klass.constantize.new(notification)
|
32
|
-
rescue NameError
|
33
|
-
klass = Gossiper.configuration.default_notification_config_class
|
34
|
-
klass.constantize.new(notification)
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
29
|
end
|
39
30
|
end
|
data/lib/gossiper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gossiper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcelo Jacobus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sqlite3
|
@@ -124,7 +124,6 @@ files:
|
|
124
124
|
- app/assets/stylesheets/gossiper/application.css
|
125
125
|
- app/assets/stylesheets/gossiper/notifications.css
|
126
126
|
- app/helpers/gossiper/notifications_helper.rb
|
127
|
-
- app/helpers/gossiper/application_helper.rb
|
128
127
|
- app/models/gossiper/notification.rb
|
129
128
|
- app/views/layouts/gossiper/application.html.erb
|
130
129
|
- app/views/kaminari/_gap.html.erb
|