action-mailer-demuxer 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/.travis.yml +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +52 -0
- data/Rakefile +10 -0
- data/action-mailer-demuxer.gemspec +26 -0
- data/lib/action-mailer-demuxer.rb +1 -0
- data/lib/action_mailer/demuxer.rb +3 -0
- data/lib/action_mailer/demuxer/delivery_method.rb +18 -0
- data/lib/action_mailer/demuxer/railtie.rb +9 -0
- data/lib/action_mailer/demuxer/version.rb +5 -0
- data/spec/action_mailer/demuxer_spec.rb +65 -0
- data/spec/spec_helper.rb +12 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 13ef04bf49a126c908bbf48666470dab458a69f4
|
4
|
+
data.tar.gz: e55cceabf8cb6521f41212635c9a7af7882f237e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a6f37e8d6badb7d1ecf31690c35593ecd8ea81a6e8794438c4027fffe2e3cc2382f831a1fbb3269eea15e6e8e3709f51ef1f9f89a3156229bb3c55542b70c1b1
|
7
|
+
data.tar.gz: 7fb873f36e3451b238cc099242e90e6a36ebbe631a44e79cc6cb8f3b67e5a8f0729837363824fd9e83bb40b542b018ea731fded6911e7a7b842cabadd1eba387
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Eric J. Holmes
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# ActionMailer Demuxer
|
2
|
+
|
3
|
+
A ruby gem for demuxing ActionMailer delivery methods.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'action-mailer-demuxer'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```console
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
```console
|
22
|
+
$ gem install action-mailer-demuxer
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Configure the action mailer delivery method
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
config.action_mailer.delivery_method = :demuxer
|
31
|
+
config.action_mailer.demuxer_settings = { email: :smtp, sms: :letter_opener }
|
32
|
+
```
|
33
|
+
|
34
|
+
Flag your mailer classes with a `type` default:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
class Emailer < ActionMailer::Base
|
38
|
+
default type: :email
|
39
|
+
end
|
40
|
+
|
41
|
+
class Texter < ActionMailer::Base
|
42
|
+
default type: :sms
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
## Contributing
|
47
|
+
|
48
|
+
1. Fork it
|
49
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
50
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
51
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
52
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'action_mailer/demuxer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'action-mailer-demuxer'
|
8
|
+
spec.version = ActionMailer::Demuxer::VERSION
|
9
|
+
spec.authors = ['Eric J. Holmes']
|
10
|
+
spec.email = ['eric@ejholmes.net']
|
11
|
+
spec.description = %q{Demux ActionMailer delivery methods}
|
12
|
+
spec.summary = %q{Demux ActionMailer delivery methods}
|
13
|
+
spec.homepage = 'https://github.com/remind101/action-mailer/demuxer'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'rails'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
spec.add_development_dependency 'rspec'
|
26
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'action_mailer/demuxer'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ActionMailer
|
2
|
+
module Demuxer
|
3
|
+
class DeliveryMethod
|
4
|
+
attr_accessor :settings
|
5
|
+
|
6
|
+
def initialize(values)
|
7
|
+
self.settings = values.symbolize_keys
|
8
|
+
end
|
9
|
+
|
10
|
+
def deliver!(mail)
|
11
|
+
type = mail.default(:type) || :email
|
12
|
+
method = settings[type.to_sym]
|
13
|
+
ActionMailer::Base.wrap_delivery_behavior(mail, method)
|
14
|
+
mail.deliver!
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'action_mailer'
|
3
|
+
require 'action-mailer-demuxer'
|
4
|
+
|
5
|
+
class SmsDeliveryMethod
|
6
|
+
attr_accessor :settings
|
7
|
+
|
8
|
+
class << self
|
9
|
+
attr_accessor :deliveries
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(values)
|
13
|
+
self.settings = values
|
14
|
+
end
|
15
|
+
|
16
|
+
def deliver!(mail)
|
17
|
+
self.class.deliveries << []
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
ActionMailer::Base.add_delivery_method :demuxer, ActionMailer::Demuxer::DeliveryMethod
|
22
|
+
ActionMailer::Base.delivery_method = :demuxer
|
23
|
+
ActionMailer::Base.demuxer_settings = { email: :test, sms: SmsDeliveryMethod }
|
24
|
+
|
25
|
+
class NoType < ActionMailer::Base
|
26
|
+
default from: 'from@example.com'
|
27
|
+
|
28
|
+
def welcome
|
29
|
+
mail to: 'foo@example.com', body: 'text'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class Emailer < ActionMailer::Base
|
34
|
+
default type: :email, from: 'from@example.com'
|
35
|
+
|
36
|
+
def welcome
|
37
|
+
mail to: 'to@example.com', body: 'text'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class Sms < ActionMailer::Base
|
42
|
+
default type: 'sms'
|
43
|
+
|
44
|
+
def welcome
|
45
|
+
mail to: '+183112345678', body: 'text'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe ActionMailer::Demuxer do
|
50
|
+
before do
|
51
|
+
SmsDeliveryMethod.deliveries = []
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'defaults to email' do
|
55
|
+
expect { NoType.welcome.deliver }.to change { ActionMailer::Base.deliveries.length }.by(1)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'demuxes email' do
|
59
|
+
expect { Emailer.welcome.deliver }.to change { ActionMailer::Base.deliveries.length }.by(1)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'demuxes sms' do
|
63
|
+
expect { Sms.welcome.deliver }.to change { SmsDeliveryMethod.deliveries.length }.by(1)
|
64
|
+
end
|
65
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
Bundler.require :default, :test
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
config.order = 'random'
|
6
|
+
config.filter_run :focus => true
|
7
|
+
config.run_all_when_everything_filtered = true
|
8
|
+
end
|
9
|
+
|
10
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
11
|
+
# in spec/support/ and its subdirectories.
|
12
|
+
Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each {|f| require f}
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: action-mailer-demuxer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eric J. Holmes
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Demux ActionMailer delivery methods
|
70
|
+
email:
|
71
|
+
- eric@ejholmes.net
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- .rspec
|
78
|
+
- .travis.yml
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- action-mailer-demuxer.gemspec
|
84
|
+
- lib/action-mailer-demuxer.rb
|
85
|
+
- lib/action_mailer/demuxer.rb
|
86
|
+
- lib/action_mailer/demuxer/delivery_method.rb
|
87
|
+
- lib/action_mailer/demuxer/railtie.rb
|
88
|
+
- lib/action_mailer/demuxer/version.rb
|
89
|
+
- spec/action_mailer/demuxer_spec.rb
|
90
|
+
- spec/spec_helper.rb
|
91
|
+
homepage: https://github.com/remind101/action-mailer/demuxer
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.0.14
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Demux ActionMailer delivery methods
|
115
|
+
test_files:
|
116
|
+
- spec/action_mailer/demuxer_spec.rb
|
117
|
+
- spec/spec_helper.rb
|