aerogel-mailer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8d2ded2ae8256f5f9459d757c4365d4ec7ac6063
4
+ data.tar.gz: 16cd2ad084083d218f9b4e9def41ad5685e63dcd
5
+ SHA512:
6
+ metadata.gz: a3e154ffcc6f1f6d47e7505b251f24435b9a92b888c7b5224720baba5890d265efcd960398d97f4593a291e68ce85ba22713acd17a4b9b3ab52dd587f53a2eb5
7
+ data.tar.gz: 43e997ca8c98234f571ea11763df72f2f4acf2f7c5d965bc1d821969d454124ef89ba22bc40d6342a70aae498b5e4e66234d3cea651af2bc53402a21e40af47b
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in aerogel-module123.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Alex Kukushkin
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,25 @@
1
+ # aerogel-mailer
2
+
3
+ A mail delivery module for aerogel applications.
4
+
5
+ ## Usage
6
+
7
+
8
+ In your application's config.ru:
9
+ ```ruby
10
+ require 'aerogel/core'
11
+ require 'aerogel/mailer' #
12
+
13
+ # define a new mailer named :test
14
+ Aerogel.mailer :test do |f, t|
15
+ from f
16
+ to t
17
+ subject 'test'
18
+ body 'hello'
19
+ end
20
+
21
+ # then send email message using this mailer:
22
+ Aerogel.email :test, 'from@domain.org', 'to@another.org'
23
+
24
+ run Aerogel::Application.load
25
+ ```
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -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 'aerogel/mailer/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "aerogel-mailer"
8
+ spec.version = Aerogel::Mailer::VERSION
9
+ spec.authors = ["Alex Kukushkin"]
10
+ spec.email = ["alex@kukushk.in"]
11
+ spec.description = %q{Mail sending for aerogel applications}
12
+ spec.summary = %q{Mail sending for aerogel applications}
13
+ spec.homepage = ""
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 "aerogel-core"
22
+ spec.add_dependency "mail"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake"
26
+ end
@@ -0,0 +1,7 @@
1
+ module Aerogel::Helpers
2
+
3
+ def email( *args )
4
+ Aerogel.email( *args )
5
+ end
6
+
7
+ end # module Aerogel::Helpers
data/config/README.md ADDED
@@ -0,0 +1,3 @@
1
+ A place for your ```*.conf``` files.
2
+
3
+ Environment specific configs go into folders 'production' or 'development'.
@@ -0,0 +1,4 @@
1
+ mailer {
2
+ delivery_method :smtp
3
+ delivery_options address: 'localhost', port: 1025
4
+ }
@@ -0,0 +1,3 @@
1
+ mailer {
2
+ delivery_method :test
3
+ }
@@ -0,0 +1,4 @@
1
+ mailer {
2
+ delivery_method :smtp
3
+ delivery_options address: 'localhost', port: 25
4
+ }
@@ -0,0 +1,21 @@
1
+ require 'aerogel/core'
2
+ require 'aerogel/mailer/version'
3
+ require 'aerogel/mailer/core'
4
+ require 'aerogel/mailer/definition'
5
+
6
+ module Aerogel
7
+
8
+ # register module's root folder
9
+ register_path File.join( File.dirname(__FILE__), '..', '..' )
10
+
11
+ # configure module
12
+ on_load do |app|
13
+ Mailer.configure
14
+ end
15
+
16
+ # Extend Aerogel
17
+ #
18
+ extend Aerogel::Mailer
19
+
20
+ end
21
+
@@ -0,0 +1,48 @@
1
+ require 'mail'
2
+
3
+ module Aerogel::Mailer
4
+
5
+ def self.configure
6
+ aerogel_delivery_method = Aerogel.config.mailer.delivery_method
7
+ aerogel_delivery_options = Aerogel.config.mailer.delivery_options.raw || {}
8
+ Mail.defaults do
9
+ delivery_method aerogel_delivery_method, aerogel_delivery_options
10
+ end
11
+ end
12
+
13
+ def self.register_mailer( mailer )
14
+ @mailers ||= {}
15
+ @mailers[mailer.name] = mailer
16
+ end
17
+
18
+ def self.mailers
19
+ @mailers || {}
20
+ end
21
+
22
+ # Registers new mailer
23
+ #
24
+ def mailer( name, &block )
25
+ Definition.new name, block
26
+ end
27
+
28
+ def email( name, *args )
29
+ unless Aerogel::Mailer.mailers[name]
30
+ raise ArgumentError.new "Mailer '#{name}' is not defined"
31
+ end
32
+ params = Aerogel::Mailer.mailers[name].eval( *args )
33
+ puts "** sending mail: #{params}"
34
+ begin
35
+ Mail.deliver do
36
+ from params[:from]
37
+ to params[:to]
38
+ subject params[:subject]
39
+ body params[:body]
40
+ end
41
+ rescue => e
42
+ raise "Mailer '#{name}' failed to deliver email: #{e}"
43
+ end
44
+ # params,
45
+ end
46
+
47
+
48
+ end # module Aerogel::Mailer
@@ -0,0 +1,40 @@
1
+ module Aerogel::Mailer
2
+ class Definition
3
+
4
+ attr_accessor :name, :blk, :params
5
+
6
+ def initialize( name, blk )
7
+ self.name = name.to_sym
8
+ self.params = {}
9
+ self.blk = blk
10
+
11
+ Aerogel::Mailer.register_mailer( self )
12
+ end
13
+
14
+ def from( str )
15
+ params[:from] = str
16
+ end
17
+
18
+ def to( str )
19
+ params[:to] = str
20
+ end
21
+
22
+ def subject( str )
23
+ params[:subject] = str
24
+ end
25
+
26
+ def body( str )
27
+ params[:body] = str
28
+ end
29
+
30
+ def eval( *args )
31
+ unless args.size == blk.arity
32
+ raise ArgumentError.new("wrong number of arguments for mailer '#{name}': #{args.size} for #{blk.arity}")
33
+ end
34
+ self.instance_exec( *args, &blk )
35
+ params
36
+ end
37
+
38
+ end # class Definition
39
+ end # module Aerogel::Mailer
40
+
@@ -0,0 +1,5 @@
1
+ module Aerogel
2
+ module Mailer
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
data/views/README.md ADDED
@@ -0,0 +1 @@
1
+ A place for module views.
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aerogel-mailer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alex Kukushkin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aerogel-core
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: mail
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: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
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: Mail sending for aerogel applications
70
+ email:
71
+ - alex@kukushk.in
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - aerogel-mailer.gemspec
82
+ - app/helpers/email.rb
83
+ - config/README.md
84
+ - config/development/mailer.conf
85
+ - config/mailer.conf
86
+ - config/production/mailer.conf
87
+ - lib/aerogel/mailer.rb
88
+ - lib/aerogel/mailer/core.rb
89
+ - lib/aerogel/mailer/definition.rb
90
+ - lib/aerogel/mailer/version.rb
91
+ - views/README.md
92
+ homepage: ''
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.0.6
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Mail sending for aerogel applications
116
+ test_files: []