sidekiq_mailer 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Sidekiq::Mailer
2
2
 
3
- Sidekiq::Mailer adds to your ActionMailer classes the ability to send mails asyncronously.
3
+ Sidekiq::Mailer adds to your ActionMailer classes the ability to send mails asynchronously.
4
4
 
5
5
  ## Usage
6
6
 
7
- If you want to make a specific mailer to work asyncronously just include Sikekiq::Mailer module:
7
+ If you want to make a specific mailer to work asynchronously just include Sidekiq::Mailer module:
8
8
 
9
9
  class MyMailer < ActionMailer::Base
10
10
  include Sidekiq::Mailer
@@ -14,9 +14,9 @@ If you want to make a specific mailer to work asyncronously just include Sikekiq
14
14
  end
15
15
  end
16
16
 
17
- Now every deliver you make with MyMailer will be asyncronous.
17
+ Now every deliver you make with MyMailer will be asynchronous.
18
18
 
19
- # Queues the mail to be sent asyncronously by sidekiq
19
+ # Queues the mail to be sent asynchronously by sidekiq
20
20
  MyMailer.welcome('your@email.com').deliver
21
21
 
22
22
  The default queue used by Sidekiq::Mailer is 'mailer'. So, in order to send mails with sidekiq you need to start a worker using:
@@ -25,7 +25,7 @@ The default queue used by Sidekiq::Mailer is 'mailer'. So, in order to send mail
25
25
 
26
26
  If you want to skip sidekiq you should use the 'deliver!' method:
27
27
 
28
- # Mail will skip sidekiq and will be sent syncronously
28
+ # Mail will skip sidekiq and will be sent synchronously
29
29
  MyMailer.welcome('your@email.com').deliver!
30
30
 
31
31
  By default Sidekiq::Mailer will retry to send an email if it failed. But you can [override sidekiq options](https://github.com/andersondias/sidekiq_mailer/wiki/Overriding-sidekiq-options) in your mailer.
@@ -5,15 +5,23 @@ require 'sidekiq_mailer/proxy'
5
5
  module Sidekiq
6
6
  module Mailer
7
7
  def self.excluded_environments=(envs)
8
- @@excluded_environments = [*envs].map { |e| e.to_sym }
8
+ @@excluded_environments = [*envs].map { |e| e && e.to_sym }
9
9
  end
10
10
 
11
11
  def self.excluded_environments
12
12
  @@excluded_environments
13
13
  end
14
14
 
15
+ def self.current_env
16
+ if defined?(Rails)
17
+ ::Rails.env
18
+ else
19
+ ENV['RAILS_ENV'].to_s
20
+ end
21
+ end
22
+
15
23
  def self.excludes_current_environment?
16
- !ActionMailer::Base.perform_deliveries || (excluded_environments && excluded_environments.include?(ENV['RAILS_ENV'].to_sym))
24
+ !ActionMailer::Base.perform_deliveries || (excluded_environments && excluded_environments.include?(current_env.to_sym))
17
25
  end
18
26
 
19
27
  def self.included(base)
@@ -57,4 +65,4 @@ module Sidekiq
57
65
  end
58
66
  end
59
67
  end
60
- end
68
+ end
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Mailer
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
@@ -73,7 +73,7 @@ class SidekiqMailerTest < Test::Unit::TestCase
73
73
  assert_equal 1, ActionMailer::Base.deliveries.size
74
74
  end
75
75
 
76
- def test_delivers_syncronously_if_running_in_a_excluded_environment
76
+ def test_delivers_synchronously_if_running_in_a_excluded_environment
77
77
  Sidekiq::Mailer.excluded_environments = [:test]
78
78
  BasicMailer.welcome('test@test.com').deliver
79
79
  assert_equal 0, Sidekiq::Mailer::Worker.jobs.size
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq_mailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-10 00:00:00.000000000 Z
12
+ date: 2013-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport