caffeinate 0.16.0 → 2.0.0

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: 267d93d746f23525a65cf5607ef0b4c67195cd9c14260d3f8b9b346cfdeb8ffe
4
+ data.tar.gz: c3851e78e0ddd35f5735aaa70ce9360cf242ab9ede3e6c6a74700b07c59ad16e
5
5
  SHA512:
6
- metadata.gz: 409337f24f2d2fbe1837632d86211767acb73fbdb84bcaba35f5352ec713b81955a784a59385c37c892d468ee978e57419fa54406c3bb0907a0c84372890fbe5
7
- data.tar.gz: 6f2988ab65ed1c8b7af248ab4ce0ed2ce2d1989bd5bd4a01f1af412297401cbc901557fd8f1057c0d502c2fc9a4b97328ab68138260cb03c4beb663a67bded1e
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 ::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,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Caffeinate
4
- VERSION = '0.16.0'
4
+ VERSION = '2.0.0'
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.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-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.