sparkpost_mailer 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +38 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/sparkpost_mailer.rb +28 -0
- data/lib/sparkpost_mailer/core_mailer.rb +62 -0
- data/lib/sparkpost_mailer/mock.rb +5 -0
- data/lib/sparkpost_mailer/payload_mailer.rb +11 -0
- data/lib/sparkpost_mailer/railtie.rb +8 -0
- data/lib/sparkpost_mailer/version.rb +3 -0
- data/sparkpost_mailer.gemspec +29 -0
- metadata +159 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4b95c250a971a55e8e7486a14158f807dc15a808
|
4
|
+
data.tar.gz: 7a445383139deb27deaf3f104ab1502d794f9b49
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 95b9d5ae78122463cd167ca80ca0d3655f1a2e5d2ec720703210262321adda728fdf2f574dafc663759c3d503b16b95f4e6cb43e704f70f321568fd643e5e515
|
7
|
+
data.tar.gz: 31401235d142fac1a970026c82bb9e9776ebd693986e619c2bf7af9aead0712f1d316d812ebbdcf0b92c203f54f65c36bd36639b3b174f59c890214f58c53844
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Preston Skaggs
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# SparkpostMailer
|
2
|
+
|
3
|
+
This is a wrapper for the sparkpost gem. Just about everything here was a straight copy and paste from the mandrill_mailer gem. Since Mandrill charges now I switched to SparkPost and needed something to get what I had to work like the Mandrill setup.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'sparkpost_mailer'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install sparkpost_mailer
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/PSkaggs/sparkpost_mailer.
|
34
|
+
|
35
|
+
|
36
|
+
## License
|
37
|
+
|
38
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "sparkpost_mailer"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require "sparkpost_mailer/version"
|
2
|
+
require 'action_view'
|
3
|
+
require 'sparkpost_mailer/railtie'
|
4
|
+
require 'sparkpost_mailer/mock'
|
5
|
+
require 'sparkpost_mailer/payload_mailer'
|
6
|
+
|
7
|
+
module SparkPostMailer
|
8
|
+
autoload :SparkPost, 'sparkpost'
|
9
|
+
|
10
|
+
if defined?(Rails)
|
11
|
+
def self.configure(&block)
|
12
|
+
if block_given?
|
13
|
+
block.call(SparkPostMailer::Railtie.config.sparkpost_mailer)
|
14
|
+
else
|
15
|
+
SparkPostMailer::Railtie.config.sparkpost_mailer
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.config
|
20
|
+
SparkPostMailer::Railtie.config.sparkpost_mailer
|
21
|
+
end
|
22
|
+
else
|
23
|
+
def self.config
|
24
|
+
@@config ||= OpenStruct.new(api_key: nil)
|
25
|
+
@@config
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'active_support/all'
|
2
|
+
|
3
|
+
module SparkPostMailer
|
4
|
+
class CoreMailer
|
5
|
+
class InvalidEmail < StandardError; end
|
6
|
+
class InvalidMailerMethod < StandardError; end
|
7
|
+
class InvalidInterceptorParams < StandardError; end
|
8
|
+
class InvalidMergeLanguageError < StandardError; end
|
9
|
+
|
10
|
+
# Makes this class act as a singleton without it actually being a singleton
|
11
|
+
# This keeps the syntax the same as the orginal mailers so we can swap quickly if something
|
12
|
+
# goes wrong.
|
13
|
+
def self.method_missing(method, *args)
|
14
|
+
return super unless respond_to?(method)
|
15
|
+
new.method(method).call(*args)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.respond_to?(method, include_private = false)
|
19
|
+
super || instance_methods.include?(method.to_sym)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Proxy route helpers to rails if Rails exists. Doing routes this way
|
23
|
+
# makes it so this gem doesn't need to be a rails engine
|
24
|
+
def method_missing(method, *args)
|
25
|
+
return super unless defined?(Rails) && Rails.application.routes.url_helpers.respond_to?(method)
|
26
|
+
# Check to see if one of the args is an open struct. If it is, we'll assume it's the
|
27
|
+
# test stub and try to call a path or url attribute.
|
28
|
+
if args.any? {|arg| arg.kind_of?(SparkPostMailer::Mock)}
|
29
|
+
# take the first OpenStruct found in args and look for .url or.path
|
30
|
+
args.each do |arg|
|
31
|
+
if arg.kind_of?(SparkPostMailer::Mock)
|
32
|
+
break arg.url || arg.path
|
33
|
+
end
|
34
|
+
end
|
35
|
+
else
|
36
|
+
options = args.extract_options!.merge({host: SparkPostMailer.config.default_url_options[:host], protocol: SparkPostMailer.config.default_url_options[:protocol]})
|
37
|
+
args << options
|
38
|
+
Rails.application.routes.url_helpers.method(method).call(*args)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def image_path(image)
|
43
|
+
if defined? Rails
|
44
|
+
ActionController::Base.helpers.asset_path(image)
|
45
|
+
else
|
46
|
+
method_missing(:image_path, image)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def image_url(image)
|
51
|
+
"#{root_url}#{image_path(image).split('/').reject!(&:empty?).join('/')}"
|
52
|
+
end
|
53
|
+
|
54
|
+
def api_key
|
55
|
+
SparkPostMailer.config.api_key
|
56
|
+
end
|
57
|
+
|
58
|
+
def sparkpost_client
|
59
|
+
@sparkpost_client ||= SparkPost::Client.new(api_key)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sparkpost_mailer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sparkpost_mailer"
|
8
|
+
spec.version = SparkpostMailer::VERSION
|
9
|
+
spec.authors = ["Preston Skaggs"]
|
10
|
+
spec.email = ["preston@delaris.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{A short wrapper for the sparkpost gem}
|
13
|
+
spec.description = %q{All this does is make the root_url and image_url available to a mailer subclass}
|
14
|
+
spec.homepage = "https://github.com/PSkaggs/sparkpost_mailer"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
spec.add_dependency 'activesupport'
|
23
|
+
spec.add_dependency 'actionpack'
|
24
|
+
spec.add_runtime_dependency 'sparkpost'
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "rspec"
|
28
|
+
spec.add_development_dependency 'pry'
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sparkpost_mailer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Preston Skaggs
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
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: actionpack
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sparkpost
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
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: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.10'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.10'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: All this does is make the root_url and image_url available to a mailer
|
112
|
+
subclass
|
113
|
+
email:
|
114
|
+
- preston@delaris.com
|
115
|
+
executables: []
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- .gitignore
|
120
|
+
- .rspec
|
121
|
+
- .travis.yml
|
122
|
+
- Gemfile
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- bin/console
|
127
|
+
- bin/setup
|
128
|
+
- lib/sparkpost_mailer.rb
|
129
|
+
- lib/sparkpost_mailer/core_mailer.rb
|
130
|
+
- lib/sparkpost_mailer/mock.rb
|
131
|
+
- lib/sparkpost_mailer/payload_mailer.rb
|
132
|
+
- lib/sparkpost_mailer/railtie.rb
|
133
|
+
- lib/sparkpost_mailer/version.rb
|
134
|
+
- sparkpost_mailer.gemspec
|
135
|
+
homepage: https://github.com/PSkaggs/sparkpost_mailer
|
136
|
+
licenses:
|
137
|
+
- MIT
|
138
|
+
metadata: {}
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - '>='
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 2.0.14.1
|
156
|
+
signing_key:
|
157
|
+
specification_version: 4
|
158
|
+
summary: A short wrapper for the sparkpost gem
|
159
|
+
test_files: []
|