maildotyml 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +22 -0
- data/README.md +58 -0
- data/Rakefile +1 -0
- data/lib/maildotyml/configuration.rb +32 -0
- data/lib/maildotyml/railtie.rb +7 -0
- data/lib/maildotyml/version.rb +3 -0
- data/lib/maildotyml.rb +12 -0
- metadata +107 -0
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Amiel Martin
|
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,58 @@
|
|
1
|
+
# Maildotyml
|
2
|
+
|
3
|
+
Configure ActionMailer with mail.yml, like ActiveRecord and database.yml.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'maildotyml'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
Add a `config/mail.yml` to your project.
|
18
|
+
|
19
|
+
Here is an example to get you started:
|
20
|
+
|
21
|
+
```yaml
|
22
|
+
development:
|
23
|
+
adapter: :smtp
|
24
|
+
address: 'localhost'
|
25
|
+
port: 25
|
26
|
+
domain: 'localhost.localdomain'
|
27
|
+
enable_startttls_auto: true
|
28
|
+
|
29
|
+
test:
|
30
|
+
adapter: :test
|
31
|
+
|
32
|
+
production:
|
33
|
+
adapter: :smtp
|
34
|
+
address: 'your.smtp.server'
|
35
|
+
port: 25
|
36
|
+
authentication: 'login'
|
37
|
+
domain: 'your.domain-to.authenticate-to.smtp.com'
|
38
|
+
user_name: <%= ENV['MAIL_USERNAME'] %>
|
39
|
+
password: <%= ENV['MAIL_PASSWORD'] %>
|
40
|
+
enable_startttls_auto: true
|
41
|
+
```
|
42
|
+
|
43
|
+
## TODO
|
44
|
+
|
45
|
+
The following features are planned for the near future:
|
46
|
+
|
47
|
+
* Add a generator to create `config/mail.yml.example` with example configuration.
|
48
|
+
* Better error handling (if `mail.yml` doesn't exist, or environment is not present).
|
49
|
+
* Map common ActiveRecord configuration keys.
|
50
|
+
(ie, `username` -> `user_name`).
|
51
|
+
|
52
|
+
## Contributing
|
53
|
+
|
54
|
+
1. Fork it
|
55
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
56
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
57
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
58
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'erb'
|
3
|
+
require 'active_support/core_ext/hash/keys'
|
4
|
+
|
5
|
+
module Maildotyml
|
6
|
+
class Configuration
|
7
|
+
attr_reader :file, :environment
|
8
|
+
def initialize(file, environment)
|
9
|
+
@file, @environment = file, environment
|
10
|
+
end
|
11
|
+
|
12
|
+
def delivery_method
|
13
|
+
parsed[:adapter]
|
14
|
+
end
|
15
|
+
|
16
|
+
def settings
|
17
|
+
parsed.reject { |k,v| k == :adapter }
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def parsed
|
23
|
+
# TODO: What to do if there is no environment
|
24
|
+
@_parsed ||= yaml.fetch(environment).symbolize_keys
|
25
|
+
end
|
26
|
+
|
27
|
+
def yaml
|
28
|
+
YAML.load ERB.new(file.read).result
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
data/lib/maildotyml.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'maildotyml/version'
|
2
|
+
require 'maildotyml/configuration'
|
3
|
+
require 'maildotyml/railtie' if defined?(Rails)
|
4
|
+
|
5
|
+
|
6
|
+
module Maildotyml
|
7
|
+
def self.configure(file, environment)
|
8
|
+
configuration = Maildotyml::Configuration.new(file, environment)
|
9
|
+
ActionMailer::Base.delivery_method = configuration.delivery_method
|
10
|
+
ActionMailer::Base.send(:"#{configuration.delivery_method}_settings=", configuration.settings)
|
11
|
+
end
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: maildotyml
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Amiel Martin
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rails
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: Add mail.yml to rails
|
63
|
+
email:
|
64
|
+
- amiel@carnesmedia.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- lib/maildotyml/configuration.rb
|
70
|
+
- lib/maildotyml/railtie.rb
|
71
|
+
- lib/maildotyml/version.rb
|
72
|
+
- lib/maildotyml.rb
|
73
|
+
- LICENSE.txt
|
74
|
+
- Rakefile
|
75
|
+
- README.md
|
76
|
+
homepage: https://github.com/carnesmedia/maildotyml
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
segments:
|
90
|
+
- 0
|
91
|
+
hash: -579743184437110137
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
segments:
|
99
|
+
- 0
|
100
|
+
hash: -579743184437110137
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 1.8.25
|
104
|
+
signing_key:
|
105
|
+
specification_version: 3
|
106
|
+
summary: Configure ActionMailer with mail.yml, like ActiveRecord and database.yml.
|
107
|
+
test_files: []
|