Permalink
Browse files

General overhaul of the gem. Support for Rails 3 added; changelog add…

…ed; README improved.
  • Loading branch information...
1 parent ea28615 commit 39b4137de3bf814fe75838ba1cf10e4bd758627e @isabanin isabanin committed Sep 15, 2010
View
@@ -0,0 +1,5 @@
+= Changelog
+
+== 0.3.0
+
+* Added support for Rails 3.
View
11 Gemfile
@@ -0,0 +1,11 @@
+source "http://rubygems.org"
+
+gem "actionmailer"
+gem "postmark", ">= 0.8.0"
+gem "rake"
+
+group :test do
+ gem "ruby-debug"
+ gem "rspec"
+ gem "jeweler"
+end
View
@@ -0,0 +1,72 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ abstract (1.0.0)
+ actionmailer (3.0.0)
+ actionpack (= 3.0.0)
+ mail (~> 2.2.5)
+ actionpack (3.0.0)
+ activemodel (= 3.0.0)
+ activesupport (= 3.0.0)
+ builder (~> 2.1.2)
+ erubis (~> 2.6.6)
+ i18n (~> 0.4.1)
+ rack (~> 1.2.1)
+ rack-mount (~> 0.6.12)
+ rack-test (~> 0.5.4)
+ tzinfo (~> 0.3.23)
+ activemodel (3.0.0)
+ activesupport (= 3.0.0)
+ builder (~> 2.1.2)
+ i18n (~> 0.4.1)
+ activesupport (3.0.0)
+ builder (2.1.2)
+ columnize (0.3.1)
+ erubis (2.6.6)
+ abstract (>= 1.0.0)
+ gemcutter (0.6.1)
+ git (1.2.5)
+ i18n (0.4.1)
+ jeweler (1.4.0)
+ gemcutter (>= 0.1.0)
+ git (>= 1.2.5)
+ rubyforge (>= 2.0.0)
+ json_pure (1.4.6)
+ linecache (0.43)
+ mail (2.2.6.1)
+ activesupport (>= 2.3.6)
+ mime-types
+ treetop (>= 1.4.5)
+ mime-types (1.16)
+ polyglot (0.3.1)
+ postmark (0.7.1)
+ tmail
+ rack (1.2.1)
+ rack-mount (0.6.13)
+ rack (>= 1.0.0)
+ rack-test (0.5.4)
+ rack (>= 1.0)
+ rake (0.8.7)
+ rspec (1.3.0)
+ ruby-debug (0.10.3)
+ columnize (>= 0.1)
+ ruby-debug-base (~> 0.10.3.0)
+ ruby-debug-base (0.10.3)
+ linecache (>= 0.3)
+ rubyforge (2.0.4)
+ json_pure (>= 1.1.7)
+ tmail (1.2.7.1)
+ treetop (1.4.8)
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.23)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ actionmailer
+ jeweler
+ postmark
+ rake
+ rspec
+ ruby-debug
View
@@ -1,63 +1,100 @@
-= Postmark rails gem
+= postmark-rails gem
-Postmark plug-in for ActionMailer
+The Postmark Rails Gem is a drop-in plug-in for ActionMailer to send emails via Postmark, an email delivery service for web apps. The gem has been created for fast implementation and fully supports all of Postmark’s features.
+
+== Supported Rails Versions
+
+* lower than 2.3: could work, but not tested
+* 2.3 and higher
+* 3.0
== Install
-The gem is hosted at gemcutter. If you don't have it, install it first:
+sudo gem install postmark
+sudo gem install postmark-rails
- sudo gem install gemcutter
- gem tumble
+== Requirements
-Then
- sudo gem install postmark-rails
+* Postmark version 0.8 and higher is required.
+* You will also need a Postmark account, server and sender signature set up to use it. To get an account, sign up at http://postmarkapp.com.
-== Example
+== Configuring your Rails application
- config/environment.rb
+=== Rails 3
- Rails::Initializer.run do |config|
+Add this to your config/application.rb:
+ config.action_mailer.delivery_method = :postmark
+ config.action_mailer.postmark_settings = { :api_key => "your-api-key" }
+
+=== Rails 2
+
+Add this to config/environment.rb:
+
+ Rails::Initializer.run do |config|
+
+ ...
+
+ config.gem 'postmark'
config.gem 'postmark-rails'
- require 'postmark-rails'
+ require 'postmark-rails'
+
config.action_mailer.postmark_api_key = "your-api-key"
- # ...
+ config.action_mailer.delivery_method = :postmark
+
+ ...
+
end
-Next, make postmark the delivery method for the production environment:
+For full API details, refer to the developer documentation at http://developer.postmarkapp.com.
- config/environments/production.rb
+== Tagging your deliveries
- config.action_mailer.delivery_method = :postmark
+You can use a tag to categorize outgoing messages and attach application-specific information. Tagging the different types of email that you send lets you review statistics and bounce reports separately. Read more at http://developer.postmarkapp.com/developer-build.html#message-format.
-You may also tag messages, in order to track bounces more precisely.
+=== Rails 3
class TestMailer < ActionMailer::Base
+
def tagged_message
- subject 'hello'
- recipients 'sheldon@bigbangtheory.com'
- from 'leonard@bigbangtheory.com'
- tag 'delivery'
+ mail(
+ :subject => 'hello',
+ :to => 'sheldon@bigbangtheory.com',
+ :from => 'leonard@bigbangtheory.com',
+ :tag => 'my-tag'
+ )
end
+
+ end
+
+=== Rails 2
+
+ class SuperMailer < ActionMailer::Base
+
+ def email
+ from "no-reply@beanseedapp.com"
+ subject "Testing new gem for Postmark"
+ recipients "ilya@wildbit.com"
+ tag "my-another-tag"
+ end
+
end
-
-== Limitations
-
- Currently postmark API does not support attachments. For more information, check the docs here:
- http://developer.postmarkapp.com
-
-== Requirements
-
-You will also need postmark account, server and sender signature set up to use it.
== Note on Patches/Pull Requests
* Fork the project.
* Make your feature addition or bug fix.
-* Add tests for it. This is important so I don't break it in a future version unintentionally.
+* Add tests for it. This is important so we dont break it in a future version unintentionally.
* Commit, do not mess with rakefile, version, or history.
-* Send me a pull request. Bonus points for topic branches.
+* Send a pull request. Bonus points for topic branches.
+
+== Authors & Contributors
+
+* Petyo Ivanov
+* Ilya Sabanin
+* Hristo Deshev
+* Randy Schmidt
== Copyright
-Copyright (c) 2009 Wildbit LLC. See LICENSE for details.
+Copyright © 2010 Wildbit LLC. See LICENSE for details.
View
@@ -7,11 +7,9 @@ begin
gem.name = "postmark-rails"
gem.summary = %Q{Postmark adapter for ActionMailer}
gem.description = %Q{Use this plugin in your rails applications to send emails through the Postmark API}
- gem.email = "underlog@gmail.com"
+ gem.email = "ilya@wildbit.com"
gem.homepage = "http://postmarkapp.com"
- gem.authors = ["Petyo Ivanov"]
- gem.add_development_dependency "rspec"
- gem.add_dependency 'postmark'
+ gem.authors = ["Petyo Ivanov", "Ilya Sabanin"]
gem.post_install_message = %q[
==================
View
@@ -1 +1 @@
-0.2.0
+0.3.0
View
12 init.rb
@@ -0,0 +1,12 @@
+def require_local(lib)
+ require File.join(File.dirname(__FILE__), 'lib', lib)
+end
+
+require_local 'postmark_installer'
+require_local 'postmark_delivery_method'
+
+#
+# Will detect your Rails version automatically
+# and install Postmark delivery method into ActionMailer properly.
+#
+PostmarkInstaller.auto_detect_and_install
@@ -1,7 +1,24 @@
-require 'postmark'
-require 'action_mailer'
-
-module PostmarkMethods
+#
+# This module is only used for Rails 2.
+#
+module PostmarkDeliveryMethod
+
+ module ClassMethods
+
+ def postmark_api_key=(value)
+ Postmark.api_key = value
+ end
+
+ end
+
+ def self.included(base)
+ base.extend(ClassMethods)
+
+ base.class_eval do
+ alias_method_chain :create_mail, :tag
+ end
+ end
+
def perform_delivery_postmark(message)
Postmark.send_through_postmark(message)
end
@@ -10,27 +27,10 @@ def tag(value)
@tag = value
end
- def self.included(base)
- base.extend(ClassMethods)
- base.class_eval do
- alias_method_chain :create_mail, :tag
- end
- end
-
def create_mail_with_tag
returning create_mail_without_tag do |mail|
mail.tag = @tag if @tag
end
end
-
- module ClassMethods
- def postmark_api_key=(value)
- Postmark.api_key = value
- end
- end
-
-end
-
-class ActionMailer::Base
- include PostmarkMethods
-end
+
+end
View
@@ -0,0 +1,23 @@
+require 'action_mailer'
+require 'postmark'
+
+module PostmarkInstaller
+ extend self
+
+ def auto_detect_and_install
+ if ActionMailer::Base.respond_to?(:add_delivery_method)
+ install_in_rails_3
+ else
+ install_in_rails_2
+ end
+ end
+
+ def install_in_rails_2
+ ActionMailer::Base.send(:include, PostmarkDeliveryMethod)
+ end
+
+ def install_in_rails_3
+ ActionMailer::Base.add_delivery_method :postmark, Mail::Postmark, :api_key => nil
+ end
+
+end
Oops, something went wrong.

0 comments on commit 39b4137

Please sign in to comment.