malone 1.0.2 → 1.0.3

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.
Files changed (4) hide show
  1. data/lib/malone.rb +25 -3
  2. data/malone.gemspec +1 -1
  3. data/test/malone.rb +12 -6
  4. metadata +1 -1
@@ -36,14 +36,22 @@ class Malone
36
36
 
37
37
  begin
38
38
  smtp.start(config.domain, config.user, config.password, config.auth)
39
- smtp.send_message(mail.to_s, mail.from.first, mail.to)
39
+ smtp.send_message(mail.to_s, mail.from.first, *recipients(mail))
40
40
  ensure
41
41
  smtp.finish if smtp.started?
42
42
  end
43
43
  end
44
44
 
45
+ def recipients(mail)
46
+ [].tap do |ret|
47
+ ret.push(*mail.to)
48
+ ret.push(*mail.cc)
49
+ ret.push(*mail.bcc)
50
+ end
51
+ end
52
+
45
53
  def envelope(dict)
46
- envelope = MailFactory.new
54
+ envelope = Envelope.new
47
55
  envelope.from = dict[:from]
48
56
  envelope.to = dict[:to]
49
57
  envelope.cc = dict[:cc] if dict[:cc]
@@ -66,7 +74,7 @@ class Malone
66
74
 
67
75
  def initialize(options)
68
76
  opts = options.dup
69
-
77
+
70
78
  @tls = true
71
79
 
72
80
  url = opts.delete(:url) || ENV["MALONE_URL"]
@@ -97,4 +105,18 @@ class Malone
97
105
  CGI.unescape(val)
98
106
  end
99
107
  end
108
+
109
+ class Envelope < MailFactory
110
+ attr :bcc
111
+
112
+ def initialize
113
+ super
114
+
115
+ @bcc = []
116
+ end
117
+
118
+ def bcc=(bcc)
119
+ @bcc.push(bcc)
120
+ end
121
+ end
100
122
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'malone'
3
- s.version = "1.0.2"
3
+ s.version = "1.0.3"
4
4
  s.summary = %{Dead-simple Ruby mailing solution which always delivers.}
5
5
  s.date = "2011-01-10"
6
6
  s.author = "Cyril David"
@@ -88,9 +88,12 @@ test "#envelope" do
88
88
  m = Malone.connect
89
89
 
90
90
  mail = m.envelope(to: "recipient@me.com", from: "no-reply@mydomain.com",
91
- subject: "SUB", text: "TEXT", html: "<h1>TEXT</h1>")
91
+ subject: "SUB", text: "TEXT", html: "<h1>TEXT</h1>",
92
+ cc: "cc@me.com", bcc: "bcc@me.com")
92
93
 
93
94
  assert_equal ["recipient@me.com"], mail.to
95
+ assert_equal ["cc@me.com"], mail.cc
96
+ assert_equal ["bcc@me.com"], mail.bcc
94
97
  assert_equal ["no-reply@mydomain.com"], mail.from
95
98
  assert_equal ["=?utf-8?Q?SUB?="], mail.subject
96
99
 
@@ -118,8 +121,8 @@ scope do
118
121
  @finish = true
119
122
  end
120
123
 
121
- def send_message(blob, from, to)
122
- @blob, @from, @to = blob, from, to
124
+ def send_message(blob, from, *recipients)
125
+ @blob, @from, @recipients = blob, from, recipients
123
126
  end
124
127
 
125
128
  def [](key)
@@ -140,7 +143,7 @@ scope do
140
143
 
141
144
  test "delivering successfully" do |m|
142
145
  m.deliver(to: "recipient@me.com", from: "no-reply@mydomain.com",
143
- subject: "SUB", text: "TEXT")
146
+ subject: "SUB", text: "TEXT", cc: "cc@me.com", bcc: "bcc@me.com")
144
147
 
145
148
  assert_equal "smtp.gmail.com", $smtp.host
146
149
  assert_equal 587, $smtp.port
@@ -151,9 +154,12 @@ scope do
151
154
  assert_equal "pass1234", $smtp[:password]
152
155
  assert_equal :login, $smtp[:auth]
153
156
 
154
- assert_equal ["recipient@me.com"], $smtp[:to]
157
+
158
+ assert_equal ["recipient@me.com", "cc@me.com", "bcc@me.com"], $smtp[:recipients]
155
159
  assert_equal "no-reply@mydomain.com", $smtp[:from]
156
160
 
161
+ assert ! $smtp[:blob].include?("bcc@me.com")
162
+
157
163
  assert $smtp[:started]
158
164
  assert $smtp[:finish]
159
165
  end
@@ -171,7 +177,7 @@ scope do
171
177
  assert_equal "pass1234", $smtp[:password]
172
178
  assert_equal :login, $smtp[:auth]
173
179
 
174
- assert_equal ["recipient@me.com"], $smtp[:to]
180
+ assert_equal ["recipient@me.com"], $smtp[:recipients]
175
181
  assert_equal "no-reply@mydomain.com", $smtp[:from]
176
182
 
177
183
  assert $smtp[:started]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: malone
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: