This commit was manufactured by cvs2svn to create tag

'mime-types-1-13-1'.
This commit is contained in:
(no author) 2004-07-07 02:04:19 +00:00
Родитель f1ef356dfa
Коммит 699f178636
9 изменённых файлов: 2670 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,77 @@
Revision history for Ruby extension MIME::Types.
Unless explicitly stated differently are all changes produced by Austin
Ziegler <mime-types@halostatue.ca>.
== MIME::Types 1.13.1
* Fixed a problem with the installer running tests. This now works.
* Improved the implementation of MIME::Type.signature?
* Moved code around to use the class << self idiom instead of always
prepending the module/class name.
* Added two new best-guess implementations of functions found in Perl's
MIME::Types implementation (1.13). Do not rely on these until the purpose
and implementation is stabilised.
* Updated the MIME list to reflect changes noted by
Ville Skyttä <ville.skytta@iki.fi>.
* Added a new constant to MIME::Types, DATA_VERSION. This will allow the Ruby
version number to be updated separately from the Perl version while keeping
the MIME Type list version in sync.
== MIME::Types 1.13
! WARNING: This version changes the API of MIME::Types !
! WARNING: This version is compatible with Ruby 1.8 and higher ONLY !
* Removed dependency on InstallPackage; offering 1.13 as either .tar.gz or
.gem.
* Split into two files, mime/type.rb and mime/types.rb. This will make
maintaining the list of changes easier.
* Changed the MIME::Type construction API. Accepts only a single String
argument (but does no named type-checking) and yields self.
* Removed private methods #init_extensions, #init_encoding, and #init_system
and replaced with #extensions=, #encoding=, and #system=.
* Added #default_encoding to return 'quoted-printable' or 'base64' depending
on the media type of the MIME type.
* Added #raw_media_type and #raw_sub_type to provide the non-simplified
versions of the media type and subtype.
* Alternative constructors MIME::Type.from_array, MIME::Type.from_hash, and
MIME::Type.from_mime_type added to compensate for the removal of named type
checking in the original constructor.
* Added #to_str, #to_a, and #to_hash methods. The latter two will provide
output suitable for use in #from_array and #from_hash.
* Removed "binary" encoding and enforced the use of a valid encoding string.
* Added #system? returning true if the MIME::Type is an OS-specific
MIME::Type.
* Added #platform? returning true if the MIME::Type is an OS-specific
MIME::Type for the current RUBY_PLATFORM.
* Added #like? returning true if the simplified type matches the other value
provided. #<'application/x-excel'>.like?('application/excel') is true.
* Added #complete? returning true if the MIME::Type specifies an extension
list.
* Updated the MIME type list to reflect additions by Mark Overmeer for Perl's
MIME::Types 1.12 and the official IANA list as of 2004.04.06. A number of
formerly "registered" MIME types are now no longer registered (e.g.,
application/excel is now application/x-excel). This ensures that the
simplified type still works with applications, but does not report an
unregistered type as registered.
* Restored MIME type list to Mark Overmeer's format to facilitate easy
exchange between the two projects.
* Added additional unit tests from Mark Overmeer's 1.12 version.
== MIME::Types 1.07
* Changed version numbering to match Perl MIME::Types 1.07.
* Re-synchronized with Mark Overmeer's list in Perl PMIME::Types 1.07.
- [NN Poster] updated the attributes for the PGP types.
== MIME::Types 1.005
* Changed to Phil Thomson's InstallPackage.
* Added several types from Perl MIME::Types 1.005.
* Cleaned up data format; some data formats will show up with proper data now.
== MIME::Types 1.004
* Updated to match Perl MIME::Types 1.004, links credited to Dan Puro. Adds
new reference list to http://www.indiana.edu/cgi-bin-local/mimetypes
* Removed InvalidType and replaced with TypeError.
* Changed instances of #type to #class.
* Cleaned up how simplified versions are created.
== MIME::Types 1.003
* Initial release based on Perl MIME::Types 1.003.

Просмотреть файл

@ -0,0 +1,6 @@
Installing this package is as simple as:
% ruby install.rb
Alternatively, you can use the RubyGem version of MIME::Types available as
mime-types-1.13.1.gem from the usual sources.

Просмотреть файл

