postmark-rails 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,5 @@
1
+ = Changelog
2
+
3
+ == 0.3.0
4
+
5
+ * Added support for Rails 3.
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "actionmailer"
4
+ gem "postmark", ">= 0.8.0"
5
+ gem "rake"
6
+
7
+ group :test do
8
+ gem "ruby-debug"
9
+ gem "rspec"
10
+ gem "jeweler"
11
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,72 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ abstract (1.0.0)
5
+ actionmailer (3.0.0)
6
+ actionpack (= 3.0.0)
7
+ mail (~> 2.2.5)
8
+ actionpack (3.0.0)
9
+ activemodel (= 3.0.0)
10
+ activesupport (= 3.0.0)
11
+ builder (~> 2.1.2)
12
+ erubis (~> 2.6.6)
13
+ i18n (~> 0.4.1)
14
+ rack (~> 1.2.1)
15
+ rack-mount (~> 0.6.12)
16
+ rack-test (~> 0.5.4)
17
+ tzinfo (~> 0.3.23)
18
+ activemodel (3.0.0)
19
+ activesupport (= 3.0.0)
20
+ builder (~> 2.1.2)
21
+ i18n (~> 0.4.1)
22
+ activesupport (3.0.0)
23
+ builder (2.1.2)
24
+ columnize (0.3.1)
25
+ erubis (2.6.6)
26
+ abstract (>= 1.0.0)
27
+ gemcutter (0.6.1)
28
+ git (1.2.5)
29
+ i18n (0.4.1)
30
+ jeweler (1.4.0)
31
+ gemcutter (>= 0.1.0)
32
+ git (>= 1.2.5)
33
+ rubyforge (>= 2.0.0)
34
+ json_pure (1.4.6)
35
+ linecache (0.43)
36
+ mail (2.2.6.1)
37
+ activesupport (>= 2.3.6)
38
+ mime-types
39
+ treetop (>= 1.4.5)
40
+ mime-types (1.16)
41
+ polyglot (0.3.1)
42
+ postmark (0.7.1)
43
+ tmail
44
+ rack (1.2.1)
45
+ rack-mount (0.6.13)
46
+ rack (>= 1.0.0)
47
+ rack-test (0.5.4)
48
+ rack (>= 1.0)
49
+ rake (0.8.7)
50
+ rspec (1.3.0)
51
+ ruby-debug (0.10.3)
52
+ columnize (>= 0.1)
53
+ ruby-debug-base (~> 0.10.3.0)
54
+ ruby-debug-base (0.10.3)
55
+ linecache (>= 0.3)
56
+ rubyforge (2.0.4)
57
+ json_pure (>= 1.1.7)
58
+ tmail (1.2.7.1)
59
+ treetop (1.4.8)
60
+ polyglot (>= 0.3.1)
61
+ tzinfo (0.3.23)
62
+
63
+ PLATFORMS
64
+ ruby
65
+
66
+ DEPENDENCIES
67
+ actionmailer
68
+ jeweler
69
+ postmark
70
+ rake
71
+ rspec
72
+ ruby-debug
data/README.rdoc CHANGED
@@ -1,63 +1,107 @@
1
- = Postmark rails gem
1
+ = postmark-rails gem
2
2
 
3
- Postmark plug-in for ActionMailer
3
+ 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.
4
4
 
5
- == Install
5
+ == Supported Rails Versions
6
6
 
7
- The gem is hosted at gemcutter. If you don't have it, install it first:
7
+ * lower than 2.3: could work, but not tested
8
+ * 2.3 and higher
9
+ * 3.0
8
10
 
9
- sudo gem install gemcutter
10
- gem tumble
11
+ == Install
11
12
 
12
- Then
13
+ sudo gem install postmark
13
14
  sudo gem install postmark-rails
14
15
 
15
- == Example
16
+ == Requirements
16
17
 
17
- config/environment.rb
18
+ * "postmark" gem version 0.8 and higher is required.
19
+ * 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.
18
20
 
19
- Rails::Initializer.run do |config|
21
+ == Configuring your Rails application
22
+
23
+ === Rails 3
24
+
25
+ Add this to your Gemfile: (change version numbers if needed)
26
+
27
+ gem 'postmark', '0.8.0'
28
+ gem 'postmark-rails', '0.3.0'
29
+
30
+ Don't forget to run "bundle install" command every time you change something in the Gemfile.
31
+
32
+ Add this to your config/application.rb:
33
+
34
+ config.action_mailer.delivery_method = :postmark
35
+ config.action_mailer.postmark_settings = { :api_key => "your-api-key" }
36
+
37
+ === Rails 2
38
+
39
+ Add this to config/environment.rb:
20
40
 
41
+ Rails::Initializer.run do |config|
42
+
43
+ ...
44
+
45
+ config.gem 'postmark'
21
46
  config.gem 'postmark-rails'
22
- require 'postmark-rails'
47
+ require 'postmark-rails'
48
+
23
49
  config.action_mailer.postmark_api_key = "your-api-key"
24
- # ...
50
+ config.action_mailer.delivery_method = :postmark
51
+
52
+ ...
53
+
25
54
  end
26
55
 
27
- Next, make postmark the delivery method for the production environment:
56
+ For API details, refer to the developer documentation at http://developer.postmarkapp.com.
28
57
 
29
- config/environments/production.rb
58
+ == Tagging your deliveries
30
59
 
31
- config.action_mailer.delivery_method = :postmark
60
+ 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.
32
61
 
33
- You may also tag messages, in order to track bounces more precisely.
62
+ === Rails 3
34
63
 
35
64
  class TestMailer < ActionMailer::Base
65
+
36
66
  def tagged_message
37
- subject 'hello'
38
- recipients 'sheldon@bigbangtheory.com'
39
- from 'leonard@bigbangtheory.com'
40
- tag 'delivery'
67
+ mail(
68
+ :subject => 'hello',
69
+ :to => 'sheldon@bigbangtheory.com',
70
+ :from => 'leonard@bigbangtheory.com',
71
+ :tag => 'my-tag'
72
+ )
41
73
  end
74
+
75
+ end
76
+
77
+ === Rails 2
78
+
79
+ class SuperMailer < ActionMailer::Base
80
+
81
+ def email
82
+ from "no-reply@beanseedapp.com"
83
+ subject "Testing new gem for Postmark"
84
+ recipients "ilya@wildbit.com"
85
+ tag "my-another-tag"
86
+ end
87
+
42
88
  end
43
-
44
- == Limitations
45
-
46
- Currently postmark API does not support attachments. For more information, check the docs here:
47
- http://developer.postmarkapp.com
48
-
49
- == Requirements
50
-
51
- You will also need postmark account, server and sender signature set up to use it.
52
89
 
53
90
  == Note on Patches/Pull Requests
54
91
 
55
92
  * Fork the project.
56
93
  * Make your feature addition or bug fix.
57
- * Add tests for it. This is important so I don't break it in a future version unintentionally.
94
+ * Add tests for it. This is important so we dont break it in a future version unintentionally.
58
95
  * Commit, do not mess with rakefile, version, or history.
59
- * Send me a pull request. Bonus points for topic branches.
96
+ * Send a pull request. Bonus points for topic branches.
97
+
98
+ == Authors & Contributors
99
+
100
+ * Petyo Ivanov
101
+ * Ilya Sabanin
102
+ * Hristo Deshev
103
+ * Randy Schmidt
60
104
 
61
105
  == Copyright
62
106
 
63
- Copyright (c) 2009 Wildbit LLC. See LICENSE for details.
107
+ Copyright © 2010 Wildbit LLC. See LICENSE for details.
data/Rakefile CHANGED
@@ -7,11 +7,9 @@ begin
7
7
  gem.name = "postmark-rails"
8
8
  gem.summary = %Q{Postmark adapter for ActionMailer}
9
9
  gem.description = %Q{Use this plugin in your rails applications to send emails through the Postmark API}
10
- gem.email = "underlog@gmail.com"
10
+ gem.email = "ilya@wildbit.com"
11
11
  gem.homepage = "http://postmarkapp.com"
12
- gem.authors = ["Petyo Ivanov"]
13
- gem.add_development_dependency "rspec"
14
- gem.add_dependency 'postmark'
12
+ gem.authors = ["Petyo Ivanov", "Ilya Sabanin"]
15
13
 
16
14
  gem.post_install_message = %q[
17
15
  ==================
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -1,36 +1,26 @@
1
- require 'postmark'
2
1
  require 'action_mailer'
2
+ require 'postmark'
3
+ require 'postmark_delivery_method'
3
4
 
4
- module PostmarkMethods
5
- def perform_delivery_postmark(message)
6
- Postmark.send_through_postmark(message)
7
- end
8
-
9
- def tag(value)
10
- @tag = value
11
- end
12
-
13
- def self.included(base)
14
- base.extend(ClassMethods)
15
- base.class_eval do
16
- alias_method_chain :create_mail, :tag
5
+ module PostmarkInstaller
6
+ extend self
7
+
8
+ def auto_detect_and_install
9
+ if ActionMailer::Base.respond_to?(:add_delivery_method)
10
+ install_in_rails_3
11
+ else
12
+ install_in_rails_2
17
13
  end
18
14
  end
19
-
20
- def create_mail_with_tag
21
- returning create_mail_without_tag do |mail|
22
- mail.tag = @tag if @tag
23
- end
15
+
16
+ def install_in_rails_2
17
+ ActionMailer::Base.send(:include, PostmarkDeliveryMethod)
24
18
  end
25
-
26
- module ClassMethods
27
- def postmark_api_key=(value)
28
- Postmark.api_key = value
29
- end
19
+
20
+ def install_in_rails_3
21
+ ActionMailer::Base.add_delivery_method :postmark, Mail::Postmark, :api_key => nil
30
22
  end
31
-
23
+
32
24
  end
33
25
 
34
- class ActionMailer::Base
35
- include PostmarkMethods
36
- end
26
+ PostmarkInstaller.auto_detect_and_install
@@ -0,0 +1,36 @@
1
+ #
2
+ # This module is only used for Rails 2.
3
+ #
4
+ module PostmarkDeliveryMethod
5
+
6
+ module ClassMethods
7
+
8
+ def postmark_api_key=(value)
9
+ Postmark.api_key = value
10
+ end
11
+
12
+ end
13
+
14
+ def self.included(base)
15
+ base.extend(ClassMethods)
16
+
17
+ base.class_eval do
18
+ alias_method_chain :create_mail, :tag
19
+ end
20
+ end
21
+
22
+ def perform_delivery_postmark(message)
23
+ Postmark.send_through_postmark(message)
24
+ end
25
+
26
+ def tag(value)
27
+ @tag = value
28
+ end
29
+
30
+ def create_mail_with_tag
31
+ returning create_mail_without_tag do |mail|
32
+ mail.tag = @tag if @tag
33
+ end
34
+ end
35
+
36
+ end
@@ -5,13 +5,13 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{postmark-rails}
8
- s.version = "0.2.0"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Petyo Ivanov"]
12
- s.date = %q{2010-03-23}
11
+ s.authors = ["Petyo Ivanov", "Ilya Sabanin"]
12
+ s.date = %q{2010-09-16}
13
13
  s.description = %q{Use this plugin in your rails applications to send emails through the Postmark API}
14
- s.email = %q{underlog@gmail.com}
14
+ s.email = %q{ilya@wildbit.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
17
  "README.rdoc"
@@ -19,15 +19,19 @@ Gem::Specification.new do |s|
19
19
  s.files = [
20
20
  ".document",
21
21
  ".gitignore",
22
+ "CHANGELOG.rdoc",
23
+ "Gemfile",
24
+ "Gemfile.lock",
22
25
  "LICENSE",
23
26
  "README.rdoc",
24
27
  "Rakefile",
25
28
  "VERSION",
26
29
  "lib/postmark-rails.rb",
30
+ "lib/postmark_delivery_method.rb",
27
31
  "postmark-rails.gemspec",
28
32
  "spec/fixtures/models/test_mailer.rb",
29
- "spec/fixtures/views/test_mailer/multipart_message.text.html.erb",
30
- "spec/fixtures/views/test_mailer/multipart_message.text.plain.erb",
33
+ "spec/fixtures/views/test_mailer/multipart_message.html.erb",
34
+ "spec/fixtures/views/test_mailer/multipart_message.text.erb",
31
35
  "spec/fixtures/views/test_mailer/simple_message.erb",
32
36
  "spec/fixtures/views/test_mailer/tagged_message.erb",
33
37
  "spec/postmark-rails_spec.rb",
@@ -56,15 +60,9 @@ Gem::Specification.new do |s|
56
60
  s.specification_version = 3
57
61
 
58
62
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
59
- s.add_development_dependency(%q<rspec>, [">= 0"])
60
- s.add_runtime_dependency(%q<postmark>, [">= 0"])
61
63
  else
62
- s.add_dependency(%q<rspec>, [">= 0"])
63
- s.add_dependency(%q<postmark>, [">= 0"])
64
64
  end
65
65
  else
66
- s.add_dependency(%q<rspec>, [">= 0"])
67
- s.add_dependency(%q<postmark>, [">= 0"])
68
66
  end
69
67
  end
70
68
 
@@ -1,22 +1,20 @@
1
1
  class TestMailer < ActionMailer::Base
2
-
2
+ default :subject => 'hello',
3
+ :to => 'sheldon@bigbangtheory.com',
4
+ :from => 'leonard@bigbangtheory.com'
5
+
3
6
  def simple_message
4
- subject 'hello'
5
- recipients 'sheldon@bigbangtheory.com'
6
- from 'leonard@bigbangtheory.com'
7
- end
8
-
9
- def multipart_message
10
- subject 'hello'
11
- recipients 'sheldon@bigbangtheory.com'
12
- from 'leonard@bigbangtheory.com'
7
+ mail
13
8
  end
14
9
 
15
10
  def tagged_message
16
- subject 'hello'
17
- recipients 'sheldon@bigbangtheory.com'
18
- from 'leonard@bigbangtheory.com'
19
- tag 'delivery'
11
+ mail(:tag => 'delivery')
20
12
  end
21
13
 
22
- end
14
+ def multipart_message
15
+ mail(:subject => "Your invitation to join Mixlr.") do |format|
16
+ format.text
17
+ format.html
18
+ end
19
+ end
20
+ end
@@ -1,19 +1,34 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe "PostmarkRails" do
4
-
3
+ describe "PostmarkRails3" do
4
+ it "should allow setting an api key" do
5
+ Postmark.stub!(:send_through_postmark)
6
+ ActionMailer::Base.postmark_settings = {:api_key => 'api-key'}
7
+ ActionMailer::Base.postmark_settings[:api_key].should == 'api-key'
8
+ Postmark.should_receive(:api_key=).with('api-key')
9
+ TestMailer.simple_message.deliver
10
+ end
11
+
5
12
  it "should use postmark for delivery" do
6
13
  Postmark.should_receive(:send_through_postmark) do |message|
7
14
  message.subject.should == "hello"
8
15
  end
9
- TestMailer.deliver_simple_message
16
+ TestMailer.simple_message.deliver
10
17
  end
11
18
 
12
19
  it "should allow tagging of message" do
13
20
  Postmark.should_receive(:send_through_postmark) do |message|
14
21
  message.tag.to_s.should == "delivery"
15
22
  end
16
- TestMailer.deliver_tagged_message
23
+ TestMailer.tagged_message.deliver
17
24
  end
18
-
19
- end
25
+
26
+ it "should work with multipart messages" do
27
+ Postmark.should_receive(:send_through_postmark) do |message|
28
+ message.should be_multipart
29
+ message.body_text.strip.should == "hello"
30
+ message.body_html.strip.should == "<b>hello</b>"
31
+ end
32
+ TestMailer.multipart_message.deliver
33
+ end
34
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,18 +1,13 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
3
4
  require 'rubygems'
4
- require 'ruby-debug'
5
- require 'actionmailer'
6
- require 'postmark-rails'
5
+ require 'postmark'
6
+ require 'lib/postmark-rails'
7
7
  require 'spec'
8
8
  require 'spec/autorun'
9
9
 
10
10
  ActionMailer::Base.delivery_method = :postmark
11
- ActionMailer::Base.template_root = File.join(File.dirname(__FILE__), "fixtures", "views")
12
-
13
- # require models
14
- Dir["#{File.dirname(__FILE__)}/fixtures/models/*.rb"].each { |f| require f }
11
+ ActionMailer::Base.prepend_view_path(File.join(File.dirname(__FILE__), "fixtures", "views"))
15
12
 
16
- Spec::Runner.configure do |config|
17
-
18
- end
13
+ Dir["#{File.dirname(__FILE__)}/fixtures/models/*.rb"].each { |f| require f }
metadata CHANGED
@@ -4,45 +4,23 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
7
+ - 3
8
8
  - 0
9
- version: 0.2.0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Petyo Ivanov
13
+ - Ilya Sabanin
13
14
  autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-03-23 00:00:00 +02:00
18
+ date: 2010-09-16 00:00:00 +02:00
18
19
  default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: rspec
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
- version: "0"
30
- type: :development
31
- version_requirements: *id001
32
- - !ruby/object:Gem::Dependency
33
- name: postmark
34
- prerelease: false
35
- requirement: &id002 !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- segments:
40
- - 0
41
- version: "0"
42
- type: :runtime
43
- version_requirements: *id002
20
+ dependencies: []
21
+
44
22
  description: Use this plugin in your rails applications to send emails through the Postmark API
45
- email: underlog@gmail.com
23
+ email: ilya@wildbit.com
46
24
  executables: []
47
25
 
48
26
  extensions: []
@@ -53,15 +31,19 @@ extra_rdoc_files:
53
31
  files:
54
32
  - .document
55
33
  - .gitignore
34
+ - CHANGELOG.rdoc
35
+ - Gemfile
36
+ - Gemfile.lock
56
37
  - LICENSE
57
38
  - README.rdoc
58
39
  - Rakefile
59
40
  - VERSION
60
41
  - lib/postmark-rails.rb
42
+ - lib/postmark_delivery_method.rb
61
43
  - postmark-rails.gemspec
62
44
  - spec/fixtures/models/test_mailer.rb
63
- - spec/fixtures/views/test_mailer/multipart_message.text.html.erb
64
- - spec/fixtures/views/test_mailer/multipart_message.text.plain.erb
45
+ - spec/fixtures/views/test_mailer/multipart_message.html.erb
46
+ - spec/fixtures/views/test_mailer/multipart_message.text.erb
65
47
  - spec/fixtures/views/test_mailer/simple_message.erb
66
48
  - spec/fixtures/views/test_mailer/tagged_message.erb
67
49
  - spec/postmark-rails_spec.rb