resque_mailer 2.2.3 → 2.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ### EDGE / 2013-05-06
2
+ * Compatibility for Rails 4 pre-release (Ben Woosley)
3
+ * Fallback to synchronous is default when connection to Redis fails
4
+ * Avoid lazy evaluation of mail when excluded, for use with mail_view
5
+ (gingerlime)
6
+
1
7
  ### 2.2.3 / 2013-02-27
2
8
  * MessageDecoy should handle non rails current_env (Hunter Haydel)
3
9
 
data/README.md CHANGED
@@ -7,6 +7,17 @@ for your background jobs.
7
7
  Note that recent (2.0+) versions of Resque::Mailer only work with Rails 3.x.
8
8
  For a version compatible with Rails 2, specify v1.x in your Gemfile.
9
9
 
10
+ ## Installation
11
+
12
+ Install the gem:
13
+
14
+ gem install resque_mailer
15
+
16
+ If you're using Bundler to manage your dependencies, you should add it to your Gemfile:
17
+
18
+ gem 'resque' # or a compatible alternative / fork
19
+ gem 'resque_mailer'
20
+
10
21
  ## Usage
11
22
 
12
23
  Include Resque::Mailer in your ActionMailer subclass(es) like this:
@@ -54,20 +65,7 @@ Resque::Mailer.error_handler = lambda { |mailer, message, error|
54
65
  }
55
66
  ```
56
67
 
57
- ### Using with Resque Scheduler
58
-
59
- If [resque-scheduler](https://github.com/bvandenbos/resque-scheduler) is
60
- installed, two extra methods will be available: `deliver_at` and `deliver_in`.
61
- These will enqueue mail for delivery at a specified time in the future.
62
-
63
- # Delivers on the 25th of December, 2013
64
- MyMailer.reminder_email(params).deliver_at(Time.parse('2013-12-25'))
65
-
66
- # Delivers in 7 days
67
- MyMailer.reminder_email(params).deliver_in(7.days)
68
-
69
-
70
- ## Resque::Mailer as a Project Default
68
+ ### Resque::Mailer as a Project Default
71
69
 
72
70
  If you have a variety of mailers in your application and want all of them to use
73
71
  Resque::Mailer by default, you can subclass ActionMailer::Base and have your
@@ -85,16 +83,17 @@ other mailers inherit from an AsyncMailer:
85
83
  end
86
84
  end
87
85
 
88
- ## Installation
89
-
90
- Install the gem:
86
+ ### Using with Resque Scheduler
91
87
 
92
- gem install resque_mailer
88
+ If [resque-scheduler](https://github.com/bvandenbos/resque-scheduler) is
89
+ installed, two extra methods will be available: `deliver_at` and `deliver_in`.
90
+ These will enqueue mail for delivery at a specified time in the future.
93
91
 
94
- If you're using Bundler to manage your dependencies, you should add it to your Gemfile:
92
+ # Delivers on the 25th of December, 2013
93
+ MyMailer.reminder_email(params).deliver_at(Time.parse('2013-12-25'))
95
94
 
96
- gem 'resque' # or a compatible alternative / fork
97
- gem 'resque_mailer'
95
+ # Delivers in 7 days
96
+ MyMailer.reminder_email(params).deliver_in(7.days)
98
97
 
99
98
  ## Testing
100
99
 
data/lib/resque_mailer.rb CHANGED
@@ -3,7 +3,7 @@ require 'resque_mailer/version'
3
3
  module Resque
4
4
  module Mailer
5
5
  class << self
6
- attr_accessor :default_queue_name, :default_queue_target, :current_env, :logger, :fallback_to_synchronous, :error_handler
6
+ attr_accessor :default_queue_name, :default_queue_target, :current_env, :logger, :error_handler
7
7
  attr_reader :excluded_environments
8
8
 
9
9
  def excluded_environments=(envs)
@@ -13,9 +13,14 @@ module Resque
13
13
  def included(base)
14
14
  base.extend(ClassMethods)
15
15
  end
16
+
17
+ # Deprecated
18
+ def fallback_to_synchronous=(val)
19
+ warn "WARNING: fallback_to_synchronous option is deprecated and will be removed in the next release"
20
+ end
16
21
  end
17
22
 
18
- self.logger = nil
23
+ self.logger ||= (defined?(Rails) ? Rails.logger : nil)
19
24
  self.default_queue_target = ::Resque
20
25
  self.default_queue_name = "mailer"
21
26
  self.excluded_environments = [:test]
@@ -84,6 +89,7 @@ module Resque
84
89
  @mailer_class = mailer_class
85
90
  @method_name = method_name
86
91
  *@args = *args
92
+ actual_message if environment_excluded?
87
93
  end
88
94
 
89
95
  def resque
@@ -117,6 +123,7 @@ module Resque
117
123
  begin
118
124
  resque.enqueue(@mailer_class, @method_name, *@args)
119
125
  rescue Errno::ECONNREFUSED
126
+ logger.error "Unable to connect to Redis; falling back to synchronous mail delivery" if logger
120
127
  deliver!
121
128
  end
122
129
  end
@@ -153,6 +160,10 @@ module Resque
153
160
  def method_missing(method_name, *args)
154
161
  actual_message.send(method_name, *args)
155
162
  end
163
+
164
+ def logger
165
+ @mailer_class.logger
166
+ end
156
167
  end
157
168
  end
158
169
  end
@@ -1,5 +1,5 @@
1
1
  module Resque
2
2
  module Mailer
3
- VERSION = "2.2.3"
3
+ VERSION = "2.2.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque_mailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 2.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,14 +9,14 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-28 00:00:00.000000000 Z
12
+ date: 2013-05-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionmailer
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: '3.0'
22
22
  type: :runtime
@@ -24,7 +24,7 @@ dependencies:
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ~>
27
+ - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '3.0'
30
30
  - !ruby/object:Gem::Dependency
@@ -88,7 +88,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
88
88
  version: '0'
89
89
  segments:
90
90
  - 0
91
- hash: -3399216281292573074
91
+ hash: 937321504006937956
92
92
  required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  none: false
94
94
  requirements:
@@ -97,10 +97,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  version: '0'
98
98
  segments:
99
99
  - 0
100
- hash: -3399216281292573074
100
+ hash: 937321504006937956
101
101
  requirements: []
102
102
  rubyforge_project:
103
- rubygems_version: 1.8.25
103
+ rubygems_version: 1.8.24
104
104
  signing_key:
105
105
  specification_version: 3
106
106
  summary: Rails plugin for sending asynchronous email with ActionMailer and Resque.