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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3bf57f512b2d4760d99422a5696250ae68e29498fb013a6b7864441c028277f
4
- data.tar.gz: 20402615978ccb8fe58a8dba9a229a10e972ea42f03bfad68894744263d2302d
3
+ metadata.gz: 855b98e11499fe2a9fbf1e589530d60d511363e55ea80cdf1b4322dc92af1f3c
4
+ data.tar.gz: ca000ad1c32cb053901e3f69dcc370725044c3529c673839c3f4ef9b43dc5505
5
5
  SHA512:
6
- metadata.gz: 72698ac79d53fe73f71203a31d789916112dac478924e88369de9622195bb9f27d25ced846b44d5896b51d787295591e971c594ede370d0c62ba68f623f8c85b
7
- data.tar.gz: 8e9a34fe244c2968f2c808f9a700d4e4502d7441de9b718a647a9dae615b4df36193f8c5e4da248b0722353447ea0d32455bc8a9c0dac99f1aa862958adc0ec6
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
- @subscriber ||= caffeinate_campaign_subscriptions.find_by(subscriber: record, **args)
39
+ caffeinate_campaign_subscriptions.find_by(subscriber: record, **args)
42
40
  end
43
41
 
44
42
  # Check if the subscriber exists
@@ -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'
@@ -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
@@ -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.6.0'
4
+ VERSION = '0.8.2'
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.6.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 00:00:00.000000000 Z
11
+ date: 2020-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails