caffeinate 0.16.0 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ea20b479c229cc1a535ede3e35ef0f37d3ee57ad146f429937ee66016bd871f
4
- data.tar.gz: e361cb2d6a4562a3f3ca83a29e6ae29c38ca03fb5012b368909d7e8706504df3
3
+ metadata.gz: bb48d50e2800e8fb0f43b61dc0cf4b241990a1221ca1d841160a3a845d7fbb47
4
+ data.tar.gz: 6374ac7daac72c68a035ff51bf97803e0ed080f3c0ceed8d4848729773bd6a41
5
5
  SHA512:
6
- metadata.gz: 409337f24f2d2fbe1837632d86211767acb73fbdb84bcaba35f5352ec713b81955a784a59385c37c892d468ee978e57419fa54406c3bb0907a0c84372890fbe5
7
- data.tar.gz: 6f2988ab65ed1c8b7af248ab4ce0ed2ce2d1989bd5bd4a01f1af412297401cbc901557fd8f1057c0d502c2fc9a4b97328ab68138260cb03c4beb663a67bded1e
6
+ metadata.gz: 1239724ca7603400fd5a6cf7952e542e363fee75b8a58b53018fc6eeffbf8436fe79100da13f84278452d5f1101ec51f4508a8efc334fb222f04f4b96b5c9cd2
7
+ data.tar.gz: 53264a47eb958f1a7c90aa6d1255174cebe37f3c4cf43bc63019b46cc39b91b7cdde961ddc1bc38f8036209cefe418e1ab89f49a0391f529101bbfaea252020e
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 ::ActiveRecord::RecordInvalid, subscription if subscription.nil?
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.create(subscriber: subscriber, **args)
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.create!(subscriber: subscriber, **args)
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
- after_commit :create_mailings!, on: :create
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
- # Updates `unsubscribed_at` to nil and runs `on_subscribe` callbacks.
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
@@ -1,3 +1,3 @@
1
1
  <%= t("caffeinate.campaign_subscriptions.subscribe") %>
2
2
  <p><%= t("caffeinate.campaign_subscriptions.changed_your_mind")%></p>
3
- <p><%= link_to "Unsubscribe", caffeinate_subscribe_url %></p>
3
+ <p><%= link_to "Unsubscribe", caffeinate_unsubscribe_url %></p>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Caffeinate
4
- VERSION = '0.16.0'
4
+ VERSION = '2.0.4'
5
5
  end
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.16.0
4
+ version: 2.0.4
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-04-15 00:00:00.000000000 Z
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.2.0.rc.2
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.