apostle-rails 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 +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +65 -0
- data/Rakefile +1 -0
- data/apostle-rails.gemspec +25 -0
- data/lib/apostle-rails.rb +1 -0
- data/lib/apostle_rails.rb +2 -0
- data/lib/apostle_rails/mailer.rb +69 -0
- data/lib/apostle_rails/version.rb +3 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 17814d82810c73973e55d1f9789db778a98f460a
|
4
|
+
data.tar.gz: 441d08eca18a45fb03a8a35a0559fe2b537b5fe7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e79d4f8f7ee52128e635926a9d7fcec8b6783ab864998737f9a3665dfdcf91b9b990bd9b4d627f12f4fb7db2ea1b0e364e1cd3cb725f16d3d51066d8ef01a265
|
7
|
+
data.tar.gz: fefbf49180076092c8b941b14f48fa8f46d783793c62f81250813fff3f944b3dddbae5eaa4b2696208563435eaef72b64e846f11198bd29ccd0bd1fdc9016e18
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Mal Curtis
|
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,65 @@
|
|
1
|
+
# Apostle::Rails
|
2
|
+
|
3
|
+
Rails Bindings for Apostle
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'apostle-rails'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install apostle-rails
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
`apostle-rails` is designed to feel like the `ActionMailer` API as much as possible.
|
22
|
+
|
23
|
+
Changing an existing mailer is easy.
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
class MyMailer < ActionMailer::Base
|
27
|
+
def my_mail name, email, message
|
28
|
+
@message, @name = message, name
|
29
|
+
mail to: email, subject: "Your message"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
```
|
33
|
+
becomes
|
34
|
+
```ruby
|
35
|
+
class MyMailer < ActionMailer::Base
|
36
|
+
|
37
|
+
include Apostle::Mailer
|
38
|
+
|
39
|
+
def my_mail name, email, message
|
40
|
+
@message, @name = message, name
|
41
|
+
mail "my_mail", email: email
|
42
|
+
end
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
The first param passed to `mail` is the template slug, and instead of `to`, use `email`. `Apostle::Mailer` automatically adds any instance variables you set to the `Apostle::Mail` instance.
|
47
|
+
|
48
|
+
Instead of returning an `ActionMailer` object when `MyMailer.my_mail` you get an instance of `Apostle::Mail`, which you can then call `deliver` on.
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
MyMailer.
|
52
|
+
my_mail("Mal Curtis", "mal@mal.co.nz", "Hi there").
|
53
|
+
deliver!
|
54
|
+
```
|
55
|
+
|
56
|
+
## Who
|
57
|
+
Created with ♥ by [Mal Curtis](http://github.com/snikch) ([@snikchnz](http://twitter.com/snikchnz))
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
1. Fork it
|
62
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
63
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
64
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
65
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'apostle_rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "apostle-rails"
|
8
|
+
spec.version = ApostleRails::VERSION
|
9
|
+
spec.authors = ["Mal Curtis"]
|
10
|
+
spec.email = ["mal@apostle.io"]
|
11
|
+
spec.description = %q{Rails Bindings for Apostle}
|
12
|
+
spec.summary = %q{Easy Rails integration for Apostle}
|
13
|
+
spec.homepage = "http://apostle.io"
|
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_development_dependency "bundler", "~> 1.4"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_dependency "apostle"
|
25
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'apostle_rails'
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Apostle
|
2
|
+
module Mailer
|
3
|
+
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
# Reset default params
|
8
|
+
self.default_params = {}.freeze
|
9
|
+
|
10
|
+
def initialize(method_name = nil, *args)
|
11
|
+
super()
|
12
|
+
@_message = Apostle::Mail.new nil
|
13
|
+
@_apostle_known_instance_vars = (self.instance_variables.dup || [])
|
14
|
+
process(method_name, *args) if method_name
|
15
|
+
end
|
16
|
+
|
17
|
+
def process(method_name, *args)
|
18
|
+
self.send(method_name, *args)
|
19
|
+
end
|
20
|
+
|
21
|
+
def mail(template, headers, &block)
|
22
|
+
m = @_message
|
23
|
+
m.template_id = template
|
24
|
+
|
25
|
+
# Call all the procs (if any)
|
26
|
+
class_default = self.class.default
|
27
|
+
default_values = class_default.merge(class_default) do |k,v|
|
28
|
+
v.respond_to?(:to_proc) ? instance_eval(&v) : v
|
29
|
+
end
|
30
|
+
|
31
|
+
# Handle defaults
|
32
|
+
headers = headers.reverse_merge(default_values)
|
33
|
+
|
34
|
+
# Set configure delivery behavior
|
35
|
+
# TODO Enable config options such as perform_deliveries and raise_delivery_errors
|
36
|
+
# wrap_delivery_behavior!(headers.delete(:delivery_method),headers.delete(:delivery_method_options))
|
37
|
+
|
38
|
+
# List of assignable attributes
|
39
|
+
directly_assignable = [:to, :from, :email, :name, :layout_id, :template, :reply_to]
|
40
|
+
|
41
|
+
# Anything that's not an assignable attribute is a header
|
42
|
+
assignable_headers = headers.except(*directly_assignable)
|
43
|
+
assignable_headers.each { |k, v| m.header(k, v) }
|
44
|
+
|
45
|
+
# Assign the assignable attributes
|
46
|
+
assignable_attributes = headers.slice(*directly_assignable)
|
47
|
+
assignable_attributes.each { |k, v| m.send("#{k}=", v) }
|
48
|
+
|
49
|
+
# Assign all new instance vars as attributes
|
50
|
+
all_instance_vars = self.instance_variables.dup
|
51
|
+
@_apostle_known_instance_vars.push(:@_apostle_known_instance_vars)
|
52
|
+
(
|
53
|
+
all_instance_vars - @_apostle_known_instance_vars
|
54
|
+
).
|
55
|
+
each do |attr|
|
56
|
+
value = self.instance_variable_get(attr).to_json
|
57
|
+
attr = attr.to_s.gsub('@', '')
|
58
|
+
if m.respond_to?(attr)
|
59
|
+
m.send(attr, value)
|
60
|
+
else
|
61
|
+
m.data[attr] = value
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
m
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: apostle-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mal Curtis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.4'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
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: apostle
|
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
|
+
description: Rails Bindings for Apostle
|
56
|
+
email:
|
57
|
+
- mal@apostle.io
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- apostle-rails.gemspec
|
68
|
+
- lib/apostle-rails.rb
|
69
|
+
- lib/apostle_rails.rb
|
70
|
+
- lib/apostle_rails/mailer.rb
|
71
|
+
- lib/apostle_rails/version.rb
|
72
|
+
homepage: http://apostle.io
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.0.3
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Easy Rails integration for Apostle
|
96
|
+
test_files: []
|