digestifier 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -1
- data/app/models/digestifier/setting.rb +1 -2
- data/db/migrate/3_add_enabled_to_settings.rb +6 -0
- data/digestifier.gemspec +1 -1
- data/lib/digestifier/delivery.rb +16 -3
- data/spec/acceptance/recipient_preferences_spec.rb +14 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc2bff6ead8753dd54d921694f2b63d050a75c04
|
4
|
+
data.tar.gz: e12e3a4577b2402543f642a8f912fb391888d9e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0caf0b5098f15efe9f3c3778a45e67c6fa981f9e35f7623023c8dfb80c1e5828f5938ae1d2f2d9563e07e2f27b1b304b09f68c2169334325327b3c5266d6f803
|
7
|
+
data.tar.gz: d8a0bc60a634fde41e4cfdd03f36d71d4ce606647df4f3fd954706ab9001bef5a5073626b22bfd5cef71b0e38116942d65a87691b03cc99f820667956561cfe9
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ A simple Rails engine for sending out email digests of activity.
|
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
gem 'digestifier', '0.0.
|
9
|
+
gem 'digestifier', '0.0.3'
|
10
10
|
|
11
11
|
Don't forget to bundle:
|
12
12
|
|
@@ -58,6 +58,12 @@ task :send_digest => :environment do
|
|
58
58
|
end
|
59
59
|
```
|
60
60
|
|
61
|
+
You can test sending an email to a specific recipient using the following code:
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
Digestifier::Delivery.new(DIGEST, recipient).deliver
|
65
|
+
```
|
66
|
+
|
61
67
|
### Customising partial templates
|
62
68
|
|
63
69
|
This step is almost certainly essential: you'll want to customise how each item in your digest is presented. The partials for this should be located in `app/views/digestifier/mailer`, and use the item's class name, downcased and underscored (for example: `_article.html.erb` or `_comment.html.haml`).
|
@@ -82,6 +88,16 @@ The two instance variables you have access to are `@recipient` and `@content_ite
|
|
82
88
|
<% end %>
|
83
89
|
```
|
84
90
|
|
91
|
+
Also: you'll very likely want to customise the email's subject - this is done via Rails' internationalisation:
|
92
|
+
|
93
|
+
```yaml
|
94
|
+
en:
|
95
|
+
digestifier:
|
96
|
+
mailer:
|
97
|
+
digest:
|
98
|
+
subject: "The Latest News"
|
99
|
+
```
|
100
|
+
|
85
101
|
### Customising the mailer
|
86
102
|
|
87
103
|
If you want to put your own Mailer, then this is certainly possible:
|
data/digestifier.gemspec
CHANGED
data/lib/digestifier/delivery.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
class Digestifier::Delivery
|
2
2
|
def self.deliver(digest)
|
3
3
|
digest.recipients.call.find_each do |recipient|
|
4
|
-
new(digest, recipient).
|
4
|
+
new(digest, recipient).deliver_and_capture
|
5
5
|
end
|
6
6
|
end
|
7
7
|
|
@@ -9,9 +9,19 @@ class Digestifier::Delivery
|
|
9
9
|
@digest, @recipient = digest, recipient
|
10
10
|
end
|
11
11
|
|
12
|
+
def capture
|
13
|
+
Digestifier::Receipt.capture recipient
|
14
|
+
end
|
15
|
+
|
12
16
|
def deliver
|
17
|
+
return unless settings.enabled?
|
18
|
+
|
13
19
|
Digestifier.mailer.digest(recipient, contents).deliver
|
14
|
-
|
20
|
+
end
|
21
|
+
|
22
|
+
def deliver_and_capture
|
23
|
+
deliver
|
24
|
+
capture
|
15
25
|
end
|
16
26
|
|
17
27
|
private
|
@@ -25,7 +35,6 @@ class Digestifier::Delivery
|
|
25
35
|
end
|
26
36
|
|
27
37
|
def frequency
|
28
|
-
settings = Digestifier::Setting.for recipient
|
29
38
|
return default_frequency unless settings.preferences['frequency']
|
30
39
|
|
31
40
|
settings.preferences['frequency']
|
@@ -35,4 +44,8 @@ class Digestifier::Delivery
|
|
35
44
|
receipt = Digestifier::Receipt.last_for(recipient)
|
36
45
|
receipt.nil? ? frequency.ago : receipt.captured_at
|
37
46
|
end
|
47
|
+
|
48
|
+
def settings
|
49
|
+
@settings ||= Digestifier::Setting.for recipient
|
50
|
+
end
|
38
51
|
end
|
@@ -29,4 +29,18 @@ describe 'Custom digest frequency' do
|
|
29
29
|
expect(mail.body).to match(/Recent Post/)
|
30
30
|
expect(mail.body).to_not match(/Old Post/)
|
31
31
|
end
|
32
|
+
|
33
|
+
it 'respects disabled digest preferences' do
|
34
|
+
Article.create! name: 'Recent Post'
|
35
|
+
|
36
|
+
setting = Digestifier::Setting.for(user)
|
37
|
+
setting.enabled = false
|
38
|
+
setting.save!
|
39
|
+
|
40
|
+
Digestifier::Delivery.deliver digest
|
41
|
+
|
42
|
+
ActionMailer::Base.deliveries.detect { |mail|
|
43
|
+
mail.to.include?('me@somewhere.com')
|
44
|
+
}.should be_nil
|
45
|
+
end
|
32
46
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: digestifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Allan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- config.ru
|
89
89
|
- db/migrate/1_create_receipts.rb
|
90
90
|
- db/migrate/2_create_settings.rb
|
91
|
+
- db/migrate/3_add_enabled_to_settings.rb
|
91
92
|
- digestifier.gemspec
|
92
93
|
- lib/digestifier.rb
|
93
94
|
- lib/digestifier/delivery.rb
|