postmark 0.5.0 → 0.6.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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.6.0
data/lib/postmark.rb CHANGED
@@ -133,7 +133,14 @@ module Postmark
133
133
  end
134
134
 
135
135
  def convert_tmail(message)
136
- options = { "From" => message['from'].to_s, "To" => message['to'].to_s, "Subject" => message.subject, "Headers" => extract_headers(message) }
136
+ options = { "From" => message['from'].to_s, "To" => message['to'].to_s, "Subject" => message.subject }
137
+
138
+ headers = extract_headers(message)
139
+ options["Headers"] = headers unless headers.length == 0
140
+
141
+ options["Tag"] = message.tag.to_s unless message.tag.nil?
142
+
143
+ options["Cc"] = message['cc'].to_s unless message.cc.nil?
137
144
 
138
145
  if reply_to = message['reply-to']
139
146
  options["ReplyTo"] = reply_to.to_s
@@ -175,6 +182,7 @@ module Postmark
175
182
  cc
176
183
  bcc
177
184
  subject
185
+ tag
178
186
  ]
179
187
  end
180
188
 
@@ -14,6 +14,14 @@
14
14
  module TMail
15
15
  class Mail
16
16
 
17
+ def tag
18
+ self["TAG"]
19
+ end
20
+
21
+ def tag=(value)
22
+ self["TAG"] = value
23
+ end
24
+
17
25
  #
18
26
  # returs an String with just the html part of the body
19
27
  # or nil if there is not any html part
@@ -57,7 +65,7 @@ module TMail
57
65
  end
58
66
  result
59
67
  end
60
-
68
+
61
69
  #
62
70
  # This is only for develop.
63
71
  # print on output all the parts of the Mail with some details
@@ -67,14 +75,14 @@ module TMail
67
75
  puts "content_type: #{content_type}"
68
76
  puts "body: #{body}"
69
77
  puts "parts.size: #{parts.size}"
70
-
78
+
71
79
  if multipart?
72
80
  parts.each_with_index do |part, index|
73
81
  puts ""
74
82
  puts " parts[#{index}]"
75
83
  puts " content_type: #{part.content_type}"
76
84
  puts " multipart? #{part.multipart?}"
77
-
85
+
78
86
  header = part["content-type"]
79
87
 
80
88
  if part.multipart?
@@ -94,16 +102,16 @@ module TMail
94
102
  puts " --no multipart, no header nil, attachment--"
95
103
  puts " content_type: #{part.content_type}"
96
104
  end
97
-
105
+
98
106
  end
99
107
  else
100
108
  puts " --no multipart--"
101
109
  puts " content_type: #{content_type}"
102
110
  puts " body: #{unquoted_body}"
103
111
  end
104
-
112
+
105
113
  puts "END"
106
114
  end
107
-
115
+
108
116
  end
109
117
  end
data/postmark.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{postmark}
8
- s.version = "0.5.0"
8
+ s.version = "0.6.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{2010-02-26}
12
+ s.date = %q{2010-03-18}
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 = [
@@ -73,24 +73,35 @@ describe "Postmark" do
73
73
  end
74
74
  end
75
75
 
76
- context "custom headers" do
77
-
78
- let :message_with_headers do
79
- TMail::Mail.new.tap do |mail|
80
- mail.from = "sheldon@bigbangtheory.com"
81
- mail.to = "lenard@bigbangtheory.com"
82
- mail.subject = "Hello!"
83
- mail.body = "Hello Sheldon!"
84
- mail['CUSTOM-HEADER'] = "header"
85
- mail.reply_to = ['a@a.com', 'b@b.com']
86
- end
76
+ def be_serialized_to(json)
77
+ simple_matcher "be serialized to #{json}" do |message|
78
+ Postmark.convert_tmail(message).should == JSON.parse(json)
87
79
  end
80
+ end
88
81
 
89
- it "should encode headers properly" do
90
- json = %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "ReplyTo":"a@a.com, b@b.com", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!", "Headers":[{"Name":"Custom-Header", "Value":"header"}]}]
91
- result = Postmark.convert_tmail(message_with_headers)
92
- result.should == JSON.parse(json)
93
- end
82
+ it "should encode custom headers headers properly" do
83
+ message["CUSTOM-HEADER"] = "header"
84
+ message.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!", "Headers":[{"Name":"Custom-Header", "Value":"header"}]}]
85
+ end
86
+
87
+ it "should encode reply to" do
88
+ message.reply_to = ['a@a.com', 'b@b.com']
89
+ message.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "ReplyTo":"a@a.com, b@b.com", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
90
+ end
91
+
92
+ it "should encode tag" do
93
+ message.tag = "invite"
94
+ message.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "Tag":"invite", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
95
+ end
96
+
97
+ it "should encode multiple recepients (TO)" do
98
+ message.to = ['a@a.com', 'b@b.com']
99
+ message.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"a@a.com, b@b.com", "TextBody":"Hello Sheldon!"}]
100
+ end
101
+
102
+ it "should encode multiple recepients (CC)" do
103
+ message.cc = ['a@a.com', 'b@b.com']
104
+ message.should be_serialized_to %q[{"Cc":"a@a.com, b@b.com", "Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
94
105
  end
95
106
 
96
107
  context "JSON library support" do
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 5
7
+ - 6
8
8
  - 0
9
- version: 0.5.0
9
+ version: 0.6.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Petyo Ivanov
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-02-26 00:00:00 +02:00
17
+ date: 2010-03-18 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency