caffeinate 0.16.0 → 2.0.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 +4 -4
- data/README.md +6 -1
- data/app/models/caffeinate/campaign.rb +4 -3
- data/app/models/caffeinate/campaign_subscription.rb +2 -13
- data/lib/caffeinate/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 267d93d746f23525a65cf5607ef0b4c67195cd9c14260d3f8b9b346cfdeb8ffe
|
4
|
+
data.tar.gz: c3851e78e0ddd35f5735aaa70ce9360cf242ab9ede3e6c6a74700b07c59ad16e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f81b1310248f890a74c37b290d5860f6562763d567ec9fe07ca3aeff27f8aa7a48ff0bb071797f8cef022cdb76ea403a12bdce8f76afae5d1a929c805209cbdf
|
7
|
+
data.tar.gz: efe9b9a8306b3c832d04218b11c10c5772319b38206de5e1c141e1f15a494ab73ec069ea19cddfe2d570edb155d14520f4bdf1525b3eb8a849718bc7e895ab05
|
data/README.md
CHANGED
@@ -16,13 +16,18 @@
|
|
16
16
|
|
17
17
|
# Caffeinate
|
18
18
|
|
19
|
-
|
20
19
|
Caffeinate is a drip email engine for managing, creating, and sending scheduled email sequences from your Ruby on Rails application.
|
21
20
|
|
22
21
|
Caffeinate provides a simple DSL to create scheduled email sequences which can be used by ActionMailer without any additional configuration.
|
23
22
|
|
24
23
|
There's a cool demo with all the things included at [caffeinate.email](https://caffeinate.email). You can view the [marketing site source code here](https://github.com/joshmn/caffeinate-marketing).
|
25
24
|
|
25
|
+
## Is this thing dead?
|
26
|
+
|
27
|
+
No! Not at all!
|
28
|
+
|
29
|
+
There's not a lot of activity here because it's stable and working! I am more than happy to entertain new features.
|
30
|
+
|
26
31
|
## Do you suffer from ActionMailer tragedies?
|
27
32
|
|
28
33
|
If you have _anything_ like this is your codebase, **you need Caffeinate**:
|
@@ -14,6 +14,7 @@ module Caffeinate
|
|
14
14
|
# Campaign ties together subscribers and mailings, and provides one core model for handling your Drippers.
|
15
15
|
class Campaign < ApplicationRecord
|
16
16
|
self.table_name = 'caffeinate_campaigns'
|
17
|
+
class NoSubscription < ::ActiveRecord::RecordInvalid; end
|
17
18
|
|
18
19
|
has_many :caffeinate_campaign_subscriptions, class_name: 'Caffeinate::CampaignSubscription', foreign_key: :caffeinate_campaign_id
|
19
20
|
has_many :subscriptions, class_name: 'Caffeinate::CampaignSubscription', foreign_key: :caffeinate_campaign_id
|
@@ -66,7 +67,7 @@ module Caffeinate
|
|
66
67
|
def unsubscribe!(subscriber, **args)
|
67
68
|
reason = args.delete(:reason)
|
68
69
|
subscription = subscriber(subscriber, **args)
|
69
|
-
raise
|
70
|
+
raise NoSubscription, subscription if subscription.nil?
|
70
71
|
|
71
72
|
subscription.unsubscribe!(reason)
|
72
73
|
end
|
@@ -74,12 +75,12 @@ module Caffeinate
|
|
74
75
|
# Creates a `CampaignSubscription` object for the present Campaign. Allows passing `**args` to
|
75
76
|
# delegate additional arguments to the record. Uses `find_or_create_by`.
|
76
77
|
def subscribe(subscriber, **args)
|
77
|
-
caffeinate_campaign_subscriptions.
|
78
|
+
caffeinate_campaign_subscriptions.find_or_create_by(subscriber: subscriber, **args)
|
78
79
|
end
|
79
80
|
|
80
81
|
# Subscribes an object to a campaign. Raises `ActiveRecord::RecordInvalid` if the record was invalid.
|
81
82
|
def subscribe!(subscriber, **args)
|
82
|
-
caffeinate_campaign_subscriptions.
|
83
|
+
caffeinate_campaign_subscriptions.find_or_create_by!(subscriber: subscriber, **args)
|
83
84
|
end
|
84
85
|
end
|
85
86
|
end
|
@@ -55,7 +55,7 @@ module Caffeinate
|
|
55
55
|
|
56
56
|
before_validation :call_dripper_before_subscribe_blocks!, on: :create
|
57
57
|
|
58
|
-
|
58
|
+
after_create :create_mailings!
|
59
59
|
|
60
60
|
after_commit :on_complete, if: :completed?
|
61
61
|
|
@@ -131,18 +131,7 @@ module Caffeinate
|
|
131
131
|
true
|
132
132
|
end
|
133
133
|
|
134
|
-
#
|
135
|
-
# Use `force` to forcefully reset. Does not create the mailings.
|
136
|
-
def resubscribe!(force = false)
|
137
|
-
return false if ended? && !force
|
138
|
-
return false if unsubscribed? && !force
|
139
|
-
|
140
|
-
result = update(unsubscribed_at: nil, resubscribed_at: ::Caffeinate.config.time_now)
|
141
|
-
|
142
|
-
caffeinate_campaign.to_dripper.run_callbacks(:on_resubscribe, self)
|
143
|
-
result
|
144
|
-
end
|
145
|
-
|
134
|
+
# Checks if the record is not new and if mailings are all gone.
|
146
135
|
def completed?
|
147
136
|
caffeinate_mailings.unsent.count.zero?
|
148
137
|
end
|
data/lib/caffeinate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caffeinate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Brody
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -200,7 +200,7 @@ homepage: https://github.com/joshmn/caffeinate
|
|
200
200
|
licenses:
|
201
201
|
- MIT
|
202
202
|
metadata: {}
|
203
|
-
post_install_message:
|
203
|
+
post_install_message:
|
204
204
|
rdoc_options: []
|
205
205
|
require_paths:
|
206
206
|
- lib
|
@@ -215,8 +215,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
215
|
- !ruby/object:Gem::Version
|
216
216
|
version: '0'
|
217
217
|
requirements: []
|
218
|
-
rubygems_version: 3.
|
219
|
-
signing_key:
|
218
|
+
rubygems_version: 3.1.4
|
219
|
+
signing_key:
|
220
220
|
specification_version: 4
|
221
221
|
summary: Create, manage, and send scheduled email sequences and drip campaigns from
|
222
222
|
your Rails app.
|