maildotyml 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -1
- data/Rakefile +9 -0
- data/lib/maildotyml/configuration.rb +12 -3
- data/lib/maildotyml/railtie.rb +3 -1
- data/lib/maildotyml/version.rb +1 -1
- data/lib/maildotyml.rb +12 -5
- metadata +3 -3
data/README.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
Configure ActionMailer with mail.yml, like ActiveRecord and database.yml.
|
4
4
|
|
5
|
+
[![Build Status](https://travis-ci.org/carnesmedia/maildotyml.png)](https://travis-ci.org/carnesmedia/maildotyml)
|
6
|
+
[![Coverage Status](https://coveralls.io/repos/carnesmedia/maildotyml/badge.png)](https://coveralls.io/r/carnesmedia/maildotyml)
|
7
|
+
|
8
|
+
|
5
9
|
## Installation
|
6
10
|
|
7
11
|
Add this line to your application's Gemfile:
|
@@ -45,7 +49,6 @@ production:
|
|
45
49
|
The following features are planned for the near future:
|
46
50
|
|
47
51
|
* 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
52
|
* Map common ActiveRecord configuration keys.
|
50
53
|
(ie, `username` -> `user_name`).
|
51
54
|
|
data/Rakefile
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'erb'
|
3
3
|
require 'active_support/core_ext/hash/keys'
|
4
|
+
require 'active_support/core_ext/object/blank'
|
4
5
|
|
5
6
|
module Maildotyml
|
6
7
|
class Configuration
|
@@ -10,22 +11,30 @@ module Maildotyml
|
|
10
11
|
end
|
11
12
|
|
12
13
|
def delivery_method
|
13
|
-
parsed[:adapter]
|
14
|
+
parsed[:adapter].to_sym if parsed[:adapter]
|
14
15
|
end
|
15
16
|
|
16
17
|
def settings
|
17
18
|
parsed.reject { |k,v| k == :adapter }
|
18
19
|
end
|
19
20
|
|
21
|
+
def present?
|
22
|
+
parsed.present?
|
23
|
+
end
|
24
|
+
|
20
25
|
private
|
21
26
|
|
22
27
|
def parsed
|
23
28
|
# TODO: What to do if there is no environment
|
24
|
-
@_parsed ||= yaml.fetch(environment).symbolize_keys
|
29
|
+
@_parsed ||= yaml.fetch(environment, {}).symbolize_keys
|
25
30
|
end
|
26
31
|
|
27
32
|
def yaml
|
28
|
-
|
33
|
+
if file.exist?
|
34
|
+
YAML.load ERB.new(file.read).result
|
35
|
+
else
|
36
|
+
{}
|
37
|
+
end
|
29
38
|
end
|
30
39
|
|
31
40
|
end
|
data/lib/maildotyml/railtie.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
module Maildotyml
|
2
2
|
class Railtie < ::Rails::Railtie
|
3
3
|
initializer 'maildotyml.initialize' do |app|
|
4
|
-
|
4
|
+
file = Rails.root.join('config/mail.yml')
|
5
|
+
configuration = Maildotyml::Configuration.new(file, Rails.env)
|
6
|
+
Maildotyml.configure(configuration)
|
5
7
|
end
|
6
8
|
end
|
7
9
|
end
|
data/lib/maildotyml/version.rb
CHANGED
data/lib/maildotyml.rb
CHANGED
@@ -2,11 +2,18 @@ require 'maildotyml/version'
|
|
2
2
|
require 'maildotyml/configuration'
|
3
3
|
require 'maildotyml/railtie' if defined?(Rails)
|
4
4
|
|
5
|
-
|
6
5
|
module Maildotyml
|
7
|
-
def self.configure(
|
8
|
-
configuration
|
9
|
-
|
10
|
-
|
6
|
+
def self.configure(configuration, klass = ActionMailer::Base)
|
7
|
+
if configuration.present?
|
8
|
+
delivery_method = configuration.delivery_method
|
9
|
+
|
10
|
+
if klass.delivery_methods.include? delivery_method
|
11
|
+
klass.delivery_method = delivery_method
|
12
|
+
klass.send(:"#{delivery_method}_settings=", configuration.settings)
|
13
|
+
else
|
14
|
+
available_adapters = klass.delivery_methods.keys
|
15
|
+
raise ArgumentError, "ActionMailer does not support the #{delivery_method.inspect} adapter. Available adapters are: #{available_adapters.inspect}"
|
16
|
+
end
|
17
|
+
end
|
11
18
|
end
|
12
19
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maildotyml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -88,7 +88,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
88
|
version: '0'
|
89
89
|
segments:
|
90
90
|
- 0
|
91
|
-
hash: -
|
91
|
+
hash: -480117984576728793
|
92
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
93
|
none: false
|
94
94
|
requirements:
|
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
97
|
version: '0'
|
98
98
|
segments:
|
99
99
|
- 0
|
100
|
-
hash: -
|
100
|
+
hash: -480117984576728793
|
101
101
|
requirements: []
|
102
102
|
rubyforge_project:
|
103
103
|
rubygems_version: 1.8.25
|