@ -0,0 +1,709 @@
application/activemessage
application/andrew-inset ez
application/appledouble base64
application/applefile base64
application/atomicmail
application/batch-SMTP
application/beep+xml
application/cals-1840
application/cnrp+xml
application/commonground
application/cpl+xml
application/cybercash
application/DCA-RFT
application/DEC-DX
application/dicom
application/dvcs
application/EDI-Consent
application/EDI-X12
application/EDIFACT
application/eshop
application/font-tdpfr pfr
application/http
application/hyperstudio stk
application/iges
application/index
application/index.cmd
application/index.obj
application/index.response
application/index.vnd
application/iotp
application/ipp
application/isup
application/mac-binhex40 hqx 8bit
application/macwriteii
application/marc
application/mathematica
application/mpeg4-generic
application/msword doc,dot,wrd base64
application/news-message-id
application/news-transmission
application/ocsp-request orq
application/ocsp-response ors
application/octet-stream bin,dms,lha,lzh,exe,class,ani,pgp base64
application/oda oda
application/ogg ogg
application/parityfec
application/pdf pdf base64
application/pgp-encrypted 7bit
application/pgp-keys 7bit
application/pgp-signature sig base64
application/pidf+xml
application/pkcs10 p10
application/pkcs7-mime p7m,p7c
application/pkcs7-signature p7s
application/pkix-cert cer
application/pkix-crl crl
application/pkix-pkipath pkipath
application/pkixcmp pki
application/postscript ai,eps,ps 8bit
application/postscript ps-z base64
application/prs.alvestrand.titrax-sheet
application/prs.cww cw,cww
application/prs.nprend rnd,rct
application/prs.plucker
application/qsig
application/reginfo+xml
application/remote-printing
application/riscos
application/rtf rtf 8bit
application/sdp
application/set-payment
application/set-payment-initiation
application/set-registration
application/set-registration-initiation
application/sgml
application/sgml-open-catalog soc
application/sieve siv
application/slate
application/timestamp-query
application/timestamp-reply
application/tve-trigger
application/vemmi
application/vnd.3gpp.pic-bw-large plb
application/vnd.3gpp.pic-bw-small psb
application/vnd.3gpp.pic-bw-var pvb
application/vnd.3gpp.sms sms
application/vnd.3M.Post-it-Notes
application/vnd.accpac.simply.aso
application/vnd.accpac.simply.imp
application/vnd.acucobol
application/vnd.acucorp atc,acutc 7bit
application/vnd.adobe.xfdf xfdf
application/vnd.aether.imp
application/vnd.amiga.amu ami
application/vnd.anser-web-certificate-issue-initiation
application/vnd.anser-web-funds-transfer-initiation
application/vnd.audiograph
application/vnd.blueice.multipass mpm
application/vnd.bmi
application/vnd.businessobjects
application/vnd.canon-cpdl
application/vnd.canon-lips
application/vnd.cinderella cdy
application/vnd.claymore
application/vnd.commerce-battelle
application/vnd.commonspace
application/vnd.contact.cmsg
application/vnd.cosmocaller cmc
application/vnd.criticaltools.wbs+xml wbs
application/vnd.ctc-posml
application/vnd.cups-postscript
application/vnd.cups-raster
application/vnd.cups-raw
application/vnd.curl curl
application/vnd.cybank
application/vnd.data-vision.rdz rdz
application/vnd.dna
application/vnd.dpgraph
application/vnd.dreamfactory dfac
application/vnd.dxr
application/vnd.ecdis-update
application/vnd.ecowin.chart
application/vnd.ecowin.filerequest
application/vnd.ecowin.fileupdate
application/vnd.ecowin.series
application/vnd.ecowin.seriesrequest
application/vnd.ecowin.seriesupdate
application/vnd.enliven
application/vnd.epson.esf
application/vnd.epson.msf
application/vnd.epson.quickanime
application/vnd.epson.salt
application/vnd.epson.ssf
application/vnd.ericsson.quickcall
application/vnd.eudora.data
application/vnd.fdf
application/vnd.ffsns
application/vnd.FloGraphIt
application/vnd.framemaker
application/vnd.fsc.weblauch fsc 7bit
application/vnd.fujitsu.oasys
application/vnd.fujitsu.oasys2
application/vnd.fujitsu.oasys3
application/vnd.fujitsu.oasysgp
application/vnd.fujitsu.oasysprs
application/vnd.fujixerox.ddd
application/vnd.fujixerox.docuworks
application/vnd.fujixerox.docuworks.binder
application/vnd.fut-misnet
application/vnd.genomatix.tuxedo txd
application/vnd.grafeq
application/vnd.groove-account
application/vnd.groove-help
application/vnd.groove-identity-message
application/vnd.groove-injector
application/vnd.groove-tool-message
application/vnd.groove-tool-template
application/vnd.groove-vcard
application/vnd.hbci hbci,hbc,kom,upa,pkd,bpd
application/vnd.hhe.lesson-player les
application/vnd.hp-HPGL plt,hpgl
application/vnd.hp-hpid
application/vnd.hp-hps
application/vnd.hp-PCL
application/vnd.hp-PCLXL
application/vnd.httphone
application/vnd.hzn-3d-crossword
application/vnd.ibm.afplinedata
application/vnd.ibm.electronic-media emm
application/vnd.ibm.MiniPay
application/vnd.ibm.modcap
application/vnd.ibm.rights-management irm
application/vnd.ibm.secure-container sc
application/vnd.informix-visionary
application/vnd.intercon.formnet
application/vnd.intertrust.digibox
application/vnd.intertrust.nncp
application/vnd.intu.qbo
application/vnd.intu.qfx
application/vnd.ipunplugged.rcprofile rcprofile
application/vnd.irepository.package+xml irp
application/vnd.is-xpr
application/vnd.japannet-directory-service
application/vnd.japannet-jpnstore-wakeup
application/vnd.japannet-payment-wakeup
application/vnd.japannet-registration
application/vnd.japannet-registration-wakeup
application/vnd.japannet-setstore-wakeup
application/vnd.japannet-verification
application/vnd.japannet-verification-wakeup
application/vnd.jisp jisp
application/vnd.kde.karbon karbon
application/vnd.kde.kchart chrt
application/vnd.kde.kformula kfo
application/vnd.kde.kivio flw
application/vnd.kde.kontour kon
application/vnd.kde.kpresenter ksp
application/vnd.kde.kspread ksp
application/vnd.kde.kword kwd,kwt
application/vnd.kenameapp htke
application/vnd.kidspiration kia
application/vnd.koan
application/vnd.liberty-request+xml
application/vnd.llamagraphics.life-balance.desktop lbd
application/vnd.llamagraphics.life-balance.exchange+xml lbe
application/vnd.lotus-1-2-3
application/vnd.lotus-approach
application/vnd.lotus-freelance
application/vnd.lotus-notes
application/vnd.lotus-organizer
application/vnd.lotus-screencam
application/vnd.lotus-wordpro
application/vnd.mcd
application/vnd.mediastation.cdkey
application/vnd.meridian-slingshot
application/vnd.micrografx.flo flo
application/vnd.micrografx.igx igx
application/vnd.mif mif
application/vnd.minisoft-hp3000-save
application/vnd.mitsubishi.misty-guard.trustweb
application/vnd.mobius.DAF
application/vnd.mobius.DIS
application/vnd.mobius.MBK
application/vnd.mobius.MQY
application/vnd.mobius.MSL
application/vnd.mobius.PLC
application/vnd.mobius.TXF
application/vnd.mophun.application mpn
application/vnd.mophun.certificate mpc
application/vnd.motorola.flexsuite
application/vnd.motorola.flexsuite.adsi
application/vnd.motorola.flexsuite.fis
application/vnd.motorola.flexsuite.gotap
application/vnd.motorola.flexsuite.kmr
application/vnd.motorola.flexsuite.ttc
application/vnd.motorola.flexsuite.wem
application/vnd.mozilla.xul+xml xul
application/vnd.ms-access mdf,mda,mdb,mde base64
application/vnd.ms-artgalry cil
application/vnd.ms-asf asf
application/vnd.ms-excel xls,xlt base64
application/vnd.ms-lrm lrm
application/vnd.ms-powerpoint ppt,pps,pot base64
application/vnd.ms-project mpp base64
application/vnd.ms-tnef base64
application/vnd.ms-works base64
application/vnd.ms-wpl wpl base64
application/vnd.mseq mseq
application/vnd.msign
application/vnd.music-niff
application/vnd.musician
application/vnd.nervana ent,entity,req,request,bkm,kcm
application/vnd.netfpx
application/vnd.noblenet-directory
application/vnd.noblenet-sealer
application/vnd.noblenet-web
application/vnd.nokia.radio-preset
application/vnd.nokia.radio-presets
application/vnd.novadigm.EDM
application/vnd.novadigm.EDX
application/vnd.novadigm.EXT
application/vnd.obn
application/vnd.osa.netdeploy
application/vnd.palm prc,pdb,pqa,oprc
application/vnd.paos.xml
application/vnd.pg.format
application/vnd.pg.osasli
application/vnd.picsel efif
application/vnd.powerbuilder6
application/vnd.powerbuilder6-s
application/vnd.powerbuilder7
application/vnd.powerbuilder7-s
application/vnd.powerbuilder75
application/vnd.powerbuilder75-s
application/vnd.previewsystems.box
application/vnd.publishare-delta-tree
application/vnd.pvi.ptid1 pti,ptid
application/vnd.pwg-multiplexed
application/vnd.pwg-xmhtml-print+xml
application/vnd.Quark.QuarkXPress qxd,qxt,qwd,qwt,qxl,qxb 8bit
application/vnd.rapid
application/vnd.s3sms
application/vnd.sealed.doc sdoc,sdo,s1w
application/vnd.sealed.eml seml,sem
application/vnd.sealed.mht smht,smh
application/vnd.sealed.net
application/vnd.sealed.ppt sppt,spp,s1p
application/vnd.sealed.xls sxls,sxl,s1e
application/vnd.sealedmedia.softseal.html stml,stm,s1h
application/vnd.sealedmedia.softseal.pdf spdf,spd,s1a
application/vnd.seemail see
application/vnd.shana.informed.formdata
application/vnd.shana.informed.formtemplate
application/vnd.shana.informed.interchange
application/vnd.shana.informed.package
application/vnd.smaf mmf
application/vnd.sss-cod
application/vnd.sss-dtf
application/vnd.sss-ntf
application/vnd.street-stream
application/vnd.svd
application/vnd.swiftview-ics
application/vnd.triscape.mxs
application/vnd.trueapp
application/vnd.truedoc
application/vnd.ufdl
application/vnd.uiq.theme
application/vnd.uplanet.alert
application/vnd.uplanet.alert-wbxml
application/vnd.uplanet.bearer-choice
application/vnd.uplanet.bearer-choice-wbxml
application/vnd.uplanet.cacheop
application/vnd.uplanet.cacheop-wbxml
application/vnd.uplanet.channel
application/vnd.uplanet.channel-wbxml
application/vnd.uplanet.list
application/vnd.uplanet.list-wbxml
application/vnd.uplanet.listcmd
application/vnd.uplanet.listcmd-wbxml
application/vnd.uplanet.signal
application/vnd.vcx
application/vnd.vectorworks
application/vnd.vidsoft.vidconference vsc 8bit
application/vnd.visio vsd,vst,vsw,vss
application/vnd.visionary vis
application/vnd.vividence.scriptfile
application/vnd.vsf
application/vnd.wap.sic sic
application/vnd.wap.slc slc
application/vnd.wap.wbxml wbxml
application/vnd.wap.wmlc wmlc
application/vnd.wap.wmlscriptc wmlsc
application/vnd.webturbo wtb
application/vnd.wordperfect wpd,wp
application/vnd.wqd wqd
application/vnd.wrq-hp3000-labelled
application/vnd.wt.stf
application/vnd.wv.csp+wbxml wv
application/vnd.wv.csp+xml 8bit
application/vnd.wv.ssp+xml 8bit
application/vnd.xara
application/vnd.xfdl
application/vnd.yamaha.hv-dic hvd
application/vnd.yamaha.hv-script hvs
application/vnd.yamaha.hv-voice hvp
application/vnd.yamaha.smaf-audio saf
application/vnd.yamaha.smaf-phrase spf
application/vnd.yellowriver-custom-menu
application/watcherinfo+xml wif
application/whoispp-query
application/whoispp-response
application/WITA
application/wordperfect5.1 wp5
application/x-123 wk
application/x-acad
application/x-access mdf,mda,mdb,mde # was application/access mdf
application/x-bcpio bcpio
application/x-bleeper bleep base64 # was application/bleeper bleep base64
application/x-bzip2 bz2
application/x-cdlink vcd
application/x-chess-pgn pgn
application/x-clariscad
application/x-compress z,Z base64
application/x-compressed z,Z base64
application/x-cpio cpio base64
application/x-csh csh 8bit
application/x-cu-seeme csm,cu # was application/cu-seeme csm,cu
application/x-debian-package deb
application/x-director dcr,dir,dxr
application/x-drafting
application/x-dvi dvi base64
application/x-dxf
application/x-excel xls,xlt base64
application/x-fractals
application/x-futuresplash spl # was application/futuresplash spl
application/x-ghostview # was application/ghostview
application/x-gtar gtar,tgz,tbz2,tbz base64
application/x-gunzip
application/x-gzip gz base64
application/x-hdf hdf
application/x-hep hep # was application/hep hep
application/x-html+ruby rhtml 8bit
application/x-httpd-php phtml,pht,php 8bit
application/x-ica ica
application/x-ideas
application/x-imagemap imagemap,imap 8bit # was application/imagemap imagemap,imap 8bit
application/x-java-archive jar
application/x-java-jnlp-file jnlp
application/x-java-serialized-object ser
application/x-java-vm class
application/x-javascript js 8bit
application/x-koan skp,skd,skt,skm
application/x-latex latex 8bit
application/x-lotus-123 wk # was application/lotus-123 wks
application/x-mac-compactpro cpt # was application/mac-compactpro cpt
application/x-macbinary
application/x-maker frm,maker,frame,fm,fb,book,fbdoc
application/x-mathcad mcd base64 # was application/mathcad mcd base64
application/x-mathematica-old # was application/mathematica-old
application/x-mif mif
application/x-msdos-program cmd,bat 8bit
application/x-msdos-program com,exe base64
application/x-msdownload exe,com base64
application/x-netcdf nc,cdf
application/x-ns-proxy-autoconfig pac
application/x-pagemaker pm5,pt5,pm # was application/pagemaker pm5,pt5,pm
application/x-perl pl,pm 8bit
application/x-pgp # was application/pgp
application/x-powerpoint ppt,pps,pot base64 # was application/powerpoint ppt,pps,pot base64
application/x-python py 8bit
application/x-quicktimeplayer qtl # was application/quicktimeplayer qtl
application/x-rar-compressed rar base64
application/x-remote_printing
application/x-rtf rtf 8bit
application/x-ruby rb,rbw 8bit
application/x-set
application/x-sh sh 8bit
application/x-shar shar 8bit
application/x-shockwave-flash swf
application/x-SLA
application/x-smil smi,smil # was application/smil smi,smil
application/x-solids
application/x-spss sav,sbs,sps,spo
application/x-STEP
application/x-stuffit sit base64
application/x-sv4cpio sv4cpio base64
application/x-sv4crc sv4crc base64
application/x-tar tar base64
application/x-tcl tcl 8bit
application/x-tex tex 8bit
application/x-texinfo texinfo,texi 8bit
application/x-toolbook tbk # was application/toolbook tbk
application/x-troff-man man 8bit
application/x-troff-me me
application/x-troff-ms ms
application/x-troff t,tr,roff 8bit
application/x-u-star
application/x-ustar ustar base64
application/x-vda
application/x-VMSBACKUP bck base64 # was application/VMSBACKUP bck base64
application/x-wais-source src
application/x-Wingz wz
application/x-word doc,dot base64
application/x-wordperfect wp # was application/wordperfect wp
application/x-wordperfect6.1 wp6 # was application/wordperfect6.1 wp6
application/x-wordperfectd wpd # was application/wordperfectd wpd
application/x-x400.bp
application/x-x509-ca-cert crt base64
application/x400-bp
application/xhtml+xml xhtml 8bit
application/xml
application/xml-dtd
application/xml-external-parsed-entity
application/zip zip base64
audio/32kadpcm
audio/AMR-WB awb base64
audio/AMR amr base64
audio/basic au,snd base64
audio/CN
audio/DAT12
audio/dsr-es201108
audio/DVI4
audio/EVRC-QCP
audio/EVRC evc
audio/EVRC0
audio/G.722.1
audio/G722
audio/G723
audio/G726-16
audio/G726-24
audio/G726-32
audio/G726-40
audio/G728
audio/G729
audio/G729D
audio/G729E
audio/GSM
audio/GSM-EFR
audio/L16 l16
audio/l20
audio/L24
audio/L8
audio/LPC
audio/MP4A-LATM
audio/MPA
audio/mpa-robust
audio/mpeg mpga,mp2,mp3 base64
audio/mpeg4-generic
audio/parityfec
audio/PCMA
audio/PCMU
audio/prs.sid sid,psid
audio/QCELP qcp
audio/RED
audio/SMV-QCP
audio/SMV smv
audio/SMV0
audio/telephone-event
audio/tone
audio/VDVI
audio/vnd.3gpp.iufp
audio/vnd.cisco.nse
audio/vnd.cns.anp1
audio/vnd.cns.inf1
audio/vnd.digital-winds eol 7bit
audio/vnd.everad.plj plj
audio/vnd.lucent.voice lvp
audio/vnd.nokia.mobile-xmf xmf
audio/vnd.nortel.vbk vbk
audio/vnd.nuera.ecelp4800 ecelp4800
audio/vnd.nuera.ecelp7470 ecelp7470
audio/vnd.nuera.ecelp9600 ecelp9600
audio/vnd.octel.sbc
audio/vnd.qcelp qcp # DEPRECATED
audio/vnd.rhetorex.32kadpcm
audio/vnd.sealedmedia.softseal.mpeg smp3,smp,s1m
audio/vnd.vmx.cvsd
audio/x-aiff aif,aifc,aiff base64
audio/x-midi mid,midi,kar base64 # was audio/midi mid,midi,kar base64
audio/x-pn-realaudio-plugin rpm
audio/x-pn-realaudio rm,ram base64
audio/x-realaudio ra base64
audio/x-wav wav base64
image/cgm
image/g3fax
image/gif gif base64
image/ief ief base64
image/jp2 jp2 base64
image/jpeg jpeg,jpg,jpe base64
image/jpm jpm base64
image/jpx jpx base64
image/naplps
image/png png base64
image/prs.btif
image/prs.pti
image/t38
image/tiff-fx
image/tiff tiff,tif base64
image/vnd.cns.inf2
image/vnd.djvu djvu,djv
image/vnd.dwg dwg
image/vnd.dxf
image/vnd.fastbidsheet
image/vnd.fpx
image/vnd.fst
image/vnd.fujixerox.edmics-mmr
image/vnd.fujixerox.edmics-rlc
image/vnd.glocalgraphics.pgb pgb
image/vnd.microsoft.icon ico
image/vnd.mix
image/vnd.ms-modi mdi
image/vnd.net-fpx
image/vnd.net.fpx
image/vnd.sealed.png spng,spn,s1n
image/vnd.sealedmedia.softseal.gif sgif,sgi,s1g
image/vnd.sealedmedia.softseal.jpg sjpg,sjp,s1j
image/vnd.svf
image/vnd.wap.wbmp wbmp
image/vnd.xiff
image/x-bmp bmp # was image/bmp bmp
image/x-cmu-raster ras
image/x-paintshoppro psp,pspimage base64
image/x-pict
image/x-portable-anymap pnm base64
image/x-portable-bitmap pbm base64
image/x-portable-graymap pgm base64
image/x-portable-pixmap ppm base64
image/x-rgb rgb base64
image/x-targa tga
image/x-vnd.dgn dgn
image/x-win-bmp
image/x-xbitmap xbm 7bit
image/x-xbm xbm 7bit
image/x-xpixmap xpm 8bit
image/x-xwindowdump xwd base64
message/CPIM
message/delivery-status
message/disposition-notification
message/external-body 8bit
message/http
message/news 8bit
message/partial 8bit
message/rfc822 8bit
message/s-http
message/sip
message/sipfrag
model/iges igs,iges
model/mesh msh,mesh,silo
model/vnd.dwf
model/vnd.flatland.3dml
model/vnd.gdl
model/vnd.gs-gdl
model/vnd.gtw
model/vnd.mts
model/vnd.parasolid.transmit.binary x_b,xmt_bin
model/vnd.parasolid.transmit.text x_t,xmt_txt quoted-printable
model/vnd.vtu
model/vrml wrl,vrml
multipart/alternative 8bit
multipart/appledouble 8bit
multipart/byteranges
multipart/digest 8bit
multipart/encrypted
multipart/form-data
multipart/header-set
multipart/mixed 8bit
multipart/parallel 8bit
multipart/related
multipart/report
multipart/signed
multipart/voice-message
multipart/x-gzip
multipart/x-mixed-replace
multipart/x-tar
multipart/x-ustar
multipart/x-www-form-urlencoded
multipart/x-zip
text/calendar
text/css css 8bit
text/directory
text/enriched
text/html html,htm,htmlx,shtml,htx 8bit
text/parityfec
text/plain txt,asc,c,cc,h,hh,cpp,hpp,dat,hlp 8bit
text/prs.fallenstein.rst rst
text/prs.lines.tag
text/rfc822-headers
text/richtext rtf,rtx 8bit
text/sgml sgml,sgm
text/t140
text/tab-separated-values tsv
text/uri-list
text/vnd.abc
text/vnd.curl
text/vnd.DMClientScript
text/vnd.fly
text/vnd.fmi.flexstor
text/vnd.in3d.3dml
text/vnd.in3d.spot
text/vnd.IPTC.NewsML
text/vnd.IPTC.NITF
text/vnd.latex-z
text/vnd.motorola.reflex
text/vnd.ms-mediapackage
text/vnd.net2phone.commcenter.command ccc
text/vnd.sun.j2me.app-descriptor jad 8bit
text/vnd.wap.si si
text/vnd.wap.sl sl
text/vnd.wap.wml wml
text/vnd.wap.wmlscript wmls
text/x-comma-separated-values csv 8bit # was text/comma-separated-values csv 8bit
text/x-rtf rtf
text/x-setext etx
text/x-setext etx
text/x-sgml sgml,sgm 8bit
text/x-vCalendar vcs 8bit
text/x-vCard vcf 8bit
text/x-vnd.flatland.3dml # was text/vnd.flatland.3dml
text/x-yaml yaml,yml 8bit
text/xml-external-parsed-entity
text/xml xml,dtd 8bit
video/BMPEG
video/BT656
video/CelB
video/DV
video/gl gl base64 # was video/gl gl base64
video/H261
video/H263
video/H263-1998
video/H263-2000
video/JPEG
video/MJ2
video/MP1S
video/MP2P
video/MP2T
video/MP4V-ES
video/mpeg mp2,mpe,mpeg,mpg base64
video/mpeg4-generic
video/MPV
video/nv
video/parityfec
video/pointer
video/quicktime qt,mov base64
video/SMPTE292M
video/vnd.fvt fvt
video/vnd.motorola.video
video/vnd.motorola.videop
video/vnd.mpegurl mxu,m4u 8bit
video/vnd.nokia.interleaved-multimedia nim
video/vnd.objectvideo mp4
video/vnd.sealed.mpeg1 s11
video/vnd.sealed.mpeg4 smpg,s14
video/vnd.sealed.swf sswf,ssw
video/vnd.sealedmedia.softseal.mov smov,smo,s1q
video/vnd.vivo viv,vivo
video/x-dl dl base64 # was video/dl dl base64
video/x-fli fli base64 # was video/fli fli base64
video/x-ms-asf asf,asx
video/x-msvideo avi base64
video/x-sgi-movie movie base64
x-chemical/x-pdb pdb
x-chemical/x-xyz xyz
x-conference/x-cooltalk ice
x-drawing/dwf dwf
x-world/x-vrml wrl,vrml
# Exceptions
mac:application/x-macbase64 bin
vms:text/plain doc 8bit

Просмотреть файл

@ -0,0 +1,15 @@
Mime::Types README
This is release 1.13.1 of MIME::Types for Ruby, based on the Perl package of the
same name. It is generally kept in sync with the Perl version of MIME::Types.
This package works on the same concept as mailcap, which uses filename
extensions to determine the file's likely MIME content type. This package does
not analyse files for magic bytes to determine the appropriate actual MIME
content type.
Copyright © 2002 - 2004 Austin Ziegler
Based on prior work copyright © Mark Overmeer
This package is licensed under Ruby's licence, the Perl Artistic licence, or
the GPL version 2 or later.

Просмотреть файл

@ -0,0 +1,187 @@
##
# Install utility for HaloStatue scripts and libraries. Based heavily on the
# original RDoc installation script by Pragmatic Programmers.
#
require 'rbconfig'
require 'find'
require 'fileutils'
require 'rdoc/rdoc'
require 'optparse'
require 'ostruct'
require 'test/unit/ui/console/testrunner'
InstallOptions = OpenStruct.new
# Set these values to what you want installed.
bins = %w{bin/**/*}
rdoc = %w{bin/**/*.rb lib/**/*.rb}
ri = %w(bin/**/*.rb lib/**/*.rb)
libs = %w{lib/**/*.rb}
tests = %w{tests/**/*.rb}
def do_bins(bins, strip = 'bin/')
bins.each do |bf|
obf = bf.gsub(/#{strip}/, '')
install_binfile(bf, obf)
end
end
def do_libs(libs, strip = 'lib/')
libs.each do |lf|
olf = File.join(InstallOptions.site_dir, lf.gsub(/#{strip}/, ''))
op = File.dirname(olf)
File.makedirs(op, true)
File.chmod(0755, op)
File.install(lf, olf, 0755, true)
end
end
##
# Prepare the file installation.
#
def prepare_installation
InstallOptions.rdoc = true
InstallOptions.ri = true
InstallOptions.tests = true
ARGV.options do |opts|
opts.banner = "Usage: #{File.basename($0)} [options]"
opts.separator ""
opts.on('--no-rdoc', FalseClass,
'Prevents the creation of RDoc output.') do |onrdoc|
InstallOptions.rdoc = onrdoc
end
opts.on('--no-ri', FalseClass,
'Prevents the creation of RI output.') do |onri|
InstallOptions.ri = onri
end
opts.on('--no-tests', FalseClass,
'Prevents the execution of nit tests.') do |ontest|
InstallOptions.tests = ontest
end
opts.separator("")
opts.on_tail('--help', "Shows this help text.") do
$stderr.puts opts
exit
end
opts.parse!
end
bds = [".", ENV['TMP'], ENV['TEMP']]
version = [Config::CONFIG["MAJOR"], Config::CONFIG["MINOR"]].join(".")
ld = File.join(Config::CONFIG["libdir"], "ruby", version)
sd = Config::CONFIG["sitelibdir"]
if sd.nil?
sd = $:.find { |x| x =~ /site_ruby/ }
if sd.nil?
sd = File.join(ld, "site_ruby")
elsif sd !~ Regexp.quote(version)
sd = File.join(sd, version)
end
end
if (destdir = ENV['DESTDIR'])
bd = "#{destdir}#{Config::CONFIG['bindir']}"
sd = "#{destdir}#{sd}"
bds << bd
FileUtils.makedirs(bd)
FileUtils.makedirs(sd)
else
bds << Config::CONFIG['bindir']
end
InstallOptions.bin_dirs = bds.compact
InstallOptions.site_dir = sd
InstallOptions.bin_dir = bd
InstallOptions.lib_dir = ld
end
##
# Build the rdoc documentation. Also, try to build the RI documentation.
#
def build_rdoc(files)
r = RDoc::RDoc.new
r.document(%w{--line-numbers --show-hash} + files)
rescue RDoc::RDocError => e
$stderr.puts e.message
end
def build_ri(files)
ri = RDoc::RDoc.new
ri.document(%w{--ri-site --line-numbers --show-hash} + files)
rescue RDoc::RDocError => e
$stderr.puts e.message
end
def run_tests(test_list)
$:.unshift "lib"
test_list.each do |test|
next if File.directory?(test)
require test
end
tests = []
ObjectSpace.each_object { |o| tests << o if o.kind_of?(Class) }
tests.delete_if { |o| !o.ancestors.include?(Test::Unit::TestCase) }
tests.delete_if { |o| o == Test::Unit::TestCase }
tests.each { |test| Test::Unit::UI::Console::TestRunner.run(test) }
$:.shift
end
##
# Install file(s) from ./bin to Config::CONFIG['bindir']. Patch it on the way
# to insert a #! line; on a Unix install, the command is named as expected
# (e.g., bin/rdoc becomes rdoc); the shebang line handles running it. Under
# windows, we add an '.rb' extension and let file associations do their stuff.
def install_binfile(from, op_file)
tmp_dir = nil
BinDirs.each do |t|
stat = File.stat(t) rescue next
if stat.directory? and stat.writable?
tmp_dir = t
break
end
end
fail "Cannot finda temporary directory" unless tmp_dir
tmp_file = File.join(tmp_dir, '_tmp')
File.open(from) do |ip|
File.open(tmp_file, "w") do |op|
ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
op.puts "#!#{ruby}"
op.write ip.read
end
end
opfile += ".rb" if Config::CONFIG["target_os"] =~ /win/
FileUtils.install(tmp_file, File.join(TargetBinDir, opfile), 0755, true)
FileUtils.unlink(tmp_file)
end
def glob(list)
g = []
list.each { |i| g << Dir.glob(i) }
g.flatten!
g.compact!
g
end
prepare_installation
bins = glob(bins)
rdoc = glob(rdoc)
ri = glob(ri)
libs = glob(libs)
tests = glob(tests)
run_tests(tests) if InstallOptions.tests
build_rdoc(rdoc) if InstallOptions.rdoc
build_ri(ri) if InstallOptions.ri
do_bins(bins)
do_libs(libs)

Просмотреть файл

@ -0,0 +1,387 @@
#:title: MIME::Types
#:main: MIME::Types
#--
# MIME::Types for Ruby
# Version 1.13.1
#
# Copyright (c) 2002 - 2004 Austin Ziegler
#
# $Id$
#
# The ChangeLog contains all details on revisions.
#++
# TODO include ../../ChangeLog
module MIME #:nodoc:
# Reflects a MIME Content-Type which is in invalid format (e.g., it isn't
# in the form of type/subtype).
class InvalidContentType < RuntimeError; end
# == Summary
# Definition of one MIME content-type
#
# == Synopsis
# require 'mime/types'
#
# plaintext = MIME::Types['text/plain']
# print plaintext.media_type # => 'text'
# print plaintext.sub_type # => 'plain'
#
# puts plaintext.extensions.join(" ") # => 'asc txt c cc h hh cpp'
#
# puts plaintext.encoding # => 8bit
# puts plaintext.binary? # => false
# puts plaintext.ascii? # => true
# puts plaintext == 'text/plain' # => true
# puts MIME::Type.simplified('x-appl/x-zip') # => 'appl/zip'
#
class Type
VERSION = '1.13.1' #:nodoc:
include Comparable
CONTENT_TYPE_RE = %r{^([-\w.+]+)/([-\w.+]*)$}o #:nodoc:
UNREGISTERED_RE = %r{^[Xx]-}o #:nodoc:
ENCODING_RE = %r{^(?:base64|7bit|8bit|quoted\-printable)$}o #:nodoc:
PLATFORM_RE = %r|#{RUBY_PLATFORM}|o #:nodoc:
SIGNATURES = %w(application/pgp-keys application/pgp application/pgp-signature application/pkcs10 application/pkcs7-mime application/pkcs7-signature text/vcard) #:nodoc:
# Returns +true+ if the simplified type matches the current
def like?(other)
if other.respond_to?(:simplified)
@simplified == other.simplified
else
@simplified == Type.simplified(other)
end
end
# Compares the MIME::Type against the exact content type or the
# simplified type (the simplified type will be used if comparing against
# something that can be treated as a String with #to_s).
def <=>(other) #:nodoc:
if other.respond_to?(:content_type)
@content_type <=> other.content_type
elsif other.respond_to?(:to_s)
@simplified <=> Type.simplified(other.to_s)
else
@content_type <=> other
end
end
# Returns +true+ if the other object is a MIME::Type and the content
# types match.
def eql?(other) #:nodoc:
other.kind_of?(MIME::Type) and self == other
end
# Returns the whole MIME content-type string.
attr_reader :content_type
# Returns the media type of the simplified MIME type.
#
# text/plain => text
# x-chemical/x-pdb => chemical
attr_reader :media_type
# Returns the media type of the unmodified MIME type.
#
# text/plain => text
# x-chemical/x-pdb => x-chemical
attr_reader :raw_media_type
# Returns the sub-type of the simplified MIME type.
#
# text/plain => plain
# x-chemical/x-pdb => pdb
attr_reader :sub_type
# Returns the media type of the unmodified MIME type.
#
# text/plain => plain
# x-chemical/x-pdb => x-pdb
attr_reader :raw_sub_type
# The MIME types main- and sub-label can both start with <tt>x-</tt>,
# which indicates that it is a non-registered name. Of course, after
# registration this flag can disappear, adds to the confusing
# proliferation of MIME types. The simplified string has the <tt>x-</tt>
# removed and are translated to lowercase.
attr_reader :simplified
# The list of extensions which are known to be used for this MIME::Type.
# Non-array values will be coerced into an array with #to_a. Array
# values will be flattened and +nil+ values removed.
attr_accessor :extensions
def extensions=(ext) #:nodoc:
@extensions = ext.to_a.flatten.compact
end
# The encoding (7bit, 8bit, quoted-printable, or base64) required to
# transport the data of this content type safely across a network, which
# roughly corresponds to Content-Transfer-Encoding. A value of +nil+ or
# <tt>:default</tt> will reset the #encoding to the #default_encoding
# for the MIME::Type. Raises ArgumentError if the encoding provided is
# invalid.
attr_accessor :encoding
def encoding=(enc) #:nodoc:
if enc.nil? or enc == :default
@encoding = self.default_encoding
elsif enc =~ ENCODING_RE
@encoding = enc
else
raise ArgumentError, "The encoding must be nil, :default, base64, 7bit, 8bit, or quoted-printable."
end
end
# The regexp for the operating system that this MIME::Type is specific
# to.
attr_accessor :system
def system=(os) #:nodoc:
if os.nil? or os.kind_of?(Regexp)
@system = os
else
@system = %r|#{os}|
end
end
# Returns the default encoding for the MIME::Type based on the media
# type.
def default_encoding
(@media_type == 'text') ? 'quoted-printable' : 'base64'
end
class << self
# The MIME types main- and sub-label can both start with <tt>x-</tt>,
# which indicates that it is a non-registered name. Of course, after
# registration this flag can disappear, adds to the confusing
# proliferation of MIME types. The simplified string has the
# <tt>x-</tt> removed and are translated to lowercase.
def Type.simplified(content_type)
matchdata = CONTENT_TYPE_RE.match(content_type)
if matchdata.nil?
simplified = nil
else
media_type = matchdata.captures[0].downcase.gsub(UNREGISTERED_RE, '')
subtype = matchdata.captures[1].downcase.gsub(UNREGISTERED_RE, '')
simplified = "#{media_type}/#{subtype}"
end
simplified
end
# Creates a MIME::Type from an array in the form of:
# [type-name, [extensions], encoding, system]
#
# +extensions+, +encoding+, and +system+ are optional.
#
# MIME::Type.from_array("application/x-ruby", ['rb'], '8bit')
# MIME::Type.from_array(["application/x-ruby", ['rb'], '8bit'])
#
# See MIME::Type.new for more information.
#
def from_array(*args) #:yields MIME::Types.new:
# Dereferences the array one level, if necessary.
args = args[0] if args[0].kind_of?(Array)
if args.size.between?(1, 4)
m = MIME::Type.new(args[0]) do |t|
t.extensions = args[1] if args.size > 1
t.encoding = args[2] if args.size > 2
t.system = args[3] if args.size > 3
end
yield m if block_given?
else
raise ArgumentError, "Array provided must contain between one and four elements."
end
m
end
# Creates a MIME::Type from a hash. Keys are case-insensitive, dashes
# may be replaced with underscores, and the internal Symbol of the
# lowercase-underscore version can be used as well. That is,
# Content-Type can be provided as content-type, Content_Type,
# content_type, or :content_type.
#
# Acceptable keys are <tt>Content-Type</tt>,
# <tt>Content-Transfer-Encoding</tt>, <tt>Extensions</tt>, and
# <tt>System</tt>.
#
# MIME::Type.from_hash('Content-Type' => 'text/x-yaml',
# 'Content-Transfer-Encoding' => '8bit',
# 'System' => 'linux',
# 'Extensions' => ['yaml', 'yml'])
#
# See MIME::Type.new for more information.
#
def from_hash(hash) #:yields MIME::Types.new:
hash = hash.dup
hash.each_pair do |k, v|
if k.respond_to?(:intern)
hash[k.tr('-A-Z', '_a-z').intern] = v
hash.delete(k)
end
end
m = MIME::Type.new(hash[:content_type]) do |t|
t.extensions = hash[:extensions]
t.encoding = hash[:content_transfer_encoding]
t.system = hash[:system]
end
yield m if block_given?
m
end
# +arg+ may also be one of MIME::Type, Array, or Hash.
# [MIME::Type] Equivalent to a copy constructor.
# MIME::Type.new(plaintext)
def from_mime_type(mime_type) #:yields MIME::Type.new:
m = MIME::Types.new(mime_type.content_type.dup) do |t|
t.extensions = mime_type.extensions.dup
t.system = mime_type.system.dup
t.encoding = mime_type.encoding.dup
end
yield m if block_given?
end
end
# MIME::Types are constructed with an alternative object construction
# technique where +self+ is +yield+ed after initial construction.
#
# MIME::Type.new('application/x-eruby') do |t|
# t.extensions = 'rhtml'
# t.encoding = '8bit'
# end
#
# === Changes
# In MIME::Types 1.07, the constructor accepted more argument types and
# called #instance_eval on the optional block provided. This is no
# longer the case as of 1.13. The full changes are noted below.
#
# 1. The constructor +yield+s +self+ instead of using #instance_eval and
# that the calls to #init_extensions, #init_encoding, and
# #init_system have been eliminated.
# 2. MIME::Type.new no longer accepts a MIME::Type argument. Use
# MIME::Type.from_mime_type instead.
#
# # 1.07
# MIME::Type.new(plaintext)
# # 1.12
# MIME::Type.from_mime_type(plaintext)
#
# 3. MIME::Type.new no longer accepts an Array argument. Use
# MIME::Type.from_array instead.
#
# # 1.07
# MIME::Type.new(["application/x-ruby", ["rb"], "8bit"])
# # 1.12
# MIME::Type.from_array("application/x-ruby", ['rb'], '8bit')
# MIME::Type.from_array(["application/x-ruby", ['rb'], '8bit'])
#
# 4. MIME::Type.new no longer accepts a Hash argument. Use
# MIME::Type.from_hash instead.
#
# # 1.07
# MIME::Type.new('Content-Type' => 'text/x-yaml',
# 'Content-Transfer-Encoding' => '8bit',
# 'System' => 'linux',
# 'Extensions' => ['yaml', 'yml'])
# # 1.12
# MIME::Type.from_hash('Content-Type' => 'text/x-yaml',
# 'Content-Transfer-Encoding' => '8bit',
# 'System' => 'linux',
# 'Extensions' => ['yaml', 'yml'])
#
# *NOTE*:: If the encoding is not specified, then it will be defaulted
# to 'quoted-printable' for 'text/*' media types and 'base64'
# for every other type. See #encoding for more information.
#
def initialize(content_type) #:yields self:
matchdata = CONTENT_TYPE_RE.match(content_type)
if matchdata.nil?
raise InvalidContentType, "Invalid Content-Type provided ('#{content_type}')"
end
@content_type = content_type
@raw_media_type = matchdata.captures[0]
@raw_sub_type = matchdata.captures[1]
@simplified = MIME::Type.simplified(@content_type)
matchdata = CONTENT_TYPE_RE.match(@simplified)
@media_type = matchdata.captures[0]
@sub_type = matchdata.captures[1]
self.extensions = nil
self.encoding = :default
self.system = nil
yield self if block_given?
end
# MIME content-types which are not regestered by IANA nor defined in
# RFCs are required to start with <tt>x-</tt>. This counts as well for a
# new media type as well as a new sub-type of an existing media type. If
# either the media-type or the content-type begins with <tt>x-</tt>,
# this method will return +false+.
def registered?
not (@raw_media_type =~ UNREGISTERED_RE) || (@raw_sub_type =~ UNREGISTERED_RE)
end
# MIME types can be specified to be sent across a network in particular
# formats. This method returns +true+ when the MIME type encoding is set
# to <tt>base64</tt>.
def binary?
@encoding == 'base64'
end
# MIME types can be specified to be sent across a network in particular
# formats. This method returns +false+ when the MIME type encoding is
# set to <tt>base64</tt>.
def ascii?
not binary?
end
# Returns +true+ when the simplified MIME type is in the list of known
# digital signatures.
def signature?
SIGNATURES.include?(@simplified.downcase)
end
# Returns +true+ if the MIME::Type is specific to an operating system.
def system?
not @system.nil?
end
# Returns +true+ if the MIME::Type is specific to the current operating
# system as represented by RUBY_PLATFORM.
def platform?
system? and (RUBY_PLATFORM =~ @system)
end
# Returns +true+ if the MIME::Type specifies an extension list,
# indicating that it is a complete MIME::Type.
def complete?
not @extensions.empty?
end
# Returns the MIME type as a string.
def to_s
@content_type
end
# Returns the MIME type as a string for implicit conversions.
def to_str
@content_type
end
# Returns the MIME type as an array suitable for use with
# MIME::Type.from_array.
def to_a
[@content_type, @extensions, @encoding, @system]
end
# Returns the MIME type as an array suitable for use with
# MIME::Type.from_hash.
def to_hash
{ 'Content-Type' => @content_type,
'Content-Transfer-Encoding' => @encoding,
'Extensions' => @extensions,
'System' => @system }
end
end
end

Просмотреть файл

@ -0,0 +1,925 @@
# :title: MIME::Types
# :main: MIME::Types
#--
# MIME::Types for Ruby
# Version 1.13.1
#
# Copyright (c) 2002 - 2004 Austin Ziegler
#
# $Id$
#
# The ChangeLog contains all details on revisions.
#++
require 'mime/type'
module MIME #:nodoc:
# = Introduction
#
# MIME types are used in MIME-compliant communications, as in e-mail or
# HTTP traffic, to indicate the type of content which is transmitted.
# MIME::Types provides the ability for detailed information about MIME
# entities (provided as a set of MIME::Type objects) )to be determined and
# used programmatically. There are many types defined by RFCs and vendors,
# so the list is long but not complete; don't hesitate to ask to add
# additional information. This library follows the IANA collection of MIME
# types (see below for reference).
#
# = Description
# MIME types are used in MIME entities, as in email or HTTP traffic. It is
# useful at times to have information available about MIME types (or,
# inversely, about files). A MIME::Type stores the known information about
# one MIME type.
#
# == Synopsis
# require 'mime/types'
#
# plaintext = MIME::Types['text/plain']
# print plaintext.media_type # => 'text'
# print plaintext.sub_type # => 'plain'
#
# puts plaintext.extensions.join(" ") # => 'asc txt c cc h hh cpp'
#
# puts plaintext.encoding # => 8bit
# puts plaintext.binary? # => false
# puts plaintext.ascii? # => true
# puts plaintext == 'text/plain' # => true
# puts MIME::Type.simplified('x-appl/x-zip') # => 'appl/zip'
#
# This module is built to conform to the MIME types of RFC's 2045 and 2231.
# It follows the official IANA registry at
# http://www.iana.org/assignments/media-types/ and
# ftp://ftp.iana.org/in-notes/iana/assignments/media-types/ and the
# collection kept at http://www.ltsw.se/knbase/internet/mime.htp
#
# This is originally based on Perl MIME::Types.
#
# = Author
#
# Copyright:: Copyright (c) 2002 - 2004 by Austin Ziegler
# <mime-types@halostatue.ca>
# Version:: 1.13.1
# Based On:: Perl
# MIME::Types[http://search.cpan.org/author/MARKOV/MIME-Types-1.13/MIME/Types.pm],
# Copyright (c) 2001-2004 by Mark Overmeer
# <mimetypes@overmeer.net>.
# Licence:: Ruby's, Perl Artistic, or GPL version 2 (or later)
# See Also:: http://www.iana.org/assignments/media-types/
# http://www.ltsw.se/knbase/internet/mime.htp
#
module Types
# The released version of Ruby MIME::Types
VERSION = '1.13.1'
# The version of the data.
DATA_VERSION = '1.13'
TYPE_VARIANTS = Hash.new { |h, k| h[k] = [] } #:nodoc:
EXTENSION_INDEX = Hash.new { |h, k| h[k] = [] } #:nodoc:
class <<self
def add_type_variant(mime_type) #:nodoc:
TYPE_VARIANTS[mime_type.simplified] << mime_type
end
def index_extensions(mime_type) #:nodoc:
mime_type.extensions.each do |ext|
EXTENSION_INDEX[ext] << mime_type
end
end
# Returns a list of MIME::Type objects, which may be empty. The optional
# flag parameters are :complete (finds only complete MIME::Types) and
# :platform (finds only MIME::Types for the current platform). It is
# possible for multiple matches to be returned for either type (in the
# example below, 'text/plain' returns two values -- one for the general
# case, and one for VMS systems.
#
# puts "\nMIME::Types['text/plain']"
# MIME::Types['text/plain'].each { |t| puts t.to_a.join(", ") }
#
# puts "\nMIME::Types[/^image/, :complete => true]"
# MIME::Types[/^image/, :complete => true].each do |t|
# puts t.to_a.join(", ")
# end
def [](type_id, flags = {})
if type_id.kind_of?(Regexp)
matches = []
TYPE_VARIANTS.each_key { |k| matches << TYPE_VARIANTS[k] if k =~ type_id }
matches.flatten!
elsif type_id.kind_of?(MIME::Type)
matches = [type_id]
else
matches = TYPE_VARIANTS[MIME::Type.simplified(type_id)]
end
matches.delete_if { |e| not e.complete? } if flags[:complete]
matches.delete_if { |e| not e.platform? } if flags[:platform]
matches
end
# Return the list of MIME::Types which belongs to the file based on
# its filename extension. If +platform+ is +true+, then only file
# types that are specific to the current platform will be returned.
#
# puts "MIME::Types.type_for('citydesk.xml') => "#{MIME::Types.type_for('citydesk.xml')}"
# puts "MIME::Types.type_for('citydesk.gif') => "#{MIME::Types.type_for('citydesk.gif')}"
def type_for(filename, platform = false)
ext = filename.chomp.downcase.gsub(/.*\./o, '')
list = EXTENSION_INDEX[ext]
list.delete_if { |e| not e.platform? } if platform
list
end
# A synonym for MIME::Types.type_for
def of(filename, platform = false)
Types.type_for(filename, platform)
end
# Add one or more MIME::Type objects to the set of known types.
# Each type should be experimental (e.g., 'application/x-ruby'). If the
# type is already known, a warning will be displayed.
#
# <b>Please inform the maintainer of this module when registered
# types are missing.</b>
def add(*types)
types.each do |mime_type|
if TYPE_VARIANTS.include?(mime_type.simplified)
if TYPE_VARIANTS[mime_type.simplified].include?(mime_type)
warn "Type #{mime_type} already registered as a variant of #{mime_type.simplified}."
end
end
MIME::Types.add_type_variant(mime_type)
MIME::Types.index_extensions(mime_type)
end
end
# Returns an array of hashes of simplified MIME types and encodings
# for the specified filename extension.
#
# Not currently unit tested -- the implementation purpose is as yet
# unclear.
def by_suffix(filename, platform = false)
mime = Types.of(filename, platform)
data = mime.inject([]) { |d, mt| d << { mt.content_type => mt.encoding } }
end
# Returns an array of hashes of MIME types by extension based on
# lookup of the MIME type.
#
# Not currently unit tested -- the implementation purpose is as yet
# unclear.
def by_mediatype(mime_type)
if mime_type["/"] or mime_type.kind_of?(Regexp)
found = MIME::Types[mime_type]
else
found = MIME::Types[%r{mime_type}]
end
data = found.inject([]) do |d, mt|
d << mt.extensions.map { |e| { e => { mt.content_type => mt.encoding } } }
end
data.flatten
end
end
end
end
# Build the type list
data_mime_type = <<MIME_TYPES
application/activemessage
application/andrew-inset ez
application/appledouble base64
application/applefile base64
application/atomicmail
application/batch-SMTP
application/beep+xml
application/cals-1840
application/cnrp+xml
application/commonground
application/cpl+xml
application/cybercash
application/DCA-RFT
application/DEC-DX
application/dicom
application/dvcs
application/EDI-Consent
application/EDIFACT
application/EDI-X12
application/eshop
application/font-tdpfr pfr
application/http
application/hyperstudio stk
application/iges
application/index
application/index.cmd
application/index.obj
application/index.response
application/index.vnd
application/iotp
application/ipp
application/isup
application/mac-binhex40 hqx 8bit
application/macwriteii
application/marc
application/mathematica
application/mpeg4-generic
application/news-message-id
application/news-transmission
application/ocsp-request orq
application/ocsp-response ors
application/octet-stream bin,dms,lha,lzh,exe,class,ani,pgp base64
application/oda oda
application/ogg ogg
application/parityfec
application/pdf pdf base64
application/pgp-encrypted 7bit
application/pgp-keys 7bit
application/pgp-signature sig base64
application/pidf+xml
application/pkcs10 p10
application/pkcs7-mime p7m,p7c
application/pkcs7-signature p7s
application/pkix-cert cer
application/pkixcmp pki
application/pkix-crl crl
application/pkix-pkipath pkipath
application/postscript ai,eps,ps 8bit
application/postscript ps-z base64
application/prs.alvestrand.titrax-sheet
application/prs.cww cw,cww
application/prs.nprend rnd,rct
application/prs.plucker
application/qsig
application/reginfo+xml
application/remote-printing
application/riscos
application/rtf rtf 8bit
application/sdp
application/set-payment
application/set-payment-initiation
application/set-registration
application/set-registration-initiation
application/sgml
application/sgml-open-catalog soc
application/sieve siv
application/slate
application/smil smi,smil
application/timestamp-query
application/timestamp-reply
application/toolbook tbk
application/tve-trigger
application/vemmi
application/vnd.3gpp.pic-bw-large plb
application/vnd.3gpp.pic-bw-small psb
application/vnd.3gpp.pic-bw-var pvb
application/vnd.3gpp.sms sms
application/vnd.3M.Post-it-Notes
application/vnd.accpac.simply.aso
application/vnd.accpac.simply.imp
application/vnd.acucobol
application/vnd.acucorp atc,acutc 7bit
application/vnd.adobe.xfdf xfdf
application/vnd.aether.imp
application/vnd.amiga.amu ami
application/vnd.anser-web-certificate-issue-initiation
application/vnd.anser-web-funds-transfer-initiation
application/vnd.audiograph
application/vnd.blueice.multipass mpm
application/vnd.bmi
application/vnd.businessobjects
application/vnd.canon-cpdl
application/vnd.canon-lips
application/vnd.cinderella cdy
application/vnd.claymore
application/vnd.commerce-battelle
application/vnd.commonspace
application/vnd.contact.cmsg
application/vnd.cosmocaller cmc
application/vnd.criticaltools.wbs+xml wbs
application/vnd.ctc-posml
application/vnd.cups-postscript
application/vnd.cups-raster
application/vnd.cups-raw
application/vnd.curl curl
application/vnd.cybank
application/vnd.data-vision.rdz rdz
application/vnd.dna
application/vnd.dpgraph
application/vnd.dreamfactory dfac
application/vnd.dxr
application/vnd.ecdis-update
application/vnd.ecowin.chart
application/vnd.ecowin.filerequest
application/vnd.ecowin.fileupdate
application/vnd.ecowin.series
application/vnd.ecowin.seriesrequest
application/vnd.ecowin.seriesupdate
application/vnd.enliven
application/vnd.epson.esf
application/vnd.epson.msf
application/vnd.epson.quickanime
application/vnd.epson.salt
application/vnd.epson.ssf
application/vnd.ericsson.quickcall
application/vnd.eudora.data
application/vnd.fdf
application/vnd.ffsns
application/vnd.FloGraphIt
application/vnd.framemaker
application/vnd.fsc.weblauch fsc 7bit
application/vnd.fujitsu.oasys
application/vnd.fujitsu.oasys2
application/vnd.fujitsu.oasys3
application/vnd.fujitsu.oasysgp
application/vnd.fujitsu.oasysprs
application/vnd.fujixerox.ddd
application/vnd.fujixerox.docuworks
application/vnd.fujixerox.docuworks.binder
application/vnd.fut-misnet
application/vnd.genomatix.tuxedo txd
application/vnd.grafeq
application/vnd.groove-account
application/vnd.groove-help
application/vnd.groove-identity-message
application/vnd.groove-injector
application/vnd.groove-tool-message
application/vnd.groove-tool-template
application/vnd.groove-vcard
application/vnd.hbci hbci,hbc,kom,upa,pkd,bpd
application/vnd.hhe.lesson-player les
application/vnd.hp-HPGL plt,hpgl
application/vnd.hp-hpid
application/vnd.hp-hps
application/vnd.hp-PCL
application/vnd.hp-PCLXL
application/vnd.httphone
application/vnd.hzn-3d-crossword
application/vnd.ibm.afplinedata
application/vnd.ibm.electronic-media emm
application/vnd.ibm.MiniPay
application/vnd.ibm.modcap
application/vnd.ibm.rights-management irm
application/vnd.ibm.secure-container sc
application/vnd.informix-visionary
application/vnd.intercon.formnet
application/vnd.intertrust.digibox
application/vnd.intertrust.nncp
application/vnd.intu.qbo
application/vnd.intu.qfx
application/vnd.ipunplugged.rcprofile rcprofile
application/vnd.irepository.package+xml irp
application/vnd.is-xpr
application/vnd.japannet-directory-service
application/vnd.japannet-jpnstore-wakeup
application/vnd.japannet-payment-wakeup
application/vnd.japannet-registration
application/vnd.japannet-registration-wakeup
application/vnd.japannet-setstore-wakeup
application/vnd.japannet-verification
application/vnd.japannet-verification-wakeup
application/vnd.jisp jisp
application/vnd.kde.karbon karbon
application/vnd.kde.kchart chrt
application/vnd.kde.kformula kfo
application/vnd.kde.kivio flw
application/vnd.kde.kontour kon
application/vnd.kde.kpresenter kpr,kpt
application/vnd.kde.kspread ksp
application/vnd.kde.kword kwd,kwt
application/vnd.kenameapp htke
application/vnd.kidspiration kia
application/vnd.Kinar kne,knp,sdf
application/vnd.koan
application/vnd.liberty-request+xml
application/vnd.llamagraphics.life-balance.desktop lbd
application/vnd.llamagraphics.life-balance.exchange+xml lbe
application/vnd.lotus-1-2-3 wks,123
application/vnd.lotus-approach
application/vnd.lotus-freelance
application/vnd.lotus-notes
application/vnd.lotus-organizer
application/vnd.lotus-screencam
application/vnd.lotus-wordpro
application/vnd.mcd mcd
application/vnd.mediastation.cdkey
application/vnd.meridian-slingshot
application/vnd.micrografx.flo flo
application/vnd.micrografx.igx igx
application/vnd.mif mif
application/vnd.minisoft-hp3000-save
application/vnd.mitsubishi.misty-guard.trustweb
application/vnd.Mobius.DAF
application/vnd.Mobius.DIS
application/vnd.Mobius.MBK
application/vnd.Mobius.MQY
application/vnd.Mobius.MSL
application/vnd.Mobius.PLC
application/vnd.Mobius.TXF
application/vnd.mophun.application mpn
application/vnd.mophun.certificate mpc
application/vnd.motorola.flexsuite
application/vnd.motorola.flexsuite.adsi
application/vnd.motorola.flexsuite.fis
application/vnd.motorola.flexsuite.gotap
application/vnd.motorola.flexsuite.kmr
application/vnd.motorola.flexsuite.ttc
application/vnd.motorola.flexsuite.wem
application/vnd.mozilla.xul+xml xul
application/vnd.ms-artgalry cil
application/vnd.ms-asf asf
application/vnd.mseq mseq
application/vnd.ms-excel xls,xlt base64
application/vnd.msign
application/vnd.ms-lrm lrm
application/vnd.ms-powerpoint ppt,pps,pot base64
application/vnd.ms-project mpp base64
application/vnd.ms-tnef base64
application/vnd.ms-works base64
application/vnd.ms-wpl wpl base64
application/vnd.musician
application/vnd.music-niff
application/vnd.nervana ent,entity,req,request,bkm,kcm
application/vnd.netfpx
application/vnd.noblenet-directory
application/vnd.noblenet-sealer
application/vnd.noblenet-web
application/vnd.nokia.radio-preset rpst
application/vnd.nokia.radio-presets rpss
application/vnd.novadigm.EDM
application/vnd.novadigm.EDX
application/vnd.novadigm.EXT
application/vnd.obn
application/vnd.osa.netdeploy
application/vnd.palm prc,pdb,pqa,oprc
application/vnd.paos.xml
application/vnd.pg.format
application/vnd.pg.osasli
application/vnd.picsel efif
application/vnd.powerbuilder6
application/vnd.powerbuilder6-s
application/vnd.powerbuilder7
application/vnd.powerbuilder75
application/vnd.powerbuilder75-s
application/vnd.powerbuilder7-s
application/vnd.previewsystems.box
application/vnd.publishare-delta-tree
application/vnd.pvi.ptid1 pti,ptid
application/vnd.pwg-multiplexed
application/vnd.pwg-xmhtml-print+xml
application/vnd.Quark.QuarkXPress qxd,qxt,qwd,qwt,qxl,qxb 8bit
application/vnd.rapid
application/vnd.renlearn.rlprint
application/vnd.s3sms
application/vnd.sealed.doc sdoc,sdo,s1w
application/vnd.sealed.eml seml,sem
application/vnd.sealedmedia.softseal.html stml,stm,s1h
application/vnd.sealedmedia.softseal.pdf spdf,spd,s1a
application/vnd.sealed.mht smht,smh
application/vnd.sealed.net
application/vnd.sealed.ppt sppt,spp,s1p
application/vnd.sealed.xls sxls,sxl,s1e
application/vnd.seemail see
application/vnd.shana.informed.formdata
application/vnd.shana.informed.formtemplate
application/vnd.shana.informed.interchange
application/vnd.shana.informed.package
application/vnd.smaf mmf
application/vnd.sss-cod
application/vnd.sss-dtf
application/vnd.sss-ntf
application/vnd.street-stream
application/vnd.sus-calendar sus,susp
application/vnd.svd
application/vnd.swiftview-ics
application/vnd.syncml.ds.notification
application/vnd.triscape.mxs
application/vnd.trueapp
application/vnd.truedoc
application/vnd.ufdl
application/vnd.uiq.theme
application/vnd.uplanet.alert
application/vnd.uplanet.alert-wbxml
application/vnd.uplanet.bearer-choice
application/vnd.uplanet.bearer-choice-wbxml
application/vnd.uplanet.cacheop
application/vnd.uplanet.cacheop-wbxml
application/vnd.uplanet.channel
application/vnd.uplanet.channel-wbxml
application/vnd.uplanet.list
application/vnd.uplanet.listcmd
application/vnd.uplanet.listcmd-wbxml
application/vnd.uplanet.list-wbxml
application/vnd.uplanet.signal
application/vnd.vcx
application/vnd.vectorworks
application/vnd.vidsoft.vidconference vsc 8bit
application/vnd.visionary vis
application/vnd.visio vsd,vst,vsw,vss
application/vnd.vividence.scriptfile
application/vnd.vsf
application/vnd.wap.sic sic
application/vnd.wap.slc slc
application/vnd.wap.wbxml wbxml
application/vnd.wap.wmlc wmlc
application/vnd.wap.wmlscriptc wmlsc
application/vnd.webturbo wtb
application/vnd.wordperfect wpd
application/vnd.wqd wqd
application/vnd.wrq-hp3000-labelled
application/vnd.wt.stf
application/vnd.wv.csp+wbxml wv
application/vnd.wv.csp+xml 8bit
application/vnd.wv.ssp+xml 8bit
application/vnd.xara
application/vnd.xfdl
application/vnd.yamaha.hv-dic hvd
application/vnd.yamaha.hv-script hvs
application/vnd.yamaha.hv-voice hvp
application/vnd.yamaha.smaf-audio saf
application/vnd.yamaha.smaf-phrase spf
application/vnd.yellowriver-custom-menu
application/watcherinfo+xml wif
application/whoispp-query
application/whoispp-response
application/wita
application/wordperfect5.1 wp5,wp
application/x-123 wk
application/x-access
application/x-bcpio bcpio
application/x-bleeper bleep base64
application/x-bzip2 bz2
application/x-cdlink vcd
application/x-chess-pgn pgn
application/x-clariscad
application/x-compress z,Z base64
application/x-cpio cpio base64
application/x-csh csh 8bit
application/x-cu-seeme csm,cu
application/x-debian-package deb
application/x-director dcr,dir,dxr
application/x-drafting
application/x-dvi dvi base64
application/x-dxf
application/x-excel
application/x-fractals
application/x-futuresplash spl
application/x-ghostview
application/x-gtar gtar,tgz,tbz2,tbz base64
application/x-gunzip
application/x-gzip gz base64
application/x-hdf hdf
application/x-hep hep
application/x-html+ruby rhtml 8bit
application/xhtml+xml xhtml 8bit
application/x-httpd-php phtml,pht,php 8bit
application/x-ica ica
application/x-ideas
application/x-imagemap imagemap,imap 8bit
application/x-java-archive jar
application/x-java-jnlp-file jnlp
application/x-javascript js 8bit
application/x-java-serialized-object ser
application/x-java-vm class
application/x-koan skp,skd,skt,skm
application/x-latex latex 8bit
application/x-lotus-123
application/x-mac-compactpro cpt
application/x-maker frm,maker,frame,fm,fb,book,fbdoc
application/x-mathcad
application/x-mif mif
application/xml
application/xml-dtd
application/xml-external-parsed-entity
application/x-msaccess mda,mdb,mde,mdf base64
application/x-msdos-program cmd,bat 8bit
application/x-msdos-program com,exe base64
application/x-msdownload base64
application/x-msword doc,dot,wrd base64
application/x-netcdf nc,cdf
application/x-ns-proxy-autoconfig pac
application/x-pagemaker pm5,pt5,pm
application/x-perl pl,pm 8bit
application/x-pgp
application/x-python py 8bit
application/x-quicktimeplayer qtl
application/x-rar-compressed rar base64
application/x-remote_printing
application/x-ruby rb,rbw 8bit
application/x-set
application/x-shar shar 8bit
application/x-shockwave-flash swf
application/x-sh sh 8bit
application/x-SLA
application/x-solids
application/x-spss sav,sbs,sps,spo,spp
application/x-stuffit sit base64
application/x-sv4cpio sv4cpio base64
application/x-sv4crc sv4crc base64
application/x-tar tar base64
application/x-tcl tcl 8bit
application/x-texinfo texinfo,texi 8bit
application/x-tex tex 8bit
application/x-troff-man man 8bit
application/x-troff-me me
application/x-troff-ms ms
application/x-troff t,tr,roff 8bit
application/x-ustar ustar base64
application/x-vda
application/x-VMSBACKUP bck base64
application/x-wais-source src
application/x-Wingz wz
application/x-word base64
application/x-wordperfect6.1 wp6
application/x-x400-bp
application/x-x509-ca-cert crt base64
application/zip zip base64
applivation/vnd.fints
audio/32kadpcm
audio/AMR amr base64
audio/AMR-WB awb base64
audio/basic au,snd base64
audio/CN
audio/DAT12
audio/dsr-es201108
audio/DVI4
audio/EVRC0
audio/EVRC evc
audio/EVRC-QCP
audio/G722
audio/G.722.1
audio/G723
audio/G726-16
audio/G726-24
audio/G726-32
audio/G726-40
audio/G728
audio/G729
audio/G729D
audio/G729E
audio/GSM
audio/GSM-EFR
audio/L16 l16
audio/L20
audio/L24
audio/L8
audio/LPC
audio/MP4A-LATM
audio/MPA
audio/mpa-robust
audio/mpeg4-generic
audio/mpeg mpga,mp2,mp3 base64
audio/parityfec
audio/PCMA
audio/PCMU
audio/prs.sid sid,psid
audio/QCELP qcp
audio/RED
audio/SMV0
audio/SMV-QCP
audio/SMV smv
audio/telephone-event
audio/tone
audio/VDVI
audio/vnd.3gpp.iufp
audio/vnd.audiokoz koz
audio/vnd.cisco.nse
audio/vnd.cns.anp1
audio/vnd.cns.inf1
audio/vnd.digital-winds eol 7bit
audio/vnd.everad.plj plj
audio/vnd.lucent.voice lvp
audio/vnd.nokia.mobile-xmf mxmf
audio/vnd.nortel.vbk vbk
audio/vnd.nuera.ecelp4800 ecelp4800
audio/vnd.nuera.ecelp7470 ecelp7470
audio/vnd.nuera.ecelp9600 ecelp9600
audio/vnd.octel.sbc
audio/vnd.qcelp
audio/vnd.rhetorex.32kadpcm
audio/vnd.sealedmedia.softseal.mpeg smp3,smp,s1m
audio/vnd.vmx.cvsd
audio/x-aiff aif,aifc,aiff base64
audio/x-midi mid,midi,kar base64
audio/x-pn-realaudio-plugin rpm
audio/x-pn-realaudio rm,ram base64
audio/x-realaudio ra base64
audio/x-wav wav base64
chemical/x-pdb pdb
chemical/x-xyz xyz
drawing/dwf dwf
image/cgm
image/g3fax
image/gif gif base64
image/ief ief base64
image/jp2 jp2,jpg2
image/jpeg jpeg,jpg,jpe base64
image/jpm jpm,jpgm
image/jpx jpf,jpx
image/naplps
image/png png base64
image/prs.btif
image/prs.pti
image/t38
image/targa tga
image/tiff-fx
image/tiff tiff,tif base64
image/vnd.cns.inf2
image/vnd.dgn dgn
image/vnd.djvu djvu,djv
image/vnd.dwg dwg
image/vnd.dxf
image/vnd.fastbidsheet
image/vnd.fpx
image/vnd.fst
image/vnd.fujixerox.edmics-mmr
image/vnd.fujixerox.edmics-rlc
image/vnd.glocalgraphics.pgb pgb
image/vnd.microsoft.icon ico
image/vnd.mix
image/vnd.ms-modi mdi
image/vnd.net-fpx
image/vnd.sealedmedia.softseal.gif sgif,sgi,s1g
image/vnd.sealedmedia.softseal.jpg sjpg,sjp,s1j
image/vnd.sealed.png spng,spn,s1n
image/vnd.svf
image/vnd.wap.wbmp wbmp
image/vnd.xiff
image/x-bmp bmp
image/x-cmu-raster ras
image/x-portable-anymap pnm base64
image/x-portable-bitmap pbm base64
image/x-portable-graymap pgm base64
image/x-portable-pixmap ppm base64
image/x-rgb rgb base64
image/x-xbitmap xbm 7bit
image/x-xpixmap xpm 8bit
image/x-xwindowdump xwd base64
message/CPIM
message/delivery-status
message/disposition-notification
message/external-body 8bit
message/http
message/news 8bit
message/partial 8bit
message/rfc822 8bit
message/s-http
message/sip
message/sipfrag
model/iges igs,iges
model/mesh msh,mesh,silo
model/vnd.dwf
model/vnd.flatland.3dml
model/vnd.gdl
model/vnd.gs-gdl
model/vnd.gtw
model/vnd.mts
model/vnd.parasolid.transmit.binary x_b,xmt_bin
model/vnd.parasolid.transmit.text x_t,xmt_txt quoted-printable
model/vnd.vtu
model/vrml wrl,vrml
multipart/alternative 8bit
multipart/appledouble 8bit
multipart/byteranges
multipart/digest 8bit
multipart/encrypted
multipart/form-data
multipart/header-set
multipart/mixed 8bit
multipart/parallel 8bit
multipart/related
multipart/report
multipart/signed
multipart/voice-message
multipart/x-gzip
multipart/x-mixed-replace
multipart/x-tar
multipart/x-ustar
multipart/x-www-form-urlencoded
multipart/x-zip
text/calendar
text/comma-separated-values csv 8bit
text/css css 8bit
text/directory
text/enriched
text/html html,htm,htmlx,shtml,htx 8bit
text/parityfec
text/plain txt,asc,c,cc,h,hh,cpp,hpp,dat,hlp 8bit
text/prs.fallenstein.rst rst
text/prs.lines.tag
text/rfc822-headers
text/richtext rtx 8bit
text/rtf rtf 8bit
text/sgml sgml,sgm
text/t140
text/tab-separated-values tsv
text/uri-list
text/vnd.abc
text/vnd.curl
text/vnd.DMClientScript
text/vnd.flatland.3dml
text/vnd.fly
text/vnd.fmi.flexstor
text/vnd.in3d.3dml
text/vnd.in3d.spot
text/vnd.IPTC.NewsML
text/vnd.IPTC.NITF
text/vnd.latex-z
text/vnd.motorola.reflex
text/vnd.ms-mediapackage
text/vnd.net2phone.commcenter.command ccc
text/vnd.sun.j2me.app-descriptor jad 8bit
text/vnd.wap.si si
text/vnd.wap.sl sl
text/vnd.wap.wmlscript wmls
text/vnd.wap.wml wml
text/xml-external-parsed-entity
text/xml xml,dtd 8bit
text/x-setext etx
text/x-sgml sgml,sgm 8bit
text/x-vCalendar vcs 8bit
text/x-vCard vcf 8bit
video/BMPEG
video/BT656
video/CelB
video/dl dl base64
video/DV
video/gl gl base64
video/H261
video/H263
video/H263-1998
video/H263-2000
video/JPEG
video/mj2 mj2,mjp2
video/MP1S
video/MP2P
video/MP2T
video/MP4V-ES
video/mpeg4-generic
video/mpeg mp2,mpe,mpeg,mpg base64
video/MPV
video/nv
video/parityfec
video/pointer
video/quicktime qt,mov base64
video/SMPTE292M
video/vnd.fvt fvt
video/vnd.motorola.video
video/vnd.motorola.videop
video/vnd.mpegurl mxu,m4u 8bit
video/vnd.nokia.interleaved-multimedia nim
video/vnd.objectvideo mp4
video/vnd.sealedmedia.softseal.mov smov,smo,s1q
video/vnd.sealed.mpeg1 s11
video/vnd.sealed.mpeg4 smpg,s14
video/vnd.sealed.swf sswf,ssw
video/vnd.vivo viv,vivo
video/x-fli fli base64
video/x-ms-asf asf,asx
video/x-msvideo avi base64
video/x-sgi-movie movie base64
x-chemical/x-pdb pdb
x-chemical/x-xyz xyz
x-conference/x-cooltalk ice
x-drawing/dwf dwf
x-world/x-vrml wrl,vrml
# Exceptions
vms:text/plain doc 8bit
mac:application/x-macbase64 bin
MIME_TYPES
os_re = %r{^(\w+):}o
data_mime_type.each do |i|
item = i.chomp.strip.gsub(%r{#.*}o, '')
next if item.empty?
match = os_re.match(item)
if match
os = match.captures[0]
item.gsub!(os_re, '')
else
os = nil
end
type, extensions, encoding = item.split
if encoding.nil? and extensions and (extensions =~ MIME::Type::ENCODING_RE)
encoding = extensions
extensions = nil
end
extensions &&= extensions.split(%r{,}o)
mime_type = MIME::Type.new(type) do |t|
t.extensions = extensions
t.system = os
t.encoding = encoding
end
MIME::Types.add_type_variant(mime_type)
MIME::Types.index_extensions(mime_type)
end
# Reduce memory consumption.
os_re = nil
data_mime_type = nil

Просмотреть файл

@ -0,0 +1,40 @@
Gem::Specification.new do |s|
s.name = %q{mime-types}
s.version = %q{1.13.1}
s.summary = %q{Manages a MIME Content-Type that will return the Content-Type for a given filename.}
s.platform = Gem::Platform::RUBY
s.has_rdoc = true
s.test_suite_file = %w{tests/tests.rb}
s.autorequire = %q{mime/types}
s.require_paths = %w{lib}
s.files = Dir.glob("**/*").delete_if do |item|
item.include?("CVS") or item.include?(".svn") or
item == "install.rb" or item =~ /~$/ or
item =~ /gem(?:spec)?$/
end
s.author = %q{Austin Ziegler}
s.email = %q{mime-types@halostatue.ca}
s.homepage = %q{http://www.halostatue.ca/ruby/Mime__Types.html}
s.description = <<-EOS
Mime::Types README
This is release 1.13 of MIME::Types for Ruby, based on the Perl package of the
same name. It is generally kept in sync with the Perl version of MIME::Types.
This package works on the same concept as mailcap, which uses filename
extensions to determine the file's likely MIME content type. This package does
not analyse files for magic bytes to determine the appropriate actual MIME
content type.
Copyright © 2002 - 2004 Austin Ziegler
Based on prior work copyright © Mark Overmeer
This package is licensed under Ruby's licence, the Perl Artistic licence, or
the GPL version 2 or later.
EOS
end

Просмотреть файл

@ -0,0 +1,324 @@
$:.unshift '../lib' if __FILE__ == $0 # Make this library first!
require 'mime/types'
require 'test/unit'
class TestMIME__Type < Test::Unit::TestCase #:nodoc:
def setup
@zip = MIME::Type.new('x-appl/x-zip') { |t| t.extensions = ['zip', 'zp'] }
end
def test_CMP # '<=>'
assert(MIME::Type.new('text/plain') == MIME::Type.new('text/plain'))
assert(MIME::Type.new('text/plain') != MIME::Type.new('image/jpeg'))
assert(MIME::Type.new('text/plain') == 'text/plain')
assert(MIME::Type.new('text/plain') != 'image/jpeg')
assert(MIME::Type.new('text/plain') > MIME::Type.new('text/html'))
assert(MIME::Type.new('text/plain') > 'text/html')
assert(MIME::Type.new('text/html') < MIME::Type.new('text/plain'))
assert(MIME::Type.new('text/html') < 'text/plain')
assert('text/html' == MIME::Type.new('text/html'))
assert('text/html' < MIME::Type.new('text/plain'))
assert('text/plain' > MIME::Type.new('text/html'))
end
def test_ascii?
assert(MIME::Type.new('text/plain').ascii?)
assert(!MIME::Type.new('image/jpeg').ascii?)
assert(!MIME::Type.new('application/x-msword').ascii?)
assert(MIME::Type.new('text/vCard').ascii?)
assert(!MIME::Type.new('application/pkcs7-mime').ascii?)
assert(!@zip.ascii?)
end
def test_binary?
assert(!MIME::Type.new('text/plain').binary?)
assert(MIME::Type.new('image/jpeg').binary?)
assert(MIME::Type.new('application/x-msword').binary?)
assert(!MIME::Type.new('text/vCard').binary?)
assert(MIME::Type.new('application/pkcs7-mime').binary?)
assert(@zip.binary?)
end
def test_complete?
assert_nothing_raised do
@yaml = MIME::Type.from_array('text/x-yaml', ['yaml', 'yml'], '8bit',
'linux')
end
assert(@yaml.complete?)
assert_nothing_raised { @yaml.extensions = nil }
assert(!@yaml.complete?)
end
def test_content_type
assert_equal(MIME::Type.new('text/plain').content_type, 'text/plain')
assert_equal(MIME::Type.new('image/jpeg').content_type, 'image/jpeg')
assert_equal(MIME::Type.new('application/x-msword').content_type, 'application/x-msword')
assert_equal(MIME::Type.new('text/vCard').content_type, 'text/vCard')
assert_equal(MIME::Type.new('application/pkcs7-mime').content_type, 'application/pkcs7-mime')
assert_equal(@zip.content_type, 'x-appl/x-zip');
end
def test_encoding
assert_equal(MIME::Type.new('text/plain').encoding, 'quoted-printable')
assert_equal(MIME::Type.new('image/jpeg').encoding, 'base64')
assert_equal(MIME::Type.new('application/x-msword').encoding, 'base64')
assert_equal(MIME::Type.new('text/vCard').encoding, 'quoted-printable')
assert_equal(MIME::Type.new('application/pkcs7-mime').encoding, 'base64')
assert_nothing_raised do
@yaml = MIME::Type.from_array('text/x-yaml', ['yaml', 'yml'], '8bit',
'linux')
end
assert_equal(@yaml.encoding, '8bit')
assert_nothing_raised { @yaml.encoding = 'base64' }
assert_equal(@yaml.encoding, 'base64')
assert_nothing_raised { @yaml.encoding = :default }
assert_equal(@yaml.encoding, 'quoted-printable')
assert_raises(ArgumentError) { @yaml.encoding = 'binary' }
assert_equal(@zip.encoding, 'base64')
end
def test_eql?
assert(MIME::Type.new('text/plain').eql?(MIME::Type.new('text/plain')))
assert(!MIME::Type.new('text/plain').eql?(MIME::Type.new('image/jpeg')))
assert(!MIME::Type.new('text/plain').eql?('text/plain'))
assert(!MIME::Type.new('text/plain').eql?('image/jpeg'))
end
def test_extensions
assert_nothing_raised do
@yaml = MIME::Type.from_array('text/x-yaml', ['yaml', 'yml'], '8bit',
'linux')
end
assert_equal(@yaml.extensions, ['yaml', 'yml'])
assert_nothing_raised { @yaml.extensions = 'yaml' }
assert_equal(@yaml.extensions, ['yaml'])
assert_equal(@zip.extensions.size, 2)
assert_equal(@zip.extensions, ['zip', 'zp'])
end
def test_like?
assert(MIME::Type.new('text/plain').like?(MIME::Type.new('text/plain')))
assert(MIME::Type.new('text/plain').like?(MIME::Type.new('text/x-plain')))
assert(!MIME::Type.new('text/plain').like?(MIME::Type.new('image/jpeg')))
assert(MIME::Type.new('text/plain').like?('text/plain'))
assert(MIME::Type.new('text/plain').like?('text/x-plain'))
assert(!MIME::Type.new('text/plain').like?('image/jpeg'))
end
def test_media_type
assert_equal(MIME::Type.new('text/plain').media_type, 'text')
assert_equal(MIME::Type.new('image/jpeg').media_type, 'image')
assert_equal(MIME::Type.new('application/x-msword').media_type, 'application')
assert_equal(MIME::Type.new('text/vCard').media_type, 'text')
assert_equal(MIME::Type.new('application/pkcs7-mime').media_type, 'application')
assert_equal(MIME::Type.new('x-chemical/x-pdb').media_type, 'chemical')
assert_equal(@zip.media_type, 'appl')
end
def test_platform?
assert_nothing_raised do
@yaml = MIME::Type.from_array('text/x-yaml', ['yaml', 'yml'], '8bit',
'oddbox')
end
assert(!@yaml.platform?)
assert_nothing_raised { @yaml.system = nil }
assert(!@yaml.platform?)
assert_nothing_raised { @yaml.system = /#{RUBY_PLATFORM}/ }
assert(@yaml.platform?)
end
def test_raw_media_type
assert_equal(MIME::Type.new('text/plain').raw_media_type, 'text')
assert_equal(MIME::Type.new('image/jpeg').raw_media_type, 'image')
assert_equal(MIME::Type.new('application/x-msword').raw_media_type, 'application')
assert_equal(MIME::Type.new('text/vCard').raw_media_type, 'text')
assert_equal(MIME::Type.new('application/pkcs7-mime').raw_media_type, 'application')
assert_equal(MIME::Type.new('x-chemical/x-pdb').raw_media_type, 'x-chemical')
assert_equal(@zip.raw_media_type, 'x-appl')
end
def test_raw_sub_type
assert_equal(MIME::Type.new('text/plain').raw_sub_type, 'plain')
assert_equal(MIME::Type.new('image/jpeg').raw_sub_type, 'jpeg')
assert_equal(MIME::Type.new('application/x-msword').raw_sub_type, 'x-msword')
assert_equal(MIME::Type.new('text/vCard').raw_sub_type, 'vCard')
assert_equal(MIME::Type.new('application/pkcs7-mime').raw_sub_type, 'pkcs7-mime')
assert_equal(@zip.raw_sub_type, 'x-zip')
end
def test_registered?
assert(MIME::Type.new('text/plain').registered?)
assert(MIME::Type.new('image/jpeg').registered?)
assert(!MIME::Type.new('application/x-msword').registered?)
assert(MIME::Type.new('text/vCard').registered?)
assert(MIME::Type.new('application/pkcs7-mime').registered?)
assert(!@zip.registered?)
end
def test_signature?
assert(!MIME::Type.new('text/plain').signature?)
assert(!MIME::Type.new('image/jpeg').signature?)
assert(!MIME::Type.new('application/x-msword').signature?)
assert(MIME::Type.new('text/vCard').signature?)
assert(MIME::Type.new('application/pkcs7-mime').signature?)
end
def test_simplified
assert_equal(MIME::Type.new('text/plain').simplified, 'text/plain')
assert_equal(MIME::Type.new('image/jpeg').simplified, 'image/jpeg')
assert_equal(MIME::Type.new('application/x-msword').simplified, 'application/msword')
assert_equal(MIME::Type.new('text/vCard').simplified, 'text/vcard')
assert_equal(MIME::Type.new('application/pkcs7-mime').simplified, 'application/pkcs7-mime')
assert_equal(MIME::Type.new('x-chemical/x-pdb').simplified, 'chemical/pdb')
end
def test_sub_type
assert_equal(MIME::Type.new('text/plain').sub_type, 'plain')
assert_equal(MIME::Type.new('image/jpeg').sub_type, 'jpeg')
assert_equal(MIME::Type.new('application/x-msword').sub_type, 'msword')
assert_equal(MIME::Type.new('text/vCard').sub_type, 'vcard')
assert_equal(MIME::Type.new('application/pkcs7-mime').sub_type, 'pkcs7-mime')
assert_equal(@zip.sub_type, 'zip')
end
def test_system
assert_nothing_raised do
@yaml = MIME::Type.from_array('text/x-yaml', ['yaml', 'yml'], '8bit',
'linux')
end
assert_equal(@yaml.system, %r{linux})
assert_nothing_raised { @yaml.system = /win32/ }
assert_equal(@yaml.system, %r{win32})
assert_nothing_raised { @yaml.system = nil }
assert_nil(@yaml.system)
end
def test_system?
assert_nothing_raised do
@yaml = MIME::Type.from_array('text/x-yaml', ['yaml', 'yml'], '8bit',
'linux')
end
assert(@yaml.system?)
assert_nothing_raised { @yaml.system = nil }
assert(!@yaml.system?)
end
def test_to_a
assert_nothing_raised do
@yaml = MIME::Type.from_array('text/x-yaml', ['yaml', 'yml'], '8bit',
'linux')
end
assert_equal(@yaml.to_a, ['text/x-yaml', ['yaml', 'yml'], '8bit', /linux/])
end
def test_to_hash
assert_nothing_raised do
@yaml = MIME::Type.from_array('text/x-yaml', ['yaml', 'yml'], '8bit',
'linux')
end
assert_equal(@yaml.to_hash,
{ 'Content-Type' => 'text/x-yaml',
'Content-Transfer-Encoding' => '8bit',
'Extensions' => ['yaml', 'yml'], 'System' => /linux/ })
end
def test_to_s
assert_equal("#{MIME::Type.new('text/plain')}", 'text/plain')
end
def test_s_constructors
assert_not_nil(@zip)
yaml = MIME::Type.from_array('text/x-yaml', ['yaml', 'yml'], '8bit',
'linux')
assert_instance_of(MIME::Type, yaml)
yaml = MIME::Type.from_hash('Content-Type' => 'text/x-yaml',
'Content-Transfer-Encoding' => '8bit',
'System' => 'linux',
'Extensions' => ['yaml', 'yml'])
assert_instance_of(MIME::Type, yaml)
yaml = MIME::Type.new('text/x-yaml') do |y|
y.extensions = ['yaml', 'yml']
y.encoding = '8bit'
y.system = 'linux'
end
assert_instance_of(MIME::Type, yaml)
assert_raises(MIME::InvalidContentType) { MIME::Type.new('apps') }
assert_raises(MIME::InvalidContentType) { MIME::Type.new(nil) }
end
def test_s_simplified
assert_equal(MIME::Type.simplified('text/plain'), 'text/plain')
assert_equal(MIME::Type.simplified('image/jpeg'), 'image/jpeg')
assert_equal(MIME::Type.simplified('application/x-msword'), 'application/msword')
assert_equal(MIME::Type.simplified('text/vCard'), 'text/vcard')
assert_equal(MIME::Type.simplified('application/pkcs7-mime'), 'application/pkcs7-mime')
assert_equal(@zip.simplified, 'appl/zip')
assert_equal(MIME::Type.simplified('x-xyz/abc'), 'xyz/abc')
end
end
class TestMIME__Types < Test::Unit::TestCase #:nodoc:
def test_s_AREF # singleton method '[]'
text_plain = MIME::Type.new('text/plain') do |t|
t.encoding = '8bit'
t.extensions = ['asc', 'txt', 'c', 'cc', 'h', 'hh', 'cpp', 'hpp', 'dat', 'hlp']
end
text_plain_vms = MIME::Type.new('text/plain') do |t|
t.encoding = '8bit'
t.extensions = ['doc']
t.system = 'vms'
end
text_vnd_fly = MIME::Type.new('text/vnd.fly')
assert_equal(MIME::Types['text/plain'].sort,
[text_plain, text_plain_vms].sort)
assert_equal(MIME::Types[/bmp$/].sort,
[MIME::Type.from_array('image/x-bmp', ['bmp']),
MIME::Type.from_array('image/vnd.wap.wbmp', ['wbmp']),
MIME::Type.from_array('image/x-win-bmp')].sort)
assert_equal(MIME::Types[/bmp$/, { :complete => true }].sort,
[MIME::Type.from_array('image/x-bmp', ['bmp']),
MIME::Type.from_array('image/vnd.wap.wbmp', ['wbmp'])].sort)
assert_nothing_raised { MIME::Types['image/bmp'][0].system = RUBY_PLATFORM }
assert_equal(MIME::Types[/bmp$/, { :platform => true }],
[MIME::Type.from_array('image/x-bmp', ['bmp'])])
assert(MIME::Types['text/vnd.fly', { :complete => true }].empty?)
assert(!MIME::Types['text/plain', { :complete => true} ].empty?)
end
def test_s_add
assert_nothing_raised do
@eruby = MIME::Type.new("application/x-eruby") do |t|
t.extensions = "rhtml"
t.encoding = "8bit"
end
MIME::Types.add(@eruby)
end
assert_equal(MIME::Types['application/x-eruby'], [@eruby])
end
def test_s_type_for
assert_equal(MIME::Types.type_for('xml'), MIME::Types['text/xml'])
assert_equal(MIME::Types.type_for('gif'), MIME::Types['image/gif'])
assert_nothing_raised do
MIME::Types['image/gif'][0].system = RUBY_PLATFORM
end
assert_equal(MIME::Types.type_for('gif', true), MIME::Types['image/gif'])
assert(MIME::Types.type_for('zzz').empty?)
end
def test_s_of
assert_equal(MIME::Types.of('xml'), MIME::Types['text/xml'])
assert_equal(MIME::Types.of('gif'), MIME::Types['image/gif'])
assert_nothing_raised do
MIME::Types['image/gif'][0].system = RUBY_PLATFORM
end
assert_equal(MIME::Types.of('gif', true), MIME::Types['image/gif'])
assert(MIME::Types.of('zzz').empty?)
end
end