pony 1.9 → 1.10
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.
- checksums.yaml +4 -4
- data/README.rdoc +45 -12
- data/Rakefile +4 -0
- data/lib/pony.rb +29 -2
- data/pony.gemspec +1 -1
- data/spec/pony_spec.rb +71 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21b0731fb0237480bcebbaabdb5a16f2cd912ac8
|
4
|
+
data.tar.gz: 51429c927817896031f8505403189ed34bf272bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e080bca7fc9a958ca2bcb9fa19c24b67832c9e13c42c7cb42edd3c884735a4801495e79693fed386672aa1e96624cb238146cdce7bf67cd8dd3cb62a0501109
|
7
|
+
data.tar.gz: d74c23bf55d5b4429de41a321b2d6ca99378d711f64cb9b5108d0536eb700ec2ba426e5cd13102fcdfbc43612b301669c82a599f2b750076c8d50a15220e874b
|
data/README.rdoc
CHANGED
@@ -134,6 +134,26 @@ Default options can be set so that they don't have to be repeated. The default o
|
|
134
134
|
Pony.mail(:to => 'foo@bar') # Sends mail to foo@bar from noreply@example.com using smtp
|
135
135
|
Pony.mail(:from => 'pony@example.com', :to => 'foo@bar') # Sends mail to foo@bar from pony@example.com using smtp
|
136
136
|
|
137
|
+
|
138
|
+
== Set override options
|
139
|
+
|
140
|
+
Override options can be set so that the override value is always be used, even if a different value is passed in to Pony.options() or Pony.mail(). This can be used to configure a development or staging environment.
|
141
|
+
|
142
|
+
Pony.override_options = { :to => 'test@example.com' }
|
143
|
+
Pony.mail(:to => 'foo@bar') # Sends mail to test@example.com instead of foo@bar
|
144
|
+
|
145
|
+
== Set subject prefix
|
146
|
+
|
147
|
+
Prepends a string to the subject line. This is used to identify email sent from a specific environment.
|
148
|
+
|
149
|
+
Pony.subject_prefix('Prefix:')
|
150
|
+
|
151
|
+
== Append options to body
|
152
|
+
|
153
|
+
Append the options passd into Pony.mail to the body of the email. Useful for debugging.
|
154
|
+
|
155
|
+
Pony.append_inputs
|
156
|
+
|
137
157
|
== Help
|
138
158
|
|
139
159
|
If you need help using Pony, or it looks like you've found a bug,
|
@@ -153,18 +173,28 @@ Maintained by Ben Prew
|
|
153
173
|
Written by Adam Wiggins
|
154
174
|
|
155
175
|
Patches contributed by:
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
176
|
+
* Adam Wiggins
|
177
|
+
* Ben Prew
|
178
|
+
* Cameron Matheson
|
179
|
+
* Carl Hörberg
|
180
|
+
* Daniel Lopes
|
181
|
+
* Hiroshi Saito
|
182
|
+
* Kalin Harvey
|
183
|
+
* MIKAMI Yoshiyuki
|
184
|
+
* Mathieu Martin
|
185
|
+
* Michael Durrant
|
186
|
+
* Neil Middleton
|
187
|
+
* Neil Mock
|
188
|
+
* Nickolas Means
|
189
|
+
* Othmane Benkirane
|
190
|
+
* Rich Meyers
|
191
|
+
* Roman Franko
|
192
|
+
* Ryan Malecky
|
193
|
+
* Seamus Abshere
|
194
|
+
* Stephen Celis
|
195
|
+
* arunthampi
|
196
|
+
* rick
|
197
|
+
* rohit
|
168
198
|
|
169
199
|
Released under the MIT License: http://www.opensource.org/licenses/mit-license.php
|
170
200
|
|
@@ -173,6 +203,9 @@ mailing list: ponyrb@googlegroups.com
|
|
173
203
|
|
174
204
|
|
175
205
|
== Releases
|
206
|
+
1.10
|
207
|
+
* Add subject_prefix, append_options and override_options
|
208
|
+
|
176
209
|
1.9
|
177
210
|
* Allow options to be queried from the gem
|
178
211
|
|
data/Rakefile
CHANGED
data/lib/pony.rb
CHANGED
@@ -105,8 +105,9 @@ require 'socket'
|
|
105
105
|
module Pony
|
106
106
|
|
107
107
|
@@options = {}
|
108
|
-
|
109
|
-
|
108
|
+
@@override_options = {}
|
109
|
+
@@subject_prefix = false
|
110
|
+
@@append_inputs = false
|
110
111
|
|
111
112
|
# Default options can be set so that they don't have to be repeated.
|
112
113
|
#
|
@@ -121,12 +122,38 @@ module Pony
|
|
121
122
|
@@options
|
122
123
|
end
|
123
124
|
|
125
|
+
def self.override_options=(value)
|
126
|
+
@@override_options = value
|
127
|
+
end
|
128
|
+
|
129
|
+
def self.override_options
|
130
|
+
@@override_options
|
131
|
+
end
|
132
|
+
|
133
|
+
def self.subject_prefix(value)
|
134
|
+
@@subject_prefix = value
|
135
|
+
end
|
136
|
+
|
137
|
+
def self.append_inputs
|
138
|
+
@@append_inputs = true
|
139
|
+
end
|
140
|
+
|
124
141
|
# Send an email
|
125
142
|
# Pony.mail(:to => 'you@example.com', :from => 'me@example.com', :subject => 'hi', :body => 'Hello there.')
|
126
143
|
# Pony.mail(:to => 'you@example.com', :html_body => '<h1>Hello there!</h1>', :body => "In case you can't read html, Hello there.")
|
127
144
|
# Pony.mail(:to => 'you@example.com', :cc => 'him@example.com', :from => 'me@example.com', :subject => 'hi', :body => 'Howsit!')
|
128
145
|
def self.mail(options)
|
146
|
+
if @@append_inputs
|
147
|
+
options[:body] = "#{options[:body]}/n #{options.to_s}"
|
148
|
+
end
|
149
|
+
|
129
150
|
options = @@options.merge options
|
151
|
+
options = options.merge @@override_options
|
152
|
+
|
153
|
+
if @@subject_prefix
|
154
|
+
options[:subject] = "#{@@subject_prefix}#{options[:subject]}"
|
155
|
+
end
|
156
|
+
|
130
157
|
fail ArgumentError, ':to is required' unless options[:to]
|
131
158
|
|
132
159
|
options[:via] = default_delivery_method unless options.key?(:via)
|
data/pony.gemspec
CHANGED
data/spec/pony_spec.rb
CHANGED
@@ -229,6 +229,77 @@ describe Pony do
|
|
229
229
|
end
|
230
230
|
end
|
231
231
|
|
232
|
+
describe "override options" do
|
233
|
+
it "should use the overide options" do
|
234
|
+
expect(Pony).to receive(:build_mail).with(hash_including(:from => 'reply@pony'))
|
235
|
+
|
236
|
+
Pony.override_options = { :from => 'reply@pony' }
|
237
|
+
Pony.mail(:to => 'foo@bar')
|
238
|
+
end
|
239
|
+
|
240
|
+
it "should use an override option instead of a default options" do
|
241
|
+
expect(Pony).to receive(:build_mail).with(hash_including(:from => 'reply@pony.com'))
|
242
|
+
|
243
|
+
Pony.options = { :from => 'other_address@pony.com' }
|
244
|
+
Pony.override_options = { :from => 'reply@pony.com' }
|
245
|
+
Pony.mail(:to => 'foo@bar')
|
246
|
+
end
|
247
|
+
|
248
|
+
it "should use an override instead of a passed in value" do
|
249
|
+
expect(Pony).to receive(:build_mail).with(hash_including(:from => 'reply@pony.com'))
|
250
|
+
|
251
|
+
Pony.override_options = { :from => 'reply@pony.com' }
|
252
|
+
Pony.mail(:to => 'foo@bar', :from => 'other_address@pony.com')
|
253
|
+
end
|
254
|
+
|
255
|
+
it "should return the override options" do
|
256
|
+
input = { :from => 'reply@pony' }
|
257
|
+
Pony.override_options = input
|
258
|
+
output = Pony.override_options
|
259
|
+
|
260
|
+
expect(output).to eq input
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
describe "subject prefix" do
|
265
|
+
after(:all) do
|
266
|
+
Pony.subject_prefix(false)
|
267
|
+
end
|
268
|
+
|
269
|
+
it "should prefix email subject line with the given text" do
|
270
|
+
expect(Pony).to receive(:build_mail).with(hash_including(:subject => 'First: Second'))
|
271
|
+
|
272
|
+
Pony.subject_prefix('First: ')
|
273
|
+
Pony.mail(:to => 'foo@bar', :subject => 'Second')
|
274
|
+
end
|
275
|
+
|
276
|
+
it "should set the prefix as the subject if no subject is given" do
|
277
|
+
expect(Pony).to receive(:build_mail).with(hash_including(:subject => 'First: '))
|
278
|
+
|
279
|
+
Pony.subject_prefix('First: ')
|
280
|
+
Pony.mail(:to => 'foo@bar')
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
describe "append_inputs" do
|
285
|
+
it "appends the options passed into Pany.mail to the body" do
|
286
|
+
expect(Pony).to receive(:build_mail).with(hash_including(:body => "body/n {:to=>\"foo@bar\", :body=>\"body\"}"))
|
287
|
+
|
288
|
+
Pony.append_inputs
|
289
|
+
|
290
|
+
Pony.mail(:to => 'foo@bar', :body => 'body')
|
291
|
+
end
|
292
|
+
|
293
|
+
it "sets the options passed into Pany.mail as the body if one is not present" do
|
294
|
+
expect(Pony).to receive(:build_mail).with(hash_including(:body => "/n {:to=>\"foo@bar\"}"))
|
295
|
+
|
296
|
+
Pony.append_inputs
|
297
|
+
|
298
|
+
Pony.mail(:to => 'foo@bar')
|
299
|
+
end
|
300
|
+
|
301
|
+
end
|
302
|
+
|
232
303
|
describe "content type" do
|
233
304
|
context "mail with attachments, html_body and body " do
|
234
305
|
subject(:mail) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pony
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.10'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Wiggins
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-07-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mail
|