caffeinate 0.6.0 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/caffeinate/campaign.rb +1 -3
- data/app/views/layouts/_caffeinate.html.erb +1 -1
- data/lib/caffeinate.rb +11 -1
- data/lib/caffeinate/drip.rb +11 -2
- data/lib/caffeinate/dripper/drip_collection.rb +3 -3
- data/lib/caffeinate/mail_ext.rb +4 -0
- data/lib/caffeinate/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 855b98e11499fe2a9fbf1e589530d60d511363e55ea80cdf1b4322dc92af1f3c
|
4
|
+
data.tar.gz: ca000ad1c32cb053901e3f69dcc370725044c3529c673839c3f4ef9b43dc5505
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d8e13de2b19eb8d7a628ae2e5ca9e0bca0d985f36629994257775a2d3b7b5b0641584fc349929ac6930e65fd6a4958556dbd0ab3604600a37c5879858657720
|
7
|
+
data.tar.gz: 999a9e763d4e1b7f96a5549f61eca6c0c1e2029e346dadea08281eb00c754ed2ccd1022dcdcbf13b315572446bf1eb5d699dde802604cc441f897cdac5fe5256
|
@@ -35,10 +35,8 @@ module Caffeinate
|
|
35
35
|
end
|
36
36
|
|
37
37
|
# Checks to see if the subscriber exists.
|
38
|
-
#
|
39
|
-
# Use `find_by` so that we don't have to load the record twice. Often used with `subscribes?`
|
40
38
|
def subscriber(record, **args)
|
41
|
-
|
39
|
+
caffeinate_campaign_subscriptions.find_by(subscriber: record, **args)
|
42
40
|
end
|
43
41
|
|
44
42
|
# Check if the subscriber exists
|
data/lib/caffeinate.rb
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'active_support'
|
4
|
+
|
5
|
+
%w(
|
6
|
+
active_record/railtie
|
7
|
+
action_controller/railtie
|
8
|
+
action_view/railtie
|
9
|
+
action_mailer/railtie
|
10
|
+
).each do |railtie|
|
11
|
+
require railtie
|
12
|
+
end
|
13
|
+
|
4
14
|
require 'caffeinate/mail_ext'
|
5
15
|
require 'caffeinate/engine'
|
6
16
|
require 'caffeinate/drip'
|
data/lib/caffeinate/drip.rb
CHANGED
@@ -24,10 +24,19 @@ module Caffeinate
|
|
24
24
|
if periodical?
|
25
25
|
start = mailing.instance_exec(&options[:start])
|
26
26
|
start += options[:every] if mailing.caffeinate_campaign_subscription.caffeinate_mailings.count.positive?
|
27
|
-
start.from_now
|
27
|
+
date = start.from_now
|
28
|
+
elsif options[:on]
|
29
|
+
date = mailing.instance_exec(&options[:on])
|
28
30
|
else
|
29
|
-
options[:delay].from_now
|
31
|
+
date = options[:delay].from_now
|
30
32
|
end
|
33
|
+
|
34
|
+
if options[:at]
|
35
|
+
time = Time.parse(options[:at])
|
36
|
+
return date.change(hour: time.hour, min: time.min, sec: time.sec)
|
37
|
+
end
|
38
|
+
|
39
|
+
date
|
31
40
|
end
|
32
41
|
|
33
42
|
def periodical?
|
@@ -42,7 +42,7 @@ module Caffeinate
|
|
42
42
|
|
43
43
|
def validate_drip_options(action, options)
|
44
44
|
options.symbolize_keys!
|
45
|
-
options.assert_valid_keys(:mailer_class, :step, :delay, :every, :start, :using, :mailer)
|
45
|
+
options.assert_valid_keys(:mailer_class, :step, :delay, :every, :start, :using, :mailer, :at, :on)
|
46
46
|
options[:mailer_class] ||= options[:mailer] || @dripper.defaults[:mailer_class]
|
47
47
|
options[:using] ||= @dripper.defaults[:using]
|
48
48
|
options[:step] ||= @dripper.drips.size + 1
|
@@ -51,8 +51,8 @@ module Caffeinate
|
|
51
51
|
raise ArgumentError, "You must define :mailer_class or :mailer in the options for #{action.inspect} on #{@dripper.inspect}"
|
52
52
|
end
|
53
53
|
|
54
|
-
if options[:every].nil? && options[:delay].nil?
|
55
|
-
raise ArgumentError, "You must define :delay in the options for #{action.inspect} on #{@dripper.inspect}"
|
54
|
+
if options[:every].nil? && options[:delay].nil? && options[:on].nil?
|
55
|
+
raise ArgumentError, "You must define :delay or :on or :every in the options for #{action.inspect} on #{@dripper.inspect}"
|
56
56
|
end
|
57
57
|
|
58
58
|
options
|
data/lib/caffeinate/mail_ext.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Mail
|
4
|
+
def self.from_source(source)
|
5
|
+
Mail.new Mail::Utilities.binary_unsafe_to_crlf(source.to_s)
|
6
|
+
end
|
7
|
+
|
4
8
|
# Extend Mail::Message to account for a Caffeinate::Mailing
|
5
9
|
class Message
|
6
10
|
attr_accessor :caffeinate_mailing
|
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: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Brody
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|