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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ebd5c45c4d4fd056ba4ff2080a464e2151bc3245849c709d9f81d396c4b36523
4
- data.tar.gz: 0ed91aa4d77c8b368fadc721ffdd81bdd70a249cebe077fadcd2161b6ebf6dab
3
+ metadata.gz: 5f2ea2b9f5f03fdeb85614ae404df166822797d18861bd1c6ea5c4c867f44618
4
+ data.tar.gz: 38b8cd78227cc1eecffe4e09ee01fd8e26a7fc46314d30956ce29230b1209f7f
5
5
  SHA512:
6
- metadata.gz: 0dc2f09d245f8936bf55ab0c00d8a4cd4b8651db10f9656a66869088297c43c694b1c71356421216d59a27376fac89962bb8dbd02dfd7d648e65578f2cfb1900
7
- data.tar.gz: 3554585afc00fc341c8627ee67071c02ca8f60092f96545043c4c06447a4c6c0ae37e3292cda9293047670471c7b16843dfa3a5b04b4b215ea93562d7050d22b
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
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <title><%= Rails.application.class.module_parent_name %></title>
4
+ <title></title>
5
5
  </head>
6
6
  <body>
7
7
 
@@ -1,6 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rails/all'
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'
@@ -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)
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Caffeinate
4
- VERSION = '0.7.1'
4
+ VERSION = '0.8.5'
5
5
  end
@@ -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.7.1
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-15 00:00:00.000000000 Z
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