caffeinate 0.15.0 → 2.0.3

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: 2c8294f4e3189cbc99b5a74d31851c1c752bae5acb417b95793aad434781db65
4
- data.tar.gz: 94cf500c26c578c950474a6e3716b6e689052880c65e87263c5403c1af17d279
3
+ metadata.gz: 46f61ede9a9ba070d742679d19deb3e066e3b92b50b0bcd24fa3bc6608fd31cc
4
+ data.tar.gz: d1525c1e7095e278f32b2c4b74d2be41f78052aa50a79764c30a3dee8fd60104
5
5
  SHA512:
6
- metadata.gz: 5861ebed028ffcb28df9565dea9fb3bdd068170631133d5ee743351489820dbe0dd86654c5631f98cd14736ca0ac06210e47de992bbda0ed45345029ba9c9141
7
- data.tar.gz: ce79dd00459d71dbc987063662ddff59b7bb0b6083e55a2821bbbd72dcbf85283daf26d60c8add3e9492010a30c77608642bce3a20695fcf8784a4399296aaa5
6
+ metadata.gz: 04d8f81d9a86eaf62685deb2da8ad32c9398611ffcb3b5d8e24b9e13e56cc3fe2721392defa9826b99bd1ce0e720c5585d98ad887348349968d9eb2530b0a03e
7
+ data.tar.gz: 87a5089d9c34479cb4deb15da5e3db26723b6dc0022ae0c6bc8a76eaa8cbcb66f9899bc6454a12c0b985878c7b53e89a2abce8f2484a439500787c6382792bd6
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>
@@ -20,8 +20,6 @@ module Caffeinate
20
20
  end
21
21
 
22
22
  class ScheduleEvaluator
23
- delegate_missing_to :@drip
24
-
25
23
  def self.call(drip, mailing)
26
24
  new(drip, mailing).call
27
25
  end
@@ -54,7 +52,15 @@ module Caffeinate
54
52
 
55
53
  date
56
54
  end
55
+
56
+ def respond_to_missing?(name, include_private = false)
57
+ @drip.respond_to?(name, include_private)
58
+ end
57
59
 
60
+ def method_missing(method, *args, &block)
61
+ @drip.send(method, *args, &block)
62
+ end
63
+
58
64
  private
59
65
 
60
66
  def periodical?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Caffeinate
4
- VERSION = '0.15.0'
4
+ VERSION = '2.0.3'
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.15.0
4
+ version: 2.0.3
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-01-24 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.