simple_postmark 0.5.1 → 0.5.2
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.
- data/.travis.yml +1 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +2 -2
- data/README.md +14 -7
- data/Rakefile +2 -3
- data/gemfiles/Rails_3_0.gemfile +2 -2
- data/gemfiles/Rails_3_1.gemfile +2 -2
- data/gemfiles/Rails_3_2.gemfile +2 -2
- data/gemfiles/Rails_master.gemfile +1 -2
- data/lib/simple_postmark.rb +2 -3
- data/lib/simple_postmark/api_error.rb +1 -1
- data/lib/simple_postmark/delivery_method.rb +6 -9
- data/lib/simple_postmark/mail_ext/part.rb +1 -1
- data/lib/simple_postmark/railtie.rb +3 -3
- data/lib/simple_postmark/version.rb +1 -1
- data/simple_postmark.gemspec +6 -5
- data/spec/delivery_method_spec.rb +5 -8
- data/spec/integration_spec.rb +1 -1
- data/spec/mail_ext/message_spec.rb +1 -1
- data/spec/mail_ext/part_spec.rb +1 -1
- data/spec/railtie_spec.rb +12 -12
- data/spec/spec_helper.rb +3 -1
- metadata +27 -27
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 0.5.2 (May 11, 2013)
|
2
|
+
* Some refactoring.
|
3
|
+
* Ruby 2.0 support!
|
4
|
+
* Rails 4.pre support! Thank you @frodsan! :)
|
5
|
+
* Updated README.md: simple_postmark will die… someday! :(
|
6
|
+
* Fixed some problems: #8 and #10.
|
7
|
+
|
1
8
|
## 0.5.1 (December 21, 2012)
|
2
9
|
|
3
10
|
* Prepared for gem-release.
|
data/Gemfile
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gemspec
|
3
|
+
gemspec
|
data/README.md
CHANGED
@@ -1,12 +1,19 @@
|
|
1
|
-
# simple_postmark
|
1
|
+
# simple_postmark [](https://travis-ci.org/haihappen/simple_postmark)
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
simple_postmark makes it easy to send mails via [Postmark](http://postmarkapp.com)™ using Rails's ActionMailer.
|
4
|
+
|
5
|
+
~~simple_postmark is inspired by [postmark-gem](https://github.com/wildbit/postmark-gem), but unfortunately postmark-gem forced to me to use non-standard Rails calls like `postmark_attachments`. simple_postmark uses the standard Rails's ActionMailer syntax to send your emails via Postmark.~~
|
6
|
+
|
7
|
+
---
|
8
|
+
|
9
|
+
**Update:** It seems that the [issue](https://github.com/wildbit/postmark-rails/issues/17#issuecomment-13761405) was fixed in the `0.9.19` version of the [postmark gem](https://github.com/wildbit/postmark-gem), which marks this gem as obligatory. However I have not decided what to do, so simple_postmark will still be there for a while. At least until Rails `4.0` is released.
|
10
|
+
|
11
|
+
---
|
5
12
|
|
6
13
|
Tested against Ruby versions `1.9.2`, `1.9.3` and Rails versions `3.0.x`, `3.1.x`, `3.2.x`.
|
7
|
-
`ruby-head
|
14
|
+
`ruby-head`, `2.0` and Rails `master` should work too btw.
|
8
15
|
|
9
|
-
If you are still using Ruby `1.8.7` or `Ruby Enterprise Edition` with Rails
|
16
|
+
If you are still using Ruby `1.8.7` or `Ruby Enterprise Edition` with Rails, you can use the backported version of this gem called [simple_postmark18](https://github.com/haihappen/simple_postmark/tree/ruby18).
|
10
17
|
|
11
18
|
## Installation
|
12
19
|
|
@@ -27,7 +34,7 @@ config.action_mailer.simple_postmark_settings = { api_key: '********-****-****-*
|
|
27
34
|
|
28
35
|
## Usage
|
29
36
|
|
30
|
-
Just use your standard Rails
|
37
|
+
Just use your standard Rails Mailer:
|
31
38
|
|
32
39
|
```ruby
|
33
40
|
class NotificationMailer < ActionMailer::Base
|
@@ -101,7 +108,7 @@ With this setup, it will actually trigger a connection to the Postmark API, but
|
|
101
108
|
|
102
109
|
(The MIT license)
|
103
110
|
|
104
|
-
Copyright (c) 2011-
|
111
|
+
Copyright (c) 2011-2013 Mario Uher
|
105
112
|
|
106
113
|
Permission is hereby granted, free of charge, to any person obtaining
|
107
114
|
a copy of this software and associated documentation files (the
|
data/Rakefile
CHANGED
data/gemfiles/Rails_3_0.gemfile
CHANGED
data/gemfiles/Rails_3_1.gemfile
CHANGED
data/gemfiles/Rails_3_2.gemfile
CHANGED
data/lib/simple_postmark.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
require 'active_support/core_ext
|
2
|
-
require 'active_support/inflector/methods'
|
1
|
+
require 'active_support/core_ext'
|
3
2
|
require 'httparty'
|
4
3
|
require 'json'
|
5
4
|
require 'mail'
|
@@ -12,4 +11,4 @@ module SimplePostmark
|
|
12
11
|
require 'simple_postmark/api_error'
|
13
12
|
|
14
13
|
require 'simple_postmark/railtie' if defined?(Rails)
|
15
|
-
end
|
14
|
+
end
|
@@ -1,19 +1,16 @@
|
|
1
1
|
module Mail
|
2
|
-
class SimplePostmark
|
2
|
+
class SimplePostmark < Struct.new(:settings)
|
3
3
|
include HTTParty
|
4
4
|
|
5
|
-
def initialize(values)
|
6
|
-
self.settings = { api_key: '********-****-****-****-************' }.merge(values)
|
7
|
-
end
|
8
|
-
|
9
|
-
attr_accessor :settings
|
10
5
|
base_uri 'http://api.postmarkapp.com'
|
11
6
|
headers 'Accept' => 'application/json', 'ContentType' => 'application/json'
|
7
|
+
delegate :post, :headers, to: self
|
12
8
|
|
13
9
|
def deliver!(mail)
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
headers = self.headers.merge('X-Postmark-Server-Token' => settings[:api_key].to_s)
|
11
|
+
body = mail.to_postmark.to_json
|
12
|
+
|
13
|
+
response = post('/email', headers: headers, body: body)
|
17
14
|
raise ::SimplePostmark::APIError.new(response) unless response.success?
|
18
15
|
response
|
19
16
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module SimplePostmark
|
2
|
-
class Railtie <
|
3
|
-
ActionMailer::Base.add_delivery_method
|
2
|
+
class Railtie < Rails::Railtie
|
3
|
+
ActionMailer::Base.add_delivery_method :simple_postmark, Mail::SimplePostmark, api_key: nil
|
4
4
|
end
|
5
|
-
end
|
5
|
+
end
|
data/simple_postmark.gemspec
CHANGED
@@ -1,23 +1,24 @@
|
|
1
|
-
|
1
|
+
$: << File.expand_path('../lib', __FILE__)
|
2
|
+
require 'simple_postmark/version'
|
2
3
|
|
3
4
|
Gem::Specification.new do |gem|
|
4
5
|
gem.name = 'simple_postmark'
|
5
6
|
gem.version = SimplePostmark::VERSION
|
6
7
|
gem.authors = 'Mario Uher'
|
7
8
|
gem.email = 'uher.mario@gmail.com'
|
8
|
-
gem.description = 'SimplePostmark makes it easy to send mails via Postmark™ using Rails
|
9
|
+
gem.description = 'SimplePostmark makes it easy to send mails via Postmark™ using Rails\'s ActionMailer.'
|
9
10
|
gem.summary = 'A simple way to use Postmark™ with your Rails app.'
|
10
11
|
gem.homepage = 'http://haihappen.github.com/simple_postmark'
|
11
12
|
|
12
13
|
gem.files = `git ls-files`.split("\n")
|
13
14
|
gem.require_path = 'lib'
|
14
15
|
|
15
|
-
gem.add_dependency 'activesupport', '
|
16
|
+
gem.add_dependency 'activesupport', '>= 3.0'
|
16
17
|
gem.add_dependency 'httparty'
|
17
18
|
gem.add_dependency 'json'
|
18
19
|
gem.add_dependency 'mail'
|
19
20
|
|
20
|
-
gem.add_development_dependency 'minitest'
|
21
|
-
gem.add_development_dependency 'rails', '
|
21
|
+
gem.add_development_dependency 'minitest', '~> 4.0'
|
22
|
+
gem.add_development_dependency 'rails', '>= 3.0'
|
22
23
|
gem.add_development_dependency 'webmock'
|
23
24
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
|
1
|
+
require_relative 'spec_helper'
|
2
2
|
|
3
3
|
describe Mail do
|
4
4
|
describe SimplePostmark do
|
5
|
-
let(:instance) { Mail::SimplePostmark.new
|
5
|
+
let(:instance) { Mail::SimplePostmark.new }
|
6
6
|
|
7
7
|
|
8
8
|
it 'responds to deliver!' do
|
@@ -27,21 +27,18 @@ describe Mail do
|
|
27
27
|
before do
|
28
28
|
mail.delivery_method(Mail::SimplePostmark)
|
29
29
|
stub_request(:post, url)
|
30
|
+
mail.deliver
|
30
31
|
end
|
31
32
|
|
32
33
|
|
33
34
|
it 'sends emails' do
|
34
|
-
mail.deliver
|
35
|
-
|
36
35
|
assert_requested(:post, url)
|
37
36
|
end
|
38
37
|
|
39
38
|
|
40
39
|
it 'sends appropriate headers' do
|
41
|
-
|
42
|
-
|
43
|
-
assert_requested(:post, url, headers: { 'Accept' => 'application/json', 'ContentType' => 'application/json', 'X-Postmark-Server-Token' => '********-****-****-****-************' })
|
40
|
+
assert_requested(:post, url, headers: { 'Accept' => 'application/json', 'ContentType' => 'application/json', 'X-Postmark-Server-Token' => '' })
|
44
41
|
end
|
45
42
|
end
|
46
43
|
end
|
47
|
-
end
|
44
|
+
end
|
data/spec/integration_spec.rb
CHANGED
data/spec/mail_ext/part_spec.rb
CHANGED
data/spec/railtie_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative 'spec_helper'
|
2
2
|
require 'action_mailer'
|
3
3
|
require 'rails'
|
4
4
|
require 'simple_postmark/railtie'
|
@@ -9,11 +9,11 @@ class NotificationMailer < ActionMailer::Base
|
|
9
9
|
default from: 'barney@himym.tld', to: 'ted@himym.tld'
|
10
10
|
|
11
11
|
def im_your_bro
|
12
|
-
mail(subject: "I'm your bro!")
|
12
|
+
mail(subject: "I'm your bro!", body: '')
|
13
13
|
end
|
14
14
|
|
15
15
|
def im_your_bro_tagged
|
16
|
-
mail(subject: "I'm your bro!", tag: 'simple-postmark')
|
16
|
+
mail(subject: "I'm your bro!", tag: 'simple-postmark', body: '')
|
17
17
|
end
|
18
18
|
|
19
19
|
def im_your_bro_multipart
|
@@ -25,7 +25,7 @@ class NotificationMailer < ActionMailer::Base
|
|
25
25
|
|
26
26
|
def the_bro_code
|
27
27
|
attachments['thebrocode.jpg'] = File.read(File.join(File.dirname(__FILE__), 'thebrocode.jpg'))
|
28
|
-
mail(subject: 'The Brocode!')
|
28
|
+
mail(subject: 'The Brocode!', body: '')
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -66,7 +66,7 @@ describe ActionMailer::Base do
|
|
66
66
|
|
67
67
|
it 'allows setting an api key' do
|
68
68
|
ActionMailer::Base.simple_postmark_settings = { api_key: api_key }
|
69
|
-
|
69
|
+
|
70
70
|
ActionMailer::Base.simple_postmark_settings[:api_key].must_equal(api_key)
|
71
71
|
end
|
72
72
|
|
@@ -79,14 +79,14 @@ describe ActionMailer::Base do
|
|
79
79
|
|
80
80
|
it 'works' do
|
81
81
|
NotificationMailer.im_your_bro.deliver
|
82
|
-
|
82
|
+
|
83
83
|
assert_requested(:post, url, headers: headers, body: merge_body)
|
84
84
|
end
|
85
85
|
|
86
86
|
|
87
87
|
it 'allows tags' do
|
88
88
|
NotificationMailer.im_your_bro_tagged.deliver
|
89
|
-
|
89
|
+
|
90
90
|
assert_requested(:post, url, headers: headers, body: merge_body('Tag' => 'simple-postmark'))
|
91
91
|
end
|
92
92
|
|
@@ -97,9 +97,9 @@ describe ActionMailer::Base do
|
|
97
97
|
'ContentType' => 'image/jpeg',
|
98
98
|
'Name' => 'thebrocode.jpg'
|
99
99
|
}
|
100
|
-
|
100
|
+
|
101
101
|
NotificationMailer.the_bro_code.deliver
|
102
|
-
|
102
|
+
|
103
103
|
assert_requested(:post, url, headers: headers, body: merge_body('Subject' => 'The Brocode!', 'Attachments' => [attachment]))
|
104
104
|
end
|
105
105
|
|
@@ -109,10 +109,10 @@ describe ActionMailer::Base do
|
|
109
109
|
'HtmlBody' => "<p>Think of me like Yoda, but instead of being little and green I wear suits and I'm awesome.<br /><br />I'm your bro-I'm Broda!</p>",
|
110
110
|
'TextBody' => "Think of me like Yoda, but instead of being little and green I wear suits and I'm awesome. I'm your bro-I'm Broda!"
|
111
111
|
}
|
112
|
-
|
112
|
+
|
113
113
|
NotificationMailer.im_your_bro_multipart.deliver
|
114
|
-
|
114
|
+
|
115
115
|
assert_requested(:post, url, headers: headers, body: merge_body(bodies))
|
116
116
|
end
|
117
117
|
end
|
118
|
-
end
|
118
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -2,41 +2,41 @@
|
|
2
2
|
name: simple_postmark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Mario Uher
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-05-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
+
prerelease: false
|
15
16
|
version_requirements: !ruby/object:Gem::Requirement
|
16
17
|
requirements:
|
17
|
-
- -
|
18
|
+
- - ! '>='
|
18
19
|
- !ruby/object:Gem::Version
|
19
20
|
version: '3.0'
|
20
21
|
none: false
|
21
|
-
name: activesupport
|
22
22
|
type: :runtime
|
23
|
-
|
23
|
+
name: activesupport
|
24
24
|
requirement: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- -
|
26
|
+
- - ! '>='
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '3.0'
|
29
29
|
none: false
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
+
prerelease: false
|
31
32
|
version_requirements: !ruby/object:Gem::Requirement
|
32
33
|
requirements:
|
33
34
|
- - ! '>='
|
34
35
|
- !ruby/object:Gem::Version
|
35
36
|
version: '0'
|
36
37
|
none: false
|
37
|
-
name: httparty
|
38
38
|
type: :runtime
|
39
|
-
|
39
|
+
name: httparty
|
40
40
|
requirement: !ruby/object:Gem::Requirement
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,15 +44,15 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
none: false
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
|
+
prerelease: false
|
47
48
|
version_requirements: !ruby/object:Gem::Requirement
|
48
49
|
requirements:
|
49
50
|
- - ! '>='
|
50
51
|
- !ruby/object:Gem::Version
|
51
52
|
version: '0'
|
52
53
|
none: false
|
53
|
-
name: json
|
54
54
|
type: :runtime
|
55
|
-
|
55
|
+
name: json
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - ! '>='
|
@@ -60,15 +60,15 @@ dependencies:
|
|
60
60
|
version: '0'
|
61
61
|
none: false
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
|
+
prerelease: false
|
63
64
|
version_requirements: !ruby/object:Gem::Requirement
|
64
65
|
requirements:
|
65
66
|
- - ! '>='
|
66
67
|
- !ruby/object:Gem::Version
|
67
68
|
version: '0'
|
68
69
|
none: false
|
69
|
-
name: mail
|
70
70
|
type: :runtime
|
71
|
-
|
71
|
+
name: mail
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,55 +76,55 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
none: false
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
|
+
prerelease: false
|
79
80
|
version_requirements: !ruby/object:Gem::Requirement
|
80
81
|
requirements:
|
81
|
-
- -
|
82
|
+
- - ~>
|
82
83
|
- !ruby/object:Gem::Version
|
83
|
-
version: '0'
|
84
|
+
version: '4.0'
|
84
85
|
none: false
|
85
|
-
name: minitest
|
86
86
|
type: :development
|
87
|
-
|
87
|
+
name: minitest
|
88
88
|
requirement: !ruby/object:Gem::Requirement
|
89
89
|
requirements:
|
90
|
-
- -
|
90
|
+
- - ~>
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
version: '0'
|
92
|
+
version: '4.0'
|
93
93
|
none: false
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
|
+
prerelease: false
|
95
96
|
version_requirements: !ruby/object:Gem::Requirement
|
96
97
|
requirements:
|
97
|
-
- -
|
98
|
+
- - ! '>='
|
98
99
|
- !ruby/object:Gem::Version
|
99
100
|
version: '3.0'
|
100
101
|
none: false
|
101
|
-
name: rails
|
102
102
|
type: :development
|
103
|
-
|
103
|
+
name: rails
|
104
104
|
requirement: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
|
-
- -
|
106
|
+
- - ! '>='
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '3.0'
|
109
109
|
none: false
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
|
+
prerelease: false
|
111
112
|
version_requirements: !ruby/object:Gem::Requirement
|
112
113
|
requirements:
|
113
114
|
- - ! '>='
|
114
115
|
- !ruby/object:Gem::Version
|
115
116
|
version: '0'
|
116
117
|
none: false
|
117
|
-
name: webmock
|
118
118
|
type: :development
|
119
|
-
|
119
|
+
name: webmock
|
120
120
|
requirement: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - ! '>='
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
none: false
|
126
|
-
description: SimplePostmark makes it easy to send mails via Postmark™ using Rails
|
127
|
-
|
126
|
+
description: SimplePostmark makes it easy to send mails via Postmark™ using Rails's
|
127
|
+
ActionMailer.
|
128
128
|
email: uher.mario@gmail.com
|
129
129
|
executables: []
|
130
130
|
extensions: []
|
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
175
|
none: false
|
176
176
|
requirements: []
|
177
177
|
rubyforge_project:
|
178
|
-
rubygems_version: 1.8.
|
178
|
+
rubygems_version: 1.8.25
|
179
179
|
signing_key:
|
180
180
|
specification_version: 3
|
181
181
|
summary: A simple way to use Postmark™ with your Rails app.
|