pony-express 0.5.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README +7 -5
  2. data/VERSION +1 -1
  3. data/lib/pony-express.rb +32 -7
  4. data/mime.types +367 -0
  5. metadata +4 -3
data/README CHANGED
@@ -17,12 +17,14 @@ REQUIREMENT:
17
17
  USAGE:
18
18
 
19
19
  >> require "pony-express"
20
- >> args = { from: "jim@example.com", to: "ralph@example.com", subject: "test email", via: "sendmail" }
21
- >> args[:text] = "Hello!"
22
- >> args[:html] = "<strong>Hello!</strong>"
23
- >> args[:attachments] = [ "/home/jim/party.png" ]
24
- >> PonyExpress.mail(args)
20
+ >> mail = PonyExpress::Mail.new to: "burns@plant.local", from: "homer@home.local", via: "sendmail"
21
+ >> mail.add subject: "Hello Mr.Burns", text: "Can I have more donuts", html: "<strong>More Dooooonuuuuts!</strong>"
22
+ >> mail.add attachments: [ "/home/homer/donuts.png" ]
23
+ >> mail.dispatch
25
24
 
25
+ Don't want to create new mail objects ? Just pass in all options to PonyExpress.mail
26
+
27
+ >> PonyExpress.mail to: "burns@plant.local", from: "homer@home.local", ...
26
28
 
27
29
  TODO:
28
30
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.6.1
data/lib/pony-express.rb CHANGED
@@ -8,12 +8,12 @@ module PonyExpress
8
8
 
9
9
  Mimetic.load_mime_types File.dirname(__FILE__) + "/../mime.types"
10
10
 
11
- def self.build options
11
+ def build options
12
12
  # TODO validation.
13
13
  Mimetic.build(options)
14
14
  end
15
15
 
16
- def self.mail options
16
+ def mail options
17
17
  via = (options.delete(:via) || :smtp).to_sym
18
18
  via_options = options.delete(:via_options) || {}
19
19
 
@@ -27,14 +27,12 @@ module PonyExpress
27
27
  end
28
28
  end
29
29
 
30
- private
31
-
32
- def self.sendmail_binary
30
+ def sendmail_binary
33
31
  sendmail = `which sendmail`.chomp
34
32
  sendmail.empty? ? '/usr/sbin/sendmail' : sendmail
35
33
  end
36
34
 
37
- def self.transport_via_sendmail content, options={}
35
+ def transport_via_sendmail content, options={}
38
36
  IO.popen('-', 'w+') do |pipe|
39
37
  if pipe
40
38
  pipe.write(content)
@@ -44,7 +42,7 @@ module PonyExpress
44
42
  end
45
43
  end
46
44
 
47
- def self.transport_via_smtp content, from, to, options={}
45
+ def transport_via_smtp content, from, to, options={}
48
46
  o = DEFAULT_SMTP_OPTIONS.merge(options)
49
47
  smtp = Net::SMTP.new(o[:host], o[:port])
50
48
  if o[:tls]
@@ -60,4 +58,31 @@ module PonyExpress
60
58
  smtp.finish
61
59
  end
62
60
 
61
+ class Mail
62
+ include PonyExpress
63
+ attr_accessor :options
64
+
65
+ def initialize opt={}
66
+ @options = opt
67
+ end
68
+
69
+ def add opt
70
+ @options.merge! opt
71
+ end
72
+
73
+ def remove opt
74
+ keys = opt.keys
75
+ @options.reject! {|k, v| keys.include?(k) }
76
+ end
77
+
78
+ def dispatch
79
+ mail(@options)
80
+ end
81
+
82
+ def content
83
+ build(@options)
84
+ end
85
+ end
86
+
87
+ extend self
63
88
  end
data/mime.types ADDED
@@ -0,0 +1,367 @@
1
+ application/andrew-inset ez
2
+ application/annodex anx
3
+ application/atom+xml atom
4
+ application/atomcat+xml atomcat
5
+ application/atomserv+xml atomsrv
6
+ application/bbolin lin
7
+ application/cap cap pcap
8
+ application/cu-seeme cu
9
+ application/davmount+xml davmount
10
+ application/dsptype tsp
11
+ application/ecmascript es
12
+ application/futuresplash spl
13
+ application/hta hta
14
+ application/java-archive jar
15
+ application/java-serialized-object ser
16
+ application/java-vm class
17
+ application/javascript js
18
+ application/m3g m3g
19
+ application/mac-binhex40 hqx
20
+ application/mac-compactpro cpt
21
+ application/mathematica nb nbp
22
+ application/msaccess mdb
23
+ application/msword doc dot
24
+ application/octet-stream bin
25
+ application/oda oda
26
+ application/ogg ogx
27
+ application/pdf pdf
28
+ application/pgp-keys key
29
+ application/pgp-signature pgp
30
+ application/pics-rules prf
31
+ application/postscript ps ai eps epsi epsf eps2 eps3
32
+ application/rar rar
33
+ application/rdf+xml rdf
34
+ application/rss+xml rss
35
+ application/rtf rtf
36
+ application/smil smi smil
37
+ application/xhtml+xml xhtml xht
38
+ application/xml xml xsl xsd
39
+ application/xspf+xml xspf
40
+ application/zip zip
41
+ application/vnd.android.package-archive apk
42
+ application/vnd.cinderella cdy
43
+ application/vnd.google-earth.kml+xml kml
44
+ application/vnd.google-earth.kmz kmz
45
+ application/vnd.mozilla.xul+xml xul
46
+ application/vnd.ms-excel xls xlb xlt
47
+ application/vnd.ms-pki.seccat cat
48
+ application/vnd.ms-pki.stl stl
49
+ application/vnd.ms-powerpoint ppt pps
50
+ application/vnd.oasis.opendocument.chart odc
51
+ application/vnd.oasis.opendocument.database odb
52
+ application/vnd.oasis.opendocument.formula odf
53
+ application/vnd.oasis.opendocument.graphics odg
54
+ application/vnd.oasis.opendocument.graphics-template otg
55
+ application/vnd.oasis.opendocument.image odi
56
+ application/vnd.oasis.opendocument.presentation odp
57
+ application/vnd.oasis.opendocument.presentation-template otp
58
+ application/vnd.oasis.opendocument.spreadsheet ods
59
+ application/vnd.oasis.opendocument.spreadsheet-template ots
60
+ application/vnd.oasis.opendocument.text odt
61
+ application/vnd.oasis.opendocument.text-master odm
62
+ application/vnd.oasis.opendocument.text-template ott
63
+ application/vnd.oasis.opendocument.text-web oth
64
+ application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
65
+ application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx
66
+ application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
67
+ application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx
68
+ application/vnd.openxmlformats-officedocument.presentationml.template potx
69
+ application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
70
+ application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
71
+ application/vnd.rim.cod cod
72
+ application/vnd.smaf mmf
73
+ application/vnd.stardivision.calc sdc
74
+ application/vnd.stardivision.chart sds
75
+ application/vnd.stardivision.draw sda
76
+ application/vnd.stardivision.impress sdd
77
+ application/vnd.stardivision.math sdf
78
+ application/vnd.stardivision.writer sdw
79
+ application/vnd.stardivision.writer-global sgl
80
+ application/vnd.sun.xml.calc sxc
81
+ application/vnd.sun.xml.calc.template stc
82
+ application/vnd.sun.xml.draw sxd
83
+ application/vnd.sun.xml.draw.template std
84
+ application/vnd.sun.xml.impress sxi
85
+ application/vnd.sun.xml.impress.template sti
86
+ application/vnd.sun.xml.math sxm
87
+ application/vnd.sun.xml.writer sxw
88
+ application/vnd.sun.xml.writer.global sxg
89
+ application/vnd.sun.xml.writer.template stw
90
+ application/vnd.symbian.install sis
91
+ application/vnd.visio vsd
92
+ application/vnd.wap.wbxml wbxml
93
+ application/vnd.wap.wmlc wmlc
94
+ application/vnd.wap.wmlscriptc wmlsc
95
+ application/vnd.wordperfect wpd
96
+ application/vnd.wordperfect5.1 wp5
97
+ application/x-123 wk
98
+ application/x-abiword abw
99
+ application/x-apple-diskimage dmg
100
+ application/x-bcpio bcpio
101
+ application/x-bittorrent torrent
102
+ application/x-cab cab
103
+ application/x-cbr cbr
104
+ application/x-cbz cbz
105
+ application/x-cdf cdf cda
106
+ application/x-cdlink vcd
107
+ application/x-chess-pgn pgn
108
+ application/x-cpio cpio
109
+ application/x-csh csh
110
+ application/x-debian-package deb udeb
111
+ application/x-director dcr dir dxr
112
+ application/x-dms dms
113
+ application/x-doom wad
114
+ application/x-dvi dvi
115
+ application/x-httpd-eruby rhtml
116
+ application/x-font pfa pfb gsf pcf pcf.Z
117
+ application/x-freemind mm
118
+ application/x-futuresplash spl
119
+ application/x-gnumeric gnumeric
120
+ application/x-go-sgf sgf
121
+ application/x-graphing-calculator gcf
122
+ application/x-gtar gtar tgz taz
123
+ application/x-hdf hdf
124
+ application/x-httpd-php phtml pht php
125
+ application/x-httpd-php-source phps
126
+ application/x-httpd-php3 php3
127
+ application/x-httpd-php3-preprocessed php3p
128
+ application/x-httpd-php4 php4
129
+ application/x-ica ica
130
+ application/x-info info
131
+ application/x-internet-signup ins isp
132
+ application/x-iphone iii
133
+ application/x-iso9660-image iso
134
+ application/x-jam jam
135
+ application/x-java-jnlp-file jnlp
136
+ application/x-jmol jmz
137
+ application/x-kchart chrt
138
+ application/x-killustrator kil
139
+ application/x-koan skp skd skt skm
140
+ application/x-kpresenter kpr kpt
141
+ application/x-kspread ksp
142
+ application/x-kword kwd kwt
143
+ application/x-latex latex
144
+ application/x-lha lha
145
+ application/x-lyx lyx
146
+ application/x-lzh lzh
147
+ application/x-lzx lzx
148
+ application/x-maker frm maker frame fm fb book fbdoc
149
+ application/x-mif mif
150
+ application/x-ms-wmd wmd
151
+ application/x-ms-wmz wmz
152
+ application/x-msdos-program com exe bat dll
153
+ application/x-msi msi
154
+ application/x-netcdf nc
155
+ application/x-ns-proxy-autoconfig pac dat
156
+ application/x-nwc nwc
157
+ application/x-object o
158
+ application/x-oz-application oza
159
+ application/x-pkcs7-certreqresp p7r
160
+ application/x-pkcs7-crl crl
161
+ application/x-python-code pyc pyo
162
+ application/x-qgis qgs shp shx
163
+ application/x-quicktimeplayer qtl
164
+ application/x-redhat-package-manager rpm
165
+ application/x-ruby rb
166
+ application/x-sh sh
167
+ application/x-shar shar
168
+ application/x-shockwave-flash swf swfl
169
+ application/x-silverlight scr
170
+ application/x-stuffit sit sitx
171
+ application/x-sv4cpio sv4cpio
172
+ application/x-sv4crc sv4crc
173
+ application/x-tar tar
174
+ application/x-tcl tcl
175
+ application/x-tex-gf gf
176
+ application/x-tex-pk pk
177
+ application/x-texinfo texinfo texi
178
+ application/x-trash ~ % bak old sik
179
+ application/x-troff t tr roff
180
+ application/x-troff-man man
181
+ application/x-troff-me me
182
+ application/x-troff-ms ms
183
+ application/x-ustar ustar
184
+ application/x-wais-source src
185
+ application/x-wingz wz
186
+ application/x-x509-ca-cert crt
187
+ application/x-xcf xcf
188
+ application/x-xfig fig
189
+ application/x-xpinstall xpi
190
+ audio/amr amr
191
+ audio/amr-wb awb
192
+ audio/amr amr
193
+ audio/amr-wb awb
194
+ audio/annodex axa
195
+ audio/basic au snd
196
+ audio/flac flac
197
+ audio/midi mid midi kar
198
+ audio/mpeg mpga mpega mp2 mp3 m4a
199
+ audio/mpegurl m3u
200
+ audio/ogg oga ogg spx
201
+ audio/prs.sid sid
202
+ audio/x-aiff aif aiff aifc
203
+ audio/x-gsm gsm
204
+ audio/x-mpegurl m3u
205
+ audio/x-ms-wma wma
206
+ audio/x-ms-wax wax
207
+ audio/x-pn-realaudio ra rm ram
208
+ audio/x-realaudio ra
209
+ audio/x-scpls pls
210
+ audio/x-sd2 sd2
211
+ audio/x-wav wav
212
+ chemical/x-alchemy alc
213
+ chemical/x-cache cac cache
214
+ chemical/x-cache-csf csf
215
+ chemical/x-cactvs-binary cbin cascii ctab
216
+ chemical/x-cdx cdx
217
+ chemical/x-cerius cer
218
+ chemical/x-chem3d c3d
219
+ chemical/x-chemdraw chm
220
+ chemical/x-cif cif
221
+ chemical/x-cmdf cmdf
222
+ chemical/x-cml cml
223
+ chemical/x-compass cpa
224
+ chemical/x-crossfire bsd
225
+ chemical/x-csml csml csm
226
+ chemical/x-ctx ctx
227
+ chemical/x-cxf cxf cef
228
+ chemical/x-embl-dl-nucleotide emb embl
229
+ chemical/x-galactic-spc spc
230
+ chemical/x-gamess-input inp gam gamin
231
+ chemical/x-gaussian-checkpoint fch fchk
232
+ chemical/x-gaussian-cube cub
233
+ chemical/x-gaussian-input gau gjc gjf
234
+ chemical/x-gaussian-log gal
235
+ chemical/x-gcg8-sequence gcg
236
+ chemical/x-genbank gen
237
+ chemical/x-hin hin
238
+ chemical/x-isostar istr ist
239
+ chemical/x-jcamp-dx jdx dx
240
+ chemical/x-kinemage kin
241
+ chemical/x-macmolecule mcm
242
+ chemical/x-macromodel-input mmd mmod
243
+ chemical/x-mdl-molfile mol
244
+ chemical/x-mdl-rdfile rd
245
+ chemical/x-mdl-rxnfile rxn
246
+ chemical/x-mdl-sdfile sd sdf
247
+ chemical/x-mdl-tgf tgf
248
+ chemical/x-mmcif mcif
249
+ chemical/x-mol2 mol2
250
+ chemical/x-molconn-Z b
251
+ chemical/x-mopac-graph gpt
252
+ chemical/x-mopac-input mop mopcrt mpc zmt
253
+ chemical/x-mopac-out moo
254
+ chemical/x-mopac-vib mvb
255
+ chemical/x-ncbi-asn1 asn
256
+ chemical/x-ncbi-asn1-ascii prt ent
257
+ chemical/x-ncbi-asn1-binary val aso
258
+ chemical/x-ncbi-asn1-spec asn
259
+ chemical/x-pdb pdb ent
260
+ chemical/x-rosdal ros
261
+ chemical/x-swissprot sw
262
+ chemical/x-vamas-iso14976 vms
263
+ chemical/x-vmd vmd
264
+ chemical/x-xtel xtel
265
+ chemical/x-xyz xyz
266
+ image/gif gif
267
+ image/ief ief
268
+ image/jpeg jpeg jpg jpe
269
+ image/pcx pcx
270
+ image/png png
271
+ image/svg+xml svg svgz
272
+ image/tiff tiff tif
273
+ image/vnd.djvu djvu djv
274
+ image/vnd.wap.wbmp wbmp
275
+ image/x-canon-cr2 cr2
276
+ image/x-canon-crw crw
277
+ image/x-cmu-raster ras
278
+ image/x-coreldraw cdr
279
+ image/x-coreldrawpattern pat
280
+ image/x-coreldrawtemplate cdt
281
+ image/x-corelphotopaint cpt
282
+ image/x-epson-erf erf
283
+ image/x-icon ico
284
+ image/x-jg art
285
+ image/x-jng jng
286
+ image/x-ms-bmp bmp
287
+ image/x-nikon-nef nef
288
+ image/x-olympus-orf orf
289
+ image/x-photoshop psd
290
+ image/x-portable-anymap pnm
291
+ image/x-portable-bitmap pbm
292
+ image/x-portable-graymap pgm
293
+ image/x-portable-pixmap ppm
294
+ image/x-rgb rgb
295
+ image/x-xbitmap xbm
296
+ image/x-xpixmap xpm
297
+ image/x-xwindowdump xwd
298
+ message/rfc822 eml
299
+ model/iges igs iges
300
+ model/mesh msh mesh silo
301
+ model/vrml wrl vrml
302
+ model/x3d+vrml x3dv
303
+ model/x3d+xml x3d
304
+ model/x3d+binary x3db
305
+ text/calendar ics icz
306
+ text/css css
307
+ text/csv csv
308
+ text/html html htm shtml
309
+ text/iuls uls
310
+ text/mathml mml
311
+ text/plain asc txt text pot brf
312
+ text/richtext rtx
313
+ text/scriptlet sct wsc
314
+ text/texmacs tm ts
315
+ text/tab-separated-values tsv
316
+ text/vnd.sun.j2me.app-descriptor jad
317
+ text/vnd.wap.wml wml
318
+ text/vnd.wap.wmlscript wmls
319
+ text/x-bibtex bib
320
+ text/x-boo boo
321
+ text/x-c++hdr h++ hpp hxx hh
322
+ text/x-c++src c++ cpp cxx cc
323
+ text/x-chdr h
324
+ text/x-component htc
325
+ text/x-csh csh
326
+ text/x-csrc c
327
+ text/x-dsrc d
328
+ text/x-diff diff patch
329
+ text/x-haskell hs
330
+ text/x-java java
331
+ text/x-literate-haskell lhs
332
+ text/x-moc moc
333
+ text/x-pascal p pas
334
+ text/x-pcs-gcd gcd
335
+ text/x-perl pl pm
336
+ text/x-python py
337
+ text/x-scala scala
338
+ text/x-setext etx
339
+ text/x-sh sh
340
+ text/x-tcl tcl tk
341
+ text/x-tex tex ltx sty cls
342
+ text/x-vcalendar vcs
343
+ text/x-vcard vcf
344
+ video/annodex axv
345
+ video/dl dl
346
+ video/dv dif dv
347
+ video/fli fli
348
+ video/gl gl
349
+ video/mpeg mpeg mpg mpe
350
+ video/mp4 mp4
351
+ video/quicktime qt mov
352
+ video/ogg ogv
353
+ video/vnd.mpegurl mxu
354
+ video/x-flv flv
355
+ video/x-la-asf lsf lsx
356
+ video/x-mng mng
357
+ video/x-ms-asf asf asx
358
+ video/x-ms-wm wm
359
+ video/x-ms-wmv wmv
360
+ video/x-ms-wmx wmx
361
+ video/x-ms-wvx wvx
362
+ video/x-msvideo avi
363
+ video/x-sgi-movie movie
364
+ video/x-matroska mpv mkv
365
+ x-conference/x-cooltalk ice
366
+ x-epoc/x-sisx-app sisx
367
+ x-world/x-vrml vrm vrml wrl
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pony-express
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bharanee Rathna
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-06-02 00:00:00 +10:00
12
+ date: 2010-06-03 00:00:00 +10:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -23,11 +23,12 @@ extra_rdoc_files:
23
23
  - LICENSE
24
24
  - README
25
25
  files:
26
+ - LICENSE
26
27
  - README
27
28
  - VERSION
28
29
  - ext/mimetic.cxx
29
30
  - lib/pony-express.rb
30
- - LICENSE
31
+ - mime.types
31
32
  has_rdoc: true
32
33
  homepage: http://github.com/deepfryed/pony-express
33
34
  licenses: []