caffeinate 0.7.1 → 0.8.5
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 -1
- data/app/views/layouts/_caffeinate.html.erb +1 -1
- data/lib/caffeinate.rb +11 -1
- data/lib/caffeinate/drip.rb +2 -0
- data/lib/caffeinate/drip_evaluator.rb +4 -4
- data/lib/caffeinate/dripper/drip_collection.rb +3 -3
- data/lib/caffeinate/dripper/perform.rb +1 -1
- data/lib/caffeinate/mail_ext.rb +4 -0
- data/lib/caffeinate/version.rb +1 -1
- data/lib/generators/caffeinate/views_generator.rb +44 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f2ea2b9f5f03fdeb85614ae404df166822797d18861bd1c6ea5c4c867f44618
|
4
|
+
data.tar.gz: 38b8cd78227cc1eecffe4e09ee01fd8e26a7fc46314d30956ce29230b1209f7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fd342f50ad5394c5253d1c7c00efa7ce25e1d1f90571fe16658bed9f0d251893f4953d746daf4db48728541d13fc67ee505529aae18711e491ca0819f66d6a1
|
7
|
+
data.tar.gz: 8ec91a5b080a1420f090a4c538c1fd1cd05def80c5aa5395ce2a2d985063e4ef7d26e935ec1131496525d44bd745abbac90cbbc749e9ec6b55d1c0f3a99d8e49
|
@@ -56,7 +56,7 @@ module Caffeinate
|
|
56
56
|
def unsubscribe(subscriber, **args)
|
57
57
|
reason = args.delete(:reason)
|
58
58
|
subscription = subscriber(subscriber, **args)
|
59
|
-
raise ActiveRecord::RecordInvalid, subscription if subscription.nil?
|
59
|
+
raise ::ActiveRecord::RecordInvalid, subscription if subscription.nil?
|
60
60
|
|
61
61
|
subscription.unsubscribe!(reason)
|
62
62
|
end
|
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
@@ -25,6 +25,8 @@ module Caffeinate
|
|
25
25
|
start = mailing.instance_exec(&options[:start])
|
26
26
|
start += options[:every] if mailing.caffeinate_campaign_subscription.caffeinate_mailings.count.positive?
|
27
27
|
date = start.from_now
|
28
|
+
elsif options[:on]
|
29
|
+
date = mailing.instance_exec(&options[:on])
|
28
30
|
else
|
29
31
|
date = options[:delay].from_now
|
30
32
|
end
|
@@ -16,14 +16,14 @@ module Caffeinate
|
|
16
16
|
end
|
17
17
|
|
18
18
|
# Ends the CampaignSubscription
|
19
|
-
def end!
|
20
|
-
mailing.caffeinate_campaign_subscription.end!
|
19
|
+
def end!(msg)
|
20
|
+
mailing.caffeinate_campaign_subscription.end!(msg)
|
21
21
|
false
|
22
22
|
end
|
23
23
|
|
24
24
|
# Unsubscribes the CampaignSubscription
|
25
|
-
def unsubscribe!
|
26
|
-
mailing.caffeinate_campaign_subscription.unsubscribe!
|
25
|
+
def unsubscribe!(msg)
|
26
|
+
mailing.caffeinate_campaign_subscription.unsubscribe!(msg)
|
27
27
|
false
|
28
28
|
end
|
29
29
|
|
@@ -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, :at)
|
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
|
@@ -20,7 +20,7 @@ module Caffeinate
|
|
20
20
|
.upcoming
|
21
21
|
.unsent
|
22
22
|
.joins(:caffeinate_campaign_subscription)
|
23
|
-
.merge(Caffeinate::CampaignSubscription.active)
|
23
|
+
.merge(Caffeinate::CampaignSubscription.active.where(caffeinate_campaign: self.campaign))
|
24
24
|
.in_batches(of: self.class.batch_size)
|
25
25
|
.each do |batch|
|
26
26
|
run_callbacks(:on_perform, self, batch)
|
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
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators/base'
|
4
|
+
|
5
|
+
module Caffeinate
|
6
|
+
module Generators
|
7
|
+
module ViewPathTemplates #:nodoc:
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
included do
|
11
|
+
public_task :copy_views
|
12
|
+
end
|
13
|
+
|
14
|
+
def copy_views
|
15
|
+
view_directory :campaign_subscriptions
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def view_directory(name, _target_path = nil)
|
21
|
+
directory name.to_s, _target_path || "#{target_path}/#{name}" do |content|
|
22
|
+
content
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def target_path
|
27
|
+
@target_path ||= "app/views/caffeinate"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class SharedViewsGenerator < Rails::Generators::Base #:nodoc:
|
32
|
+
include ViewPathTemplates
|
33
|
+
source_root File.expand_path("../../../../app/views/caffeinate", __FILE__)
|
34
|
+
desc "Copies shared Caffeinate views to your application."
|
35
|
+
hide!
|
36
|
+
end
|
37
|
+
|
38
|
+
class ViewsGenerator < Rails::Generators::Base
|
39
|
+
desc "Copies Caffeinate views to your application."
|
40
|
+
|
41
|
+
invoke SharedViewsGenerator
|
42
|
+
end
|
43
|
+
end
|
44
|
+
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.
|
4
|
+
version: 0.8.5
|
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-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- lib/generators/caffeinate/install_generator.rb
|
178
178
|
- lib/generators/caffeinate/templates/application_dripper.rb
|
179
179
|
- lib/generators/caffeinate/templates/caffeinate.rb
|
180
|
+
- lib/generators/caffeinate/views_generator.rb
|
180
181
|
homepage: https://github.com/joshmn/caffeinate
|
181
182
|
licenses:
|
182
183
|
- MIT
|