public
Description: Deliver email to local db and have it send by sequel_sendmail later. Attempt at a clone of ar_mailer for merb + sequel.
Clone URL: git://github.com/bricooke/sequel_mailer.git
Search Repo:
Initial rev of sequel_mailer. Can store your mail in the db, but nothing 
to read it yet.
bricooke (author)
Sat Mar 08 15:07:12 -0800 2008
commit  2b0f38752d0817fd0418fd6506769a5c0f87aeea
tree    2d924c7716a63901a2bcf7360b7a8733f7c61dc9
...
 
0
...
1
2
0
@@ -0,0 +1 @@
0
+pkg
0
\ No newline at end of file
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
0
@@ -0,0 +1,20 @@
0
+Copyright (c) 2008 YOUR NAME
0
+
0
+Permission is hereby granted, free of charge, to any person obtaining
0
+a copy of this software and associated documentation files (the
0
+"Software"), to deal in the Software without restriction, including
0
+without limitation the rights to use, copy, modify, merge, publish,
0
+distribute, sublicense, and/or sell copies of the Software, and to
0
+permit persons to whom the Software is furnished to do so, subject to
0
+the following conditions:
0
+
0
+The above copyright notice and this permission notice shall be
0
+included in all copies or substantial portions of the Software.
0
+
0
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
0
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
0
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
0
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0
\ No newline at end of file
0
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
0
@@ -0,0 +1,45 @@
0
+sequel_mailer
0
+=============
0
+
0
+My attempt at a clone of ar_mailer (http://seattlerb.rubyforge.org/ar_mailer/) for Merb 0.9.1+ and the Sequel ORM.
0
+
0
+Status
0
+=============
0
+The plugin can be used in your merb app, but there's nothing to send the mail yet.
0
+
0
+
0
+Using
0
+=============
0
++ Create the migration for your model (Assumes model will be named Email):
0
+
0
+class EmailMigration < Sequel::Migration
0
+ def up
0
+ create_table "emails" do
0
+ primary_key :id
0
+ varchar :from_address
0
+ varchar :to_address
0
+ varchar :last_send_attempt, :default => 0
0
+ text :mail
0
+ datetime :created_on
0
+ end
0
+ end
0
+
0
+ def down
0
+ execute "DROP TABLE emails"
0
+ end
0
+end
0
+
0
+
0
++ Set the delivery_method and class to be used:
0
+
0
+Merb::Mailer.delivery_method = :sequel
0
+Merb::Mailer.config = {:sequel_mailer_class => Email}
0
+
0
++ Enjoy
0
+
0
+
0
+TODO
0
+=============
0
++ Write specs for the mailer
0
++ Write the sequel_sendmail daemon
0
++ Write a generator for the migration and setting the config
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
0
@@ -0,0 +1,44 @@
0
+require 'rubygems'
0
+require 'rake/gempackagetask'
0
+
0
+PLUGIN = "sequel_mailer"
0
+NAME = "sequel_mailer"
0
+VERSION = "0.0.1"
0
+AUTHOR = "Brian Cooke"
0
+EMAIL = "bcooke@roobasoft.com"
0
+HOMEPAGE = "http://"
0
+SUMMARY = "Merb plugin that provides a :sequel mailer based on ar_mailer"
0
+
0
+spec = Gem::Specification.new do |s|
0
+ s.name = NAME
0
+ s.version = VERSION
0
+ s.platform = Gem::Platform::RUBY
0
+ s.has_rdoc = true
0
+ s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
0
+ s.summary = SUMMARY
0
+ s.description = s.summary
0
+ s.author = AUTHOR
0
+ s.email = EMAIL
0
+ s.homepage = HOMEPAGE
0
+ s.add_dependency('merb-more', '>= 0.9.1')
0
+ s.require_path = 'lib'
0
+ s.autorequire = PLUGIN
0
+ s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,specs}/**/*")
0
+end
0
+
0
+Rake::GemPackageTask.new(spec) do |pkg|
0
+ pkg.gem_spec = spec
0
+end
0
+
0
+task :install => [:package] do
0
+ sh %{sudo gem install pkg/#{NAME}-#{VERSION}}
0
+end
0
+
0
+namespace :jruby do
0
+
0
+ desc "Run :package and install the resulting .gem with jruby"
0
+ task :install => :package do
0
+ sh %{#{SUDO} jruby -S gem install pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
0
+ end
0
+
0
+end
0
\ No newline at end of file
0
...
 
 
 
 
 
0
...
1
2
3
4
5
6
0
@@ -0,0 +1,5 @@
0
+TODO:
0
+Fix LICENSE with your name
0
+Fix Rakefile with your name and contact info
0
+Add your code to lib/sequel_mailer.rb
0
+Add your Merb rake tasks to lib/sequel_mailer/merbtasks.rb
0
\ No newline at end of file
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
0
@@ -0,0 +1,57 @@
0
+# make sure we're running inside Merb
0
+if defined?(Merb::Plugins)
0
+
0
+ # Merb gives you a Merb::Plugins.config hash...feel free to put your stuff in your piece of it
0
+ Merb::Plugins.config[:sequel_mailer] = {
0
+ :chickens => false
0
+ }
0
+
0
+ Merb::BootLoader.before_app_loads do
0
+ end
0
+
0
+ Merb::BootLoader.after_app_loads do
0
+ # require code that must be loaded before the application
0
+ require "merb-mailer"
0
+ require "merb_sequel"
0
+ require "sequel"
0
+
0
+ class SequelMailer < Merb::Mailer
0
+ @@email_class = Merb::Mailer.config[:sequel_mailer_class] || Email
0
+
0
+ ##
0
+ # Current email class for deliveries.
0
+ def self.email_class
0
+ @@email_class
0
+ end
0
+
0
+ ##
0
+ # Sets the email class for deliveries.
0
+
0
+ def self.email_class=(klass)
0
+ @@email_class = klass
0
+ end
0
+
0
+ ##
0
+ # Adds +mail+ to the Email table. Only the first From address for +mail+ is
0
+ # used.
0
+
0
+ def sequel
0
+ debugger
0
+ @mail.to.each do |destination|
0
+ r = @@email_class.create({
0
+ :mail => @mail.to_s,
0
+ :to_address => destination,
0
+ :from_address => @mail.from.first,
0
+ :created_on => Time.now
0
+ })
0
+ end
0
+ end
0
+ end
0
+
0
+ class SequelMailController < Merb::MailController
0
+ self._mailer_klass = SequelMailer
0
+ end
0
+ end
0
+
0
+ Merb::Plugins.add_rakefiles "sequel_mailer/merbtasks"
0
+end
0
\ No newline at end of file
...
 
 
 
 
 
 
0
...
1
2
3
4
5
6
7
0
@@ -0,0 +1,6 @@
0
+namespace :sequel_mailer do
0
+ desc "Do something for sequel_mailer"
0
+ task :default do
0
+ puts "sequel_mailer doesn't do anything"
0
+ end
0
+end
0
\ No newline at end of file
...
 
 
 
 
 
 
 
0
...
1
2
3
4
5
6
7
8
0
@@ -0,0 +1,7 @@
0
+require File.dirname(__FILE__) + '/spec_helper'
0
+
0
+describe "sequel_mailer" do
0
+ it "should do nothing" do
0
+ true.should == true
0
+ end
0
+end
0
\ No newline at end of file
...
 
 
0
...
1
2
3
0
@@ -0,0 +1,2 @@
0
+$TESTING=true
0
+$:.push File.join(File.dirname(__FILE__), '..', 'lib')
0
\ No newline at end of file

Comments

    No one has commented yet.