fishman-postmark-rails 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,7 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ .rake_tasks
7
+ .bundle
@@ -0,0 +1,13 @@
1
+ = Changelog
2
+
3
+ == 0.4.1
4
+
5
+ * Fixed "returning" deprecation warning.
6
+
7
+ == 0.4.0
8
+
9
+ * Attachments support.
10
+
11
+ == 0.3.0
12
+
13
+ * Added support for Rails 3.
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem "ruby-debug", :platforms => [:ruby_18]
7
+ gem "ruby-debug19", :platforms => [:ruby_19]
8
+ gem "rspec"
9
+ gem "jeweler"
10
+ end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Petyo Ivanov
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,151 @@
1
+ = postmark-rails gem
2
+
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
+
5
+ == Supported Rails Versions
6
+
7
+ * lower than 2.3: could work, but not tested
8
+ * 2.3 and higher
9
+ * 3.0
10
+
11
+ == Install
12
+
13
+ sudo gem install postmark-rails
14
+
15
+ == Requirements
16
+
17
+ * "postmark" gem version 0.8 and higher is required.
18
+ * 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.
19
+
20
+ == Configuring your Rails application
21
+
22
+ === Rails 3
23
+
24
+ Add this to your Gemfile: (change version numbers if needed)
25
+
26
+ gem 'postmark-rails', '0.4.0'
27
+
28
+ Don't forget to run "bundle install" command every time you change something in the Gemfile.
29
+
30
+ Add this to your config/application.rb:
31
+
32
+ config.action_mailer.delivery_method = :postmark
33
+ config.action_mailer.postmark_settings = { :api_key => "your-api-key" }
34
+
35
+ === Rails 2
36
+
37
+ Add this to config/environment.rb:
38
+
39
+ Rails::Initializer.run do |config|
40
+
41
+ ...
42
+
43
+ config.gem 'postmark-rails'
44
+ require 'postmark-rails'
45
+
46
+ config.action_mailer.postmark_api_key = "your-api-key"
47
+ config.action_mailer.delivery_method = :postmark
48
+
49
+ ...
50
+
51
+ end
52
+
53
+ For API details, refer to the developer documentation at http://developer.postmarkapp.com.
54
+
55
+ == Tagging your deliveries
56
+
57
+ 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.
58
+
59
+ === Rails 3
60
+
61
+ class TestMailer < ActionMailer::Base
62
+
63
+ def tagged_message
64
+ mail(
65
+ :subject => 'hello',
66
+ :to => 'sheldon@bigbangtheory.com',
67
+ :from => 'leonard@bigbangtheory.com',
68
+ :tag => 'my-tag'
69
+ )
70
+ end
71
+
72
+ end
73
+
74
+ === Rails 2
75
+
76
+ class SuperMailer < ActionMailer::Base
77
+
78
+ def email
79
+ from "no-reply@example.com"
80
+ subject "Some marvelous email message"
81
+ recipients "someone-fancy@example.com"
82
+ tag "my-another-tag"
83
+ end
84
+
85
+ end
86
+
87
+ == Sending attachments
88
+
89
+ You can also send file attachments with Postmark. Read more here: http://developer.postmarkapp.com/developer-build.html#attachments
90
+
91
+ === Rails 3
92
+
93
+ class TestMailer < ActionMailer::Base
94
+
95
+ def message_with_attachment
96
+ mail(
97
+ :subject => 'hello',
98
+ :to => 'sheldon@bigbangtheory.com',
99
+ :from => 'leonard@bigbangtheory.com',
100
+ :postmark_attachments => [File.open("/path/to/file")]
101
+ )
102
+ end
103
+
104
+ end
105
+
106
+ === Rails 2
107
+
108
+ class SuperMailer < ActionMailer::Base
109
+
110
+ def email
111
+ from "no-reply@example.com"
112
+ subject "Some marvelous email message"
113
+ recipients "someone-fancy@example.com"
114
+ postmark_attachments [File.open("/path/to/file")]
115
+ end
116
+
117
+ end
118
+
119
+ You can pass either an array of File objects or a single object. Postmark will detect the file name automatically and send an attachment with the "application/octet-stream" content type. If you want more control on how attachments get formatted, you can pass Hash objects, which contain the custom settings such as file name or content-type. Here is an example:
120
+
121
+ #
122
+ # Don't forget to read your file and base64-encode it,
123
+ # before assigning it to "Content".
124
+ #
125
+ message.postmark_attachments = {
126
+ "Name" => "fancy-file-name.jpg",
127
+ "Content" => [ IO.read("path/to/file") ].pack("m"),
128
+ "ContentType" => "image/jpeg"
129
+ }
130
+
131
+ == Note on Patches/Pull Requests
132
+
133
+ * Fork the project.
134
+ * Make your feature addition or bug fix.
135
+ * Add tests for it. This is important so we don’t break it in a future version unintentionally.
136
+ * Commit, do not mess with rakefile, version, or history.
137
+ * Send a pull request. Bonus points for topic branches.
138
+
139
+ == Authors & Contributors
140
+
141
+ * Petyo Ivanov
142
+ * Ilya Sabanin
143
+ * Hristo Deshev
144
+ * Randy Schmidt
145
+ * Chris Williams
146
+ * Nicolás Sanguinetti
147
+ * Laust Rud Jacobsen (rud)
148
+
149
+ == Copyright
150
+
151
+ Copyright © 2010 Wildbit LLC. See LICENSE for details.
@@ -0,0 +1,59 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "postmark-rails"
8
+ gem.summary = %Q{Postmark adapter for ActionMailer}
9
+ gem.description = %Q{Use this plugin in your rails applications to send emails through the Postmark API}
10
+ gem.email = "ilya@wildbit.com"
11
+ gem.homepage = "http://postmarkapp.com"
12
+ gem.authors = ["Petyo Ivanov", "Ilya Sabanin"]
13
+
14
+ gem.add_dependency "actionmailer"
15
+ gem.add_dependency "postmark", ">= 0.9.0"
16
+ gem.add_dependency "rake"
17
+
18
+ gem.post_install_message = %q[
19
+ ==================
20
+ Thanks for installing the postmark-rails gem. If you don't have an account, please sign up at http://postmarkapp.com/.
21
+ Review the README.rdoc for implementation details and examples.
22
+ ==================
23
+ ]
24
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
25
+ end
26
+ Jeweler::GemcutterTasks.new
27
+ rescue LoadError
28
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
29
+ end
30
+
31
+ require 'spec/rake/spectask'
32
+ Spec::Rake::SpecTask.new(:spec) do |spec|
33
+ spec.libs << 'lib' << 'spec'
34
+ spec.spec_files = FileList['spec/**/*_spec.rb']
35
+ end
36
+
37
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
38
+ spec.libs << 'lib' << 'spec'
39
+ spec.pattern = 'spec/**/*_spec.rb'
40
+ spec.rcov = true
41
+ end
42
+
43
+ task :spec => :check_dependencies
44
+
45
+ task :default => :spec
46
+
47
+ require 'rake/rdoctask'
48
+ Rake::RDocTask.new do |rdoc|
49
+ if File.exist?('VERSION')
50
+ version = File.read('VERSION')
51
+ else
52
+ version = ""
53
+ end
54
+
55
+ rdoc.rdoc_dir = 'rdoc'
56
+ rdoc.title = "postmark-rails #{version}"
57
+ rdoc.rdoc_files.include('README*')
58
+ rdoc.rdoc_files.include('lib/**/*.rb')
59
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.4.1
@@ -0,0 +1,27 @@
1
+ require 'action_mailer'
2
+ require 'postmark'
3
+ require 'postmark_delivery_method'
4
+
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
13
+ end
14
+ end
15
+
16
+ def install_in_rails_2
17
+ ActionMailer::Base.send(:include, PostmarkDeliveryMethod)
18
+ end
19
+
20
+ def install_in_rails_3
21
+ ActionMailer::Base.add_delivery_method :postmark, Mail::Postmark, :api_key => nil
22
+ Mail::Message.send(:include, Postmark::AttachmentsFixForMail)
23
+ end
24
+
25
+ end
26
+
27
+ PostmarkInstaller.auto_detect_and_install
@@ -0,0 +1,41 @@
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, :postmark_extras
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 postmark_attachments(value)
31
+ @attachments = value
32
+ end
33
+
34
+ def create_mail_with_postmark_extras
35
+ create_mail_without_postmark_extras.tap do |mail|
36
+ mail.tag = @tag if @tag
37
+ mail.postmark_attachments = @attachments if @attachments
38
+ end
39
+ end
40
+
41
+ end
@@ -0,0 +1,76 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{fishman-postmark-rails}
8
+ s.version = "0.4.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Petyo Ivanov", "Ilya Sabanin"]
12
+ s.date = %q{2010-11-22}
13
+ s.description = %q{Use this plugin in your rails applications to send emails through the Postmark API}
14
+ s.email = %q{ilya@wildbit.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "CHANGELOG.rdoc",
23
+ "Gemfile",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/postmark-rails.rb",
29
+ "lib/postmark_delivery_method.rb",
30
+ "postmark-rails.gemspec",
31
+ "spec/fixtures/models/test_mailer.rb",
32
+ "spec/fixtures/views/test_mailer/multipart_message.html.erb",
33
+ "spec/fixtures/views/test_mailer/multipart_message.text.erb",
34
+ "spec/fixtures/views/test_mailer/simple_message.erb",
35
+ "spec/fixtures/views/test_mailer/tagged_message.erb",
36
+ "spec/postmark-rails_spec.rb",
37
+ "spec/spec.opts",
38
+ "spec/spec_helper.rb"
39
+ ]
40
+ s.homepage = %q{http://postmarkapp.com}
41
+ s.post_install_message = %q{
42
+ ==================
43
+ Thanks for installing the postmark-rails gem. If you don't have an account, please sign up at http://postmarkapp.com/.
44
+ Review the README.rdoc for implementation details and examples.
45
+ ==================
46
+ }
47
+ s.rdoc_options = ["--charset=UTF-8"]
48
+ s.require_paths = ["lib"]
49
+ s.rubygems_version = %q{1.3.7}
50
+ s.summary = %q{Postmark adapter for ActionMailer}
51
+ s.test_files = [
52
+ "spec/fixtures/models/test_mailer.rb",
53
+ "spec/postmark-rails_spec.rb",
54
+ "spec/spec_helper.rb"
55
+ ]
56
+
57
+ if s.respond_to? :specification_version then
58
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
59
+ s.specification_version = 3
60
+
61
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
62
+ s.add_runtime_dependency(%q<actionmailer>, [">= 0"])
63
+ s.add_runtime_dependency(%q<postmark>, [">= 0.9.0"])
64
+ s.add_runtime_dependency(%q<rake>, [">= 0"])
65
+ else
66
+ s.add_dependency(%q<actionmailer>, [">= 0"])
67
+ s.add_dependency(%q<postmark>, [">= 0.9.0"])
68
+ s.add_dependency(%q<rake>, [">= 0"])
69
+ end
70
+ else
71
+ s.add_dependency(%q<actionmailer>, [">= 0"])
72
+ s.add_dependency(%q<postmark>, [">= 0.9.0"])
73
+ s.add_dependency(%q<rake>, [">= 0"])
74
+ end
75
+ end
76
+
@@ -0,0 +1,20 @@
1
+ class TestMailer < ActionMailer::Base
2
+ default :subject => 'hello',
3
+ :to => 'sheldon@bigbangtheory.com',
4
+ :from => 'leonard@bigbangtheory.com'
5
+
6
+ def simple_message
7
+ mail
8
+ end
9
+
10
+ def tagged_message
11
+ mail(:tag => 'delivery')
12
+ end
13
+
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
@@ -0,0 +1,34 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
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
+
12
+ it "should use postmark for delivery" do
13
+ Postmark.should_receive(:send_through_postmark) do |message|
14
+ message.subject.should == "hello"
15
+ end
16
+ TestMailer.simple_message.deliver
17
+ end
18
+
19
+ it "should allow tagging of message" do
20
+ Postmark.should_receive(:send_through_postmark) do |message|
21
+ message.tag.to_s.should == "delivery"
22
+ end
23
+ TestMailer.tagged_message.deliver
24
+ 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
@@ -0,0 +1,3 @@
1
+ --colour
2
+ --format specdoc
3
+ --loadby mtime
@@ -0,0 +1,13 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
4
+ require 'rubygems'
5
+ require 'postmark'
6
+ require 'postmark-rails'
7
+ require 'spec'
8
+ require 'spec/autorun'
9
+
10
+ ActionMailer::Base.delivery_method = :postmark
11
+ ActionMailer::Base.prepend_view_path(File.join(File.dirname(__FILE__), "fixtures", "views"))
12
+
13
+ Dir["#{File.dirname(__FILE__)}/fixtures/models/*.rb"].each { |f| require f }
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fishman-postmark-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Petyo Ivanov
9
+ - Ilya Sabanin
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2010-11-22 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: actionmailer
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: postmark
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: 0.9.0
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: 0.9.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ description: Use this plugin in your rails applications to send emails through the
64
+ Postmark API
65
+ email: ilya@wildbit.com
66
+ executables: []
67
+ extensions: []
68
+ extra_rdoc_files:
69
+ - LICENSE
70
+ - README.rdoc
71
+ files:
72
+ - .document
73
+ - .gitignore
74
+ - CHANGELOG.rdoc
75
+ - Gemfile
76
+ - LICENSE
77
+ - README.rdoc
78
+ - Rakefile
79
+ - VERSION
80
+ - lib/postmark-rails.rb
81
+ - lib/postmark_delivery_method.rb
82
+ - postmark-rails.gemspec
83
+ - spec/fixtures/models/test_mailer.rb
84
+ - spec/fixtures/views/test_mailer/multipart_message.html.erb
85
+ - spec/fixtures/views/test_mailer/multipart_message.text.erb
86
+ - spec/fixtures/views/test_mailer/simple_message.erb
87
+ - spec/fixtures/views/test_mailer/tagged_message.erb
88
+ - spec/postmark-rails_spec.rb
89
+ - spec/spec.opts
90
+ - spec/spec_helper.rb
91
+ homepage: http://postmarkapp.com
92
+ licenses: []
93
+ post_install_message: ! "\n ==================\n Thanks for installing the
94
+ postmark-rails gem. If you don't have an account, please sign up at http://postmarkapp.com/.\n
95
+ \ Review the README.rdoc for implementation details and examples.\n ==================\n
96
+ \ "
97
+ rdoc_options:
98
+ - --charset=UTF-8
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ! '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ! '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 1.8.21
116
+ signing_key:
117
+ specification_version: 3
118
+ summary: Postmark adapter for ActionMailer
119
+ test_files:
120
+ - spec/fixtures/models/test_mailer.rb
121
+ - spec/postmark-rails_spec.rb
122
+ - spec/spec_helper.rb