postmark 0.3.0 → 0.4.0
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/README.rdoc +2 -0
- data/VERSION +1 -1
- data/lib/postmark.rb +11 -1
- data/postmark.gemspec +5 -5
- data/spec/postmark_spec.rb +19 -1
- data/spec/spec_helper.rb +1 -0
- metadata +2 -2
data/README.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/lib/postmark.rb
CHANGED
@@ -111,7 +111,7 @@ module Postmark
|
|
111
111
|
end
|
112
112
|
|
113
113
|
def convert_tmail(message)
|
114
|
-
options = { "From" => message['from'].to_s, "To" => message['to'].to_s, "Subject" => message.subject }
|
114
|
+
options = { "From" => message['from'].to_s, "To" => message['to'].to_s, "Subject" => message.subject, "Headers" => extract_headers(message) }
|
115
115
|
html = message.body_html
|
116
116
|
text = message.body_text
|
117
117
|
if message.multipart?
|
@@ -125,6 +125,16 @@ module Postmark
|
|
125
125
|
options
|
126
126
|
end
|
127
127
|
|
128
|
+
def extract_headers(message)
|
129
|
+
bogus_headers = %w[from to subject]
|
130
|
+
headers = []
|
131
|
+
message.each_header do |key, value|
|
132
|
+
next if bogus_headers.include? key.downcase
|
133
|
+
headers << { "Name" => key.upcase, "Value" => value.body }
|
134
|
+
end
|
135
|
+
headers
|
136
|
+
end
|
137
|
+
|
128
138
|
end
|
129
139
|
|
130
140
|
self.response_parser_class = nil
|
data/postmark.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{postmark}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Petyo Ivanov"]
|
12
|
-
s.date = %q{2009-12-
|
12
|
+
s.date = %q{2009-12-23}
|
13
13
|
s.description = %q{Ruby gem for sending emails through http://postmarkapp.com HTTP API. It relieas on TMail::Mail for message construction.}
|
14
14
|
s.email = %q{underlog@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -32,7 +32,6 @@ Gem::Specification.new do |s|
|
|
32
32
|
"lib/postmark/response_parsers/json.rb",
|
33
33
|
"lib/postmark/response_parsers/yajl.rb",
|
34
34
|
"lib/postmark/tmail_mail_extension.rb",
|
35
|
-
"lib/postmark/tmail_mail_extension.rb",
|
36
35
|
"postmark.gemspec",
|
37
36
|
"spec/postmark_spec.rb",
|
38
37
|
"spec/spec.opts",
|
@@ -73,3 +72,4 @@ Gem::Specification.new do |s|
|
|
73
72
|
s.add_dependency(%q<tmail>, [">= 0"])
|
74
73
|
end
|
75
74
|
end
|
75
|
+
|
data/spec/postmark_spec.rb
CHANGED
@@ -102,6 +102,25 @@ describe "Postmark" do
|
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
+
context "custom headers" do
|
106
|
+
|
107
|
+
let :message_with_headers do
|
108
|
+
TMail::Mail.new.tap do |mail|
|
109
|
+
mail.from = "sheldon@bigbangtheory.com"
|
110
|
+
mail.to = "lenard@bigbangtheory.com"
|
111
|
+
mail.subject = "Hello!"
|
112
|
+
mail.body = "Hello Sheldon!"
|
113
|
+
mail['CUSTOM-HEADER'] = "header"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should encode headers properly" do
|
118
|
+
json = %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!", "Headers":[{"Name":"CUSTOM-HEADER", "Value":"header"}]}]
|
119
|
+
result = Postmark.convert_tmail(message_with_headers)
|
120
|
+
result.should == JSON.parse(json)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
105
124
|
context "JSON library support" do
|
106
125
|
[:Json, :ActiveSupport, :Yajl].each do |lib|
|
107
126
|
begin
|
@@ -114,7 +133,6 @@ describe "Postmark" do
|
|
114
133
|
rescue LoadError # No ActiveSupport or Yajl :(
|
115
134
|
end
|
116
135
|
end
|
117
|
-
|
118
136
|
end
|
119
137
|
|
120
138
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postmark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Petyo Ivanov
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-23 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|