Permalink
Browse files

add delayed_mailhopper

  • Loading branch information...
1 parent 93fba23 commit 5d8e5e92839171e6804b11663848f43c0b915cbb @jduan jduan committed Jan 3, 2012
View
7 Gemfile
@@ -17,6 +17,13 @@ gem 'acts-as-taggable-on'
gem 'jquery-rails'
################
+# Mail #
+################
+
+gem 'delayed_mailhopper'
+gem 'delayed_job_active_record'
+
+################
# Presentation #
################
View
12 Gemfile.lock
@@ -65,6 +65,14 @@ GEM
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.1)
+ delayed_job (3.0.0)
+ activesupport (~> 3.0)
+ delayed_job_active_record (0.3.1)
+ activerecord (> 2.1.0)
+ delayed_job (~> 3.0.0)
+ delayed_mailhopper (0.0.2)
+ delayed_job
+ mailhopper (~> 0.0.1)
erubis (2.7.0)
exception_notification (2.5.2)
actionmailer (>= 3.0.4)
@@ -94,6 +102,8 @@ GEM
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
+ mailhopper (0.0.5)
+ rails (~> 3.1.0)
mime-types (1.16)
minitest (2.3.1)
multi_json (1.0.3)
@@ -232,6 +242,8 @@ DEPENDENCIES
coffee-rails (~> 3.1.0)
colorific (~> 1.0.0)
compass (~> 0.12.alpha)
+ delayed_job_active_record
+ delayed_mailhopper
exception_notification
factory_girl_rails
haml
View
3 config/initializers/mailhopper.rb
@@ -0,0 +1,3 @@
+Mailhopper::Base.setup do |config|
+ config.default_delivery_method = :smtp
+end
View
29 db/migrate/20120103065730_create_emails.rb
@@ -0,0 +1,29 @@
+# Everything listed in this migration will be added to a migration file
+# inside of your main app.
+class CreateEmails < ActiveRecord::Migration
+ def self.up
+ create_table :emails do |t|
+ t.string :from_address, :null => false
+
+ t.string :reply_to_address,
+ :subject
+
+ # The following addresses have been defined as text fields to allow for multiple recipients. These fields could
+ # instead be defined as strings, and even indexed, if you'd like to improve search performance and you can
+ # confidently limit the size of their contents.
+
+ t.text :to_address,
+ :cc_address,
+ :bcc_address
+
+ t.text :content
+
+ t.datetime :sent_at
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :emails
+ end
+end
View
22 db/migrate/20120103073336_create_delayed_jobs.rb
@@ -0,0 +1,22 @@
+class CreateDelayedJobs < ActiveRecord::Migration
+ def self.up
+ create_table :delayed_jobs, :force => true do |table|
+ table.integer :priority, :default => 0 # Allows some jobs to jump to the front of the queue
+ table.integer :attempts, :default => 0 # Provides for retries, but still fail eventually.
+ table.text :handler # YAML-encoded string of the object that will do work
+ table.text :last_error # reason for last failure (See Note below)
+ table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
+ table.datetime :locked_at # Set when a client is working on this object
+ table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
+ table.string :locked_by # Who is working on this object (if locked)
+ table.string :queue # The name of the queue this job is in
+ table.timestamps
+ end
+
+ add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority'
+ end
+
+ def self.down
+ drop_table :delayed_jobs
+ end
+end
View
31 db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20111116150031) do
+ActiveRecord::Schema.define(:version => 20120103073336) do
create_table "announcements", :force => true do |t|
t.text "body"
@@ -45,6 +45,35 @@
t.datetime "updated_at"
end
+ create_table "delayed_jobs", :force => true do |t|
+ t.integer "priority", :default => 0
+ t.integer "attempts", :default => 0
+ t.text "handler"
+ t.text "last_error"
+ t.datetime "run_at"
+ t.datetime "locked_at"
+ t.datetime "failed_at"
+ t.string "locked_by"
+ t.string "queue"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority"
+
+ create_table "emails", :force => true do |t|
+ t.string "from_address", :null => false
+ t.string "reply_to_address"
+ t.string "subject"
+ t.text "to_address"
+ t.text "cc_address"
+ t.text "bcc_address"
+ t.text "content"
+ t.datetime "sent_at"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
create_table "puzzles", :force => true do |t|
t.text "name"
t.text "short_description"
View
5 script/delayed_job
@@ -0,0 +1,5 @@
+#!/usr/bin/env ruby
+
+require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
+require 'delayed/command'
+Delayed::Command.new(ARGV).daemonize

0 comments on commit 5d8e5e9

Please sign in to comment.