Browse files

Initial commit

  • Loading branch information...
0 parents commit 33872cfadae51b0ec4062aaba925399fd043a5ac @sickill committed Jan 10, 2010
Showing with 67 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +11 −0 Rakefile
  3. +38 −0 lib/merb_resque_mailer.rb
  4. +16 −0 merb_resque_mailer.gemspec
2 .gitignore
@@ -0,0 +1,2 @@
+pkg
+
11 Rakefile
@@ -0,0 +1,11 @@
+require 'rubygems'
+require 'rake'
+require 'rake/gempackagetask'
+
+task :default => [:repackage]
+
+spec = eval(File.read('merb_resque_mailer.gemspec'))
+
+Rake::GemPackageTask.new(spec) do |pkg|
+ pkg.need_tar = true
+end
38 lib/merb_resque_mailer.rb
@@ -0,0 +1,38 @@
+require 'resque'
+
+module Resque
+ module Mailer
+
+ def self.included(base)
+ base.extend(ClassMethods)
+ end
+
+ module ClassMethods
+ def queue
+ :mailer
+ end
+
+ def perform(params, method, mail_params)
+ new(params).dispatch_and_deliver!(method, mail_params)
+ end
+ end
+
+ def self.excluded_environments=(*environments)
+ @@excluded_environments = environments && environments.flatten.collect! { |env| env.to_sym }
+ end
+
+ def self.excluded_environments
+ @@excluded_environments ||= []
+ end
+
+ alias :dispatch_and_deliver! :dispatch_and_deliver
+
+ def dispatch_and_deliver(method, mail_params)
+ if ::Resque::Mailer.excluded_environments.include?(Merb.env.to_sym)
+ dispatch_and_deliver!(method, mail_params)
+ else
+ ::Resque.enqueue(self.class, @params, method, mail_params)
+ end
+ end
+ end
+end
16 merb_resque_mailer.gemspec
@@ -0,0 +1,16 @@
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{merb_resque_mailer}
+ s.version = "0.1"
+ s.platform = Gem::Platform::RUBY
+ s.date = %q{2010-01-10}
+ s.authors = ["Marcin Kulik"]
+ s.email = %q{marcin.kulik@gmail.com}
+ s.has_rdoc = false
+ s.homepage = %q{http://sickill.net}
+ s.summary = %q{Merb plugin for putting mail deliveries onto Resque queue}
+ s.files = [ "lib/merb_resque_mailer.rb" ]
+ s.add_dependency 'merb-mailer'
+ s.add_dependency 'resque'
+end

0 comments on commit 33872cf

Please sign in to comment.