epitools 0.4.48 → 0.4.49

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.48
1
+ 0.4.49
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{epitools}
8
- s.version = "0.4.48"
8
+ s.version = "0.4.49"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["epitron"]
@@ -74,6 +74,11 @@ class MimeMagic
74
74
  def extensions
75
75
  TYPES.key?(type) ? TYPES[type][0] : []
76
76
  end
77
+
78
+ # Default extension
79
+ def ext
80
+ extensions.first
81
+ end
77
82
 
78
83
  # Get mime comment
79
84
  def comment
@@ -131,11 +136,11 @@ class MimeMagic
131
136
  def self.magic_match(io, matches)
132
137
  matches.any? do |offset, value, children|
133
138
  match = if Range === offset
134
- io.seek(offset.begin)
139
+ io.seek(offset.begin)
135
140
  io.read(offset.end - offset.begin + value.length).include?(value)
136
141
  else
137
142
  io.seek(offset)
138
- value == io.read(value.length)
143
+ value == io.read(value.length)
139
144
  end
140
145
  match && (!children || magic_match(io, children))
141
146
  end
@@ -1,4 +1,10 @@
1
1
  # Generated from freedesktop.org.xml
2
+
3
+ #
4
+ # TODO:
5
+ # Order by popularity, to speed up the MAGIC.find command.
6
+ #
7
+
2
8
  class MimeMagic
3
9
  private
4
10
  EXTENSIONS = {
@@ -764,8 +770,8 @@ class MimeMagic
764
770
  'application/ogg' => [%w(ogx), %w(), "Ogg multimedia file"],
765
771
  'application/oxps' => [%w(oxps xps), %w(application/zip), "XPS document"],
766
772
  'application/pdf' => [%w(pdf), %w(), "PDF document"],
767
- 'application/pgp-encrypted' => [%w(asc gpg pgp), %w(), "PGP/MIME-encrypted message header"],
768
- 'application/pgp-keys' => [%w(asc pkr skr), %w(text/plain), "PGP keys"],
773
+ 'application/pgp-encrypted' => [%w(pgp gpg asc), %w(), "PGP/MIME-encrypted message header"],
774
+ 'application/pgp-keys' => [%w(pkr skr asc), %w(text/plain), "PGP keys"],
769
775
  'application/pkcs10' => [%w(p10), %w(), "PKCS#10 certification request"],
770
776
  'application/pkcs7-signature' => [%w(p7s), %w(text/plain), "detached S/MIME signature"],
771
777
  'application/pkcs8' => [%w(p8), %w(), "PKCS#8 private key"],
@@ -774,13 +780,13 @@ class MimeMagic
774
780
  'application/pkix-pkipath' => [%w(pkipath), %w(), "PkiPath certification path"],
775
781
  'application/postscript' => [%w(ps), %w(text/plain), "PS document"],
776
782
  'application/ram' => [%w(ram), %w(), "RealMedia Metafile"],
777
- 'application/rdf+xml' => [%w(owl rdf rdfs), %w(application/xml), "RDF file"],
783
+ 'application/rdf+xml' => [%w(rdf owl rdfs), %w(application/xml), "RDF file"],
778
784
  'application/relax-ng-compact-syntax' => [%w(rnc), %w(text/plain), "RELAX NG XML schema"],
779
785
  'application/rss+xml' => [%w(rss), %w(application/xml), "RSS summary"],
780
786
  'application/rtf' => [%w(rtf), %w(text/plain), "RTF document"],
781
787
  'application/sdp' => [%w(sdp), %w(), "SDP multicast stream file"],
782
788
  'application/sieve' => [%w(siv), %w(application/xml), "Sieve mail filter script"],
783
- 'application/smil' => [%w(kino smi smil sml), %w(application/xml), "SMIL document"],
789
+ 'application/smil' => [%w(smil kino smi sml), %w(application/xml), "SMIL document"],
784
790
  'application/vnd.apple.mpegurl' => [%w(m3u m3u8), %w(), "HTTP Live Streaming playlist"],
785
791
  'application/vnd.corel-draw' => [%w(cdr), %w(), "Corel Draw drawing"],
786
792
  'application/vnd.emusic-emusic_package' => [%w(emp), %w(), "eMusic download package"],
@@ -793,10 +799,10 @@ class MimeMagic
793
799
  'application/vnd.mozilla.xul+xml' => [%w(xul), %w(application/xml), "XUL interface document"],
794
800
  'application/vnd.ms-access' => [%w(mdb), %w(), "JET database"],
795
801
  'application/vnd.ms-cab-compressed' => [%w(cab), %w(), "Microsoft Cabinet archive"],
796
- 'application/vnd.ms-excel' => [%w(xla xlc xld xll xlm xls xlt xlw), %w(), "Excel spreadsheet"],
797
- 'application/vnd.ms-powerpoint' => [%w(pot pps ppt ppz), %w(), "PowerPoint presentation"],
802
+ 'application/vnd.ms-excel' => [%w(xls xla xlc xld xll xlm xlt xlw), %w(), "Excel spreadsheet"],
803
+ 'application/vnd.ms-powerpoint' => [%w(ppt pot pps ppz), %w(), "PowerPoint presentation"],
798
804
  'application/vnd.ms-tnef' => [%w(tnef tnf), %w(), "TNEF message"],
799
- 'application/vnd.ms-works' => [%w(wcm wdb wks wps), %w(application/x-ole-storage), "Microsoft Works document"],
805
+ 'application/vnd.ms-works' => [%w(wks wcm wdb wps), %w(application/x-ole-storage), "Microsoft Works document"],
800
806
  'application/vnd.ms-wpl' => [%w(wpl), %w(), "WPL playlist"],
801
807
  'application/vnd.oasis.opendocument.chart' => [%w(odc), %w(application/zip), "ODC chart"],
802
808
  'application/vnd.oasis.opendocument.chart-template' => [%w(otc), %w(application/zip), "ODC template"],
@@ -819,10 +825,10 @@ class MimeMagic
819
825
  'application/vnd.oasis.opendocument.text-template' => [%w(ott), %w(application/zip), "ODT template"],
820
826
  'application/vnd.oasis.opendocument.text-web' => [%w(oth), %w(application/zip), "OTH template"],
821
827
  'application/vnd.openofficeorg.extension' => [%w(oxt), %w(application/zip), "OpenOffice.org extension"],
822
- 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => [%w(pptm pptx), %w(application/zip), "PowerPoint 2007 presentation"],
828
+ 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => [%w(pptx pptm), %w(application/zip), "PowerPoint 2007 presentation"],
823
829
  'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => [%w(ppsx), %w(application/zip), "PowerPoint 2007 show"],
824
- 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => [%w(xlsm xlsx), %w(application/zip), "Excel 2007 spreadsheet"],
825
- 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => [%w(docm docx), %w(application/zip), "Word 2007 document"],
830
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => [%w(xlsx xlsm), %w(application/zip), "Excel 2007 spreadsheet"],
831
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => [%w(docx docm), %w(application/zip), "Word 2007 document"],
826
832
  'application/vnd.rn-realmedia' => [%w(rm rmj rmm rms rmvb rmx), %w(), "RealMedia document"],
827
833
  'application/vnd.stardivision.calc' => [%w(sdc), %w(), "StarCalc spreadsheet"],
828
834
  'application/vnd.stardivision.chart' => [%w(sds), %w(), "StarChart chart"],
@@ -858,10 +864,10 @@ class MimeMagic
858
864
  'application/x-awk' => [%w(awk), %w(application/x-executable text/plain), "AWK script"],
859
865
  'application/x-bcpio' => [%w(bcpio), %w(), "BCPIO document"],
860
866
  'application/x-bittorrent' => [%w(torrent), %w(), "BitTorrent seed file"],
861
- 'application/x-blender' => [%w(blend blend blender), %w(), "Blender scene"],
867
+ 'application/x-blender' => [%w(blender blend), %w(), "Blender scene"],
862
868
  'application/x-bzdvi' => [%w(dvi.bz2), %w(), "TeX DVI document (bzip-compressed)"],
863
- 'application/x-bzip' => [%w(bz bz2), %w(), "Bzip archive"],
864
- 'application/x-bzip-compressed-tar' => [%w(tar.bz tar.bz2 tbz tbz2), %w(application/x-bzip), "Tar archive (bzip-compressed)"],
869
+ 'application/x-bzip' => [%w(bz2 bz), %w(), "Bzip archive"],
870
+ 'application/x-bzip-compressed-tar' => [%w(tar.bz2 tar.bz tbz tbz2), %w(application/x-bzip), "Tar archive (bzip-compressed)"],
865
871
  'application/x-bzpdf' => [%w(pdf.bz2), %w(), "PDF document (bzip-compressed)"],
866
872
  'application/x-bzpostscript' => [%w(ps.bz2), %w(), "PostScript document (bzip-compressed)"],
867
873
  'application/x-cb7' => [%w(cb7), %w(application/x-7z-compressed), "comic book archive"],
@@ -874,7 +880,7 @@ class MimeMagic
874
880
  'application/x-chm' => [%w(chm), %w(), "CHM document"],
875
881
  'application/x-cisco-vpn-settings' => [%w(pcf), %w(), "Cisco VPN Settings"],
876
882
  'application/x-compress' => [%w(z), %w(), "UNIX-compressed file"],
877
- 'application/x-compressed-tar' => [%w(tar.gz taz tgz), %w(), "Tar archive (gzip-compressed)"],
883
+ 'application/x-compressed-tar' => [%w(tar.gz tgz taz), %w(), "Tar archive (gzip-compressed)"],
878
884
  'application/x-cpio' => [%w(cpio), %w(), "CPIO archive"],
879
885
  'application/x-cpio-compressed' => [%w(cpio.gz), %w(), "CPIO archive (gzip-compressed)"],
880
886
  'application/x-csh' => [%w(csh), %w(application/x-shellscript text/plain), "C shell script"],
@@ -898,16 +904,16 @@ class MimeMagic
898
904
  'application/x-font-otf' => [%w(otf), %w(), "OpenType font"],
899
905
  'application/x-font-pcf' => [%w(pcf pcf.gz pcf.z), %w(), "PCF font"],
900
906
  'application/x-font-speedo' => [%w(spd), %w(), "Speedo font"],
901
- 'application/x-font-ttf' => [%w(ttc ttf), %w(), "TrueType font"],
907
+ 'application/x-font-ttf' => [%w(ttf ttc), %w(), "TrueType font"],
902
908
  'application/x-font-ttx' => [%w(ttx), %w(text/xml), "TrueType XML font"],
903
- 'application/x-font-type1' => [%w(gsf pfa pfb), %w(application/postscript), "Postscript type-1 font"],
909
+ 'application/x-font-type1' => [%w(pfb pfa gsf), %w(application/postscript), "Postscript type-1 font"],
904
910
  'application/x-gameboy-rom' => [%w(gb), %w(), "Game Boy ROM"],
905
911
  'application/x-gba-rom' => [%w(gba), %w(), "Game Boy Advance ROM"],
906
912
  'application/x-gedcom' => [%w(ged gedcom), %w(), "GEDCOM family history"],
907
913
  'application/x-genesis-rom' => [%w(gen md), %w(), "Genesis ROM"],
908
914
  'application/x-gettext-translation' => [%w(gmo mo), %w(), "translated messages (machine-readable)"],
909
915
  'application/x-glade' => [%w(glade), %w(application/xml), "Glade project"],
910
- 'application/x-gnucash' => [%w(gnc gnucash xac), %w(), "GnuCash financial data"],
916
+ 'application/x-gnucash' => [%w(gnucash gnc xac), %w(), "GnuCash financial data"],
911
917
  'application/x-gnumeric' => [%w(gnumeric), %w(), "Gnumeric spreadsheet"],
912
918
  'application/x-gnuplot' => [%w(gnuplot gp gplt), %w(text/plain), "Gnuplot document"],
913
919
  'application/x-go-sgf' => [%w(sgf), %w(text/plain), "SGF record"],
@@ -917,7 +923,7 @@ class MimeMagic
917
923
  'application/x-gzip' => [%w(gz), %w(), "Gzip archive"],
918
924
  'application/x-gzpdf' => [%w(pdf.gz), %w(application/x-gzip), "PDF document (gzip-compressed)"],
919
925
  'application/x-gzpostscript' => [%w(ps.gz), %w(application/x-gzip), "PostScript document (gzip-compressed)"],
920
- 'application/x-hdf' => [%w(h4 h5 hdf hdf4 hdf5), %w(), "HDF document"],
926
+ 'application/x-hdf' => [%w(hdf hdf4 hdf5 h4 h5), %w(), "HDF document"],
921
927
  'application/x-hwp' => [%w(hwp), %w(), "Haansoft Hangul document"],
922
928
  'application/x-hwt' => [%w(hwt), %w(), "Haansoft Hangul document template"],
923
929
  'application/x-ica' => [%w(ica), %w(text/plain), "Citrix ICA settings file"],
@@ -945,7 +951,7 @@ class MimeMagic
945
951
  'application/x-kspread' => [%w(ksp), %w(), "KSpread spreadsheet"],
946
952
  'application/x-kugar' => [%w(kud), %w(), "Kugar document"],
947
953
  'application/x-kword' => [%w(kwd kwt), %w(), "KWord document"],
948
- 'application/x-lha' => [%w(lha lzh), %w(), "LHA archive"],
954
+ 'application/x-lha' => [%w(lzh lha), %w(), "LHA archive"],
949
955
  'application/x-lhz' => [%w(lhz), %w(), "LHZ archive"],
950
956
  'application/x-lrzip' => [%w(lrz), %w(), "Lrzip archive"],
951
957
  'application/x-lrzip-compressed-tar' => [%w(tar.lrz tlrz), %w(application/x-lrzip), "Tar archive (lrzip-compressed)"],
@@ -974,7 +980,7 @@ class MimeMagic
974
980
  'application/x-pak' => [%w(pak), %w(), "PAK archive"],
975
981
  'application/x-palm-database' => [%w(pdb prc), %w(), "Palm OS database"],
976
982
  'application/x-par2' => [%w(par2 par2), %w(), "Parchive archive"],
977
- 'application/x-perl' => [%w(al perl pl pm), %w(application/x-executable text/plain), "Perl script"],
983
+ 'application/x-perl' => [%w(perl pl pm al), %w(application/x-executable text/plain), "Perl script"],
978
984
  'application/x-php' => [%w(php php3 php4), %w(text/plain), "PHP script"],
979
985
  'application/x-pkcs12' => [%w(p12 pfx), %w(), "PKCS#12 certificate bundle"],
980
986
  'application/x-pkcs7-certificates' => [%w(p7b spc), %w(), "PKCS#7 certificate bundle"],
@@ -1007,7 +1013,7 @@ class MimeMagic
1007
1013
  'application/x-sv4cpio' => [%w(sv4cpio), %w(), "SV4 CPIO archive"],
1008
1014
  'application/x-sv4crc' => [%w(sv4crc), %w(), "SV4 CPIO archive (with CRC)"],
1009
1015
  'application/x-t602' => [%w(602), %w(), "T602 document"],
1010
- 'application/x-tar' => [%w(gem gtar tar), %w(), "Tar archive"],
1016
+ 'application/x-tar' => [%w(tar gtar gem), %w(), "Tar archive"],
1011
1017
  'application/x-tarz' => [%w(tar.z), %w(), "Tar archive (compressed)"],
1012
1018
  'application/x-tex-gf' => [%w(gf), %w(), "generic font file"],
1013
1019
  'application/x-tex-pk' => [%w(pk), %w(), "packed font file"],
@@ -1034,7 +1040,7 @@ class MimeMagic
1034
1040
  'application/xml' => [%w(rng xbl xml xsd), %w(text/plain), "XML document"],
1035
1041
  'application/xml-dtd' => [%w(dtd), %w(text/plain), "DTD file"],
1036
1042
  'application/xml-external-parsed-entity' => [%w(ent), %w(application/xml), "XML entities document"],
1037
- 'application/xslt+xml' => [%w(xsl xslt), %w(application/xml), "XSLT stylesheet"],
1043
+ 'application/xslt+xml' => [%w(xslt xsl), %w(application/xml), "XSLT stylesheet"],
1038
1044
  'application/xspf+xml' => [%w(xspf), %w(application/xml), "XSPF playlist"],
1039
1045
  'application/zip' => [%w(zip), %w(), "Zip archive"],
1040
1046
  'audio/AMR' => [%w(amr), %w(), "AMR audio"],
@@ -1043,14 +1049,14 @@ class MimeMagic
1043
1049
  'audio/annodex' => [%w(axa), %w(application/annodex), "Annodex Audio"],
1044
1050
  'audio/basic' => [%w(au snd), %w(), "ULAW (Sun) audio"],
1045
1051
  'audio/flac' => [%w(flac), %w(), "FLAC audio"],
1046
- 'audio/midi' => [%w(kar mid midi), %w(), "MIDI audio"],
1052
+ 'audio/midi' => [%w(midi mid kar), %w(), "MIDI audio"],
1047
1053
  'audio/mp2' => [%w(mp2), %w(), "MP2 audio"],
1048
- 'audio/mp4' => [%w(aac f4a m4a), %w(), "MPEG-4 audio"],
1054
+ 'audio/mp4' => [%w(m4a aac f4a), %w(), "MPEG-4 audio"],
1049
1055
  'audio/mpeg' => [%w(mp3 mpga), %w(), "MP3 audio"],
1050
- 'audio/ogg' => [%w(oga ogg spx), %w(application/ogg), "Ogg Audio"],
1056
+ 'audio/ogg' => [%w(ogg oga spx), %w(application/ogg), "Ogg Audio"],
1051
1057
  'audio/prs.sid' => [%w(psid sid), %w(), "Commodore 64 audio"],
1052
1058
  'audio/vnd.rn-realaudio' => [%w(ra rax), %w(), "RealAudio document"],
1053
- 'audio/x-aiff' => [%w(aif aifc aiff), %w(), "AIFF/Amiga/Mac audio"],
1059
+ 'audio/x-aiff' => [%w(aiff aif aifc), %w(), "AIFF/Amiga/Mac audio"],
1054
1060
  'audio/x-ape' => [%w(ape), %w(), "Monkey's audio"],
1055
1061
  'audio/x-flac+ogg' => [%w(ogg), %w(audio/ogg), "Ogg FLAC audio"],
1056
1062
  'audio/x-gsm' => [%w(gsm), %w(), "GSM 06.10 audio"],
@@ -1060,7 +1066,7 @@ class MimeMagic
1060
1066
  'audio/x-matroska' => [%w(mka), %w(application/x-matroska), "Matroska audio"],
1061
1067
  'audio/x-minipsf' => [%w(minipsf), %w(audio/x-psf), "MiniPSF audio"],
1062
1068
  'audio/x-mo3' => [%w(mo3), %w(), "compressed Tracker audio"],
1063
- 'audio/x-mod' => [%w(669 m15 med mod mtm ult uni), %w(), "Amiga SoundTracker audio"],
1069
+ 'audio/x-mod' => [%w(mod 669 m15 med mtm ult uni), %w(), "Amiga SoundTracker audio"],
1064
1070
  'audio/x-mpegurl' => [%w(m3u m3u8 vlc), %w(text/plain), "MP3 audio (streamed)"],
1065
1071
  'audio/x-ms-asx' => [%w(asx wax wmx wvx), %w(), "Microsoft ASX playlist"],
1066
1072
  'audio/x-ms-wma' => [%w(wma), %w(video/x-ms-asf), "Windows Media audio"],
@@ -1087,16 +1093,16 @@ class MimeMagic
1087
1093
  'image/fits' => [%w(fits), %w(), "FITS document"],
1088
1094
  'image/gif' => [%w(gif), %w(), "GIF image"],
1089
1095
  'image/ief' => [%w(ief), %w(), "IEF image"],
1090
- 'image/jp2' => [%w(j2k jp2 jpc jpf jpx), %w(), "JPEG-2000 image"],
1096
+ 'image/jp2' => [%w(jp2 j2k jpc jpf jpx), %w(), "JPEG-2000 image"],
1091
1097
  'image/jpeg' => [%w(jpeg jpg jpe), %w(), "JPEG image"],
1092
1098
  'image/openraster' => [%w(ora), %w(), "OpenRaster archiving image"],
1093
1099
  'image/png' => [%w(png), %w(), "PNG image"],
1094
1100
  'image/rle' => [%w(rle), %w(), "Run Length Encoded bitmap image"],
1095
1101
  'image/svg+xml' => [%w(svg), %w(application/xml), "SVG image"],
1096
1102
  'image/svg+xml-compressed' => [%w(svgz), %w(application/x-gzip), "compressed SVG image"],
1097
- 'image/tiff' => [%w(tif tiff), %w(), "TIFF image"],
1103
+ 'image/tiff' => [%w(tiff tif), %w(), "TIFF image"],
1098
1104
  'image/vnd.adobe.photoshop' => [%w(psd), %w(), "Photoshop image"],
1099
- 'image/vnd.djvu' => [%w(djv djvu), %w(), "DjVu image"],
1105
+ 'image/vnd.djvu' => [%w(djvu djv), %w(), "DjVu image"],
1100
1106
  'image/vnd.dwg' => [%w(dwg), %w(), "AutoCAD image"],
1101
1107
  'image/vnd.dxf' => [%w(dxf), %w(), "DXF vector image"],
1102
1108
  'image/vnd.microsoft.icon' => [%w(ico), %w(), "Microsoft icon"],
@@ -1164,11 +1170,11 @@ class MimeMagic
1164
1170
  'text/calendar' => [%w(ics vcs), %w(text/plain), "VCS/ICS calendar"],
1165
1171
  'text/css' => [%w(css cssl), %w(text/x-csrc), "CSS stylesheet"],
1166
1172
  'text/csv' => [%w(csv), %w(text/plain), "CSV document"],
1167
- 'text/directory' => [%w(gcrd vcf vct), %w(text/plain), "electronic business card"],
1168
- 'text/html' => [%w(htm html), %w(text/plain), "HTML document"],
1169
- 'text/plain' => [%w(asc txt), %w(), "plain text document"],
1173
+ 'text/directory' => [%w(vcf vct gcrd), %w(text/plain), "electronic business card"],
1174
+ 'text/html' => [%w(html htm), %w(text/plain), "HTML document"],
1175
+ 'text/plain' => [%w(txt asc), %w(), "plain text document"],
1170
1176
  'text/richtext' => [%w(rtx), %w(text/plain), "rich text document"],
1171
- 'text/sgml' => [%w(sgm sgml), %w(text/plain), "SGML document"],
1177
+ 'text/sgml' => [%w(sgml sgm), %w(text/plain), "SGML document"],
1172
1178
  'text/spreadsheet' => [%w(slk sylk), %w(text/plain), "spreadsheet interchange document"],
1173
1179
  'text/tab-separated-values' => [%w(tsv), %w(text/plain), "TSV document"],
1174
1180
  'text/troff' => [%w(roff t tr), %w(text/plain), "Troff document"],
@@ -1178,10 +1184,10 @@ class MimeMagic
1178
1184
  'text/vnd.trolltech.linguist' => [%w(ts), %w(application/xml), "message catalog"],
1179
1185
  'text/vnd.wap.wml' => [%w(wml), %w(application/xml), "WML document"],
1180
1186
  'text/vnd.wap.wmlscript' => [%w(wmls), %w(), "WMLScript program"],
1181
- 'text/x-adasrc' => [%w(adb ads), %w(text/plain), "Ada source code"],
1187
+ 'text/x-adasrc' => [%w(ads adb), %w(text/plain), "Ada source code"],
1182
1188
  'text/x-bibtex' => [%w(bib), %w(text/plain), "BibTeX document"],
1183
- 'text/x-c++hdr' => [%w(h++ hh hp hpp hxx), %w(text/x-chdr), "C++ header"],
1184
- 'text/x-c++src' => [%w(c c++ cc cpp cxx), %w(text/x-csrc), "C++ source code"],
1189
+ 'text/x-c++hdr' => [%w(hpp hh h++ hp hxx), %w(text/x-chdr), "C++ header"],
1190
+ 'text/x-c++src' => [%w(cpp c++ cc cxx c), %w(text/x-csrc), "C++ source code"],
1185
1191
  'text/x-chdr' => [%w(h), %w(text/x-csrc), "C header"],
1186
1192
  'text/x-cmake' => [%w(cmake), %w(text/plain), "CMake source code"],
1187
1193
  'text/x-cobol' => [%w(cbl cob), %w(text/plain), "COBOL source file"],
@@ -1213,17 +1219,17 @@ class MimeMagic
1213
1219
  'text/x-moc' => [%w(moc), %w(text/plain), "Qt MOC file"],
1214
1220
  'text/x-mof' => [%w(mof), %w(text/x-csrc), "Managed Object Format"],
1215
1221
  'text/x-mpsub' => [%w(sub), %w(text/plain), "MPSub subtitles"],
1216
- 'text/x-mrml' => [%w(mrl mrml), %w(), "MRML playlist"],
1222
+ 'text/x-mrml' => [%w(mrml mrl), %w(), "MRML playlist"],
1217
1223
  'text/x-ms-regedit' => [%w(reg), %w(text/plain), "Windows Registry extract"],
1218
1224
  'text/x-mup' => [%w(mup not), %w(text/plain), "Mup publication"],
1219
- 'text/x-nfo' => [%w(nfo), %w(text/x-readme), "NFO document"],
1225
+ 'text/x-nfo' => [%w(nfo), %w(text/x-readme), "NFO file"],
1220
1226
  'text/x-objcsrc' => [%w(m), %w(text/x-csrc), "Objective-C source code"],
1221
1227
  'text/x-ocaml' => [%w(ml mli), %w(), "OCaml source code"],
1222
1228
  'text/x-ocl' => [%w(ocl), %w(text/plain), "OCL file"],
1223
1229
  'text/x-ooc' => [%w(ooc), %w(text/x-csrc), "OOC source code"],
1224
1230
  'text/x-opml+xml' => [%w(opml), %w(application/xml), "OPML syndication feed"],
1225
- 'text/x-pascal' => [%w(p pas), %w(text/plain), "Pascal source code"],
1226
- 'text/x-patch' => [%w(diff patch), %w(text/plain), "differences between files"],
1231
+ 'text/x-pascal' => [%w(pas p), %w(text/plain), "Pascal source code"],
1232
+ 'text/x-patch' => [%w(patch diff), %w(text/plain), "differences between files"],
1227
1233
  'text/x-python' => [%w(py), %w(application/x-executable text/plain), "Python script"],
1228
1234
  'text/x-rpm-spec' => [%w(spec), %w(text/plain), "RPM spec file"],
1229
1235
  'text/x-scheme' => [%w(scm), %w(text/plain), "Scheme source code"],
@@ -1241,7 +1247,7 @@ class MimeMagic
1241
1247
  'text/x-troff-ms' => [%w(ms), %w(text/plain), "Troff MS input document"],
1242
1248
  'text/x-txt2tags' => [%w(t2t), %w(text/plain), "txt2tags document"],
1243
1249
  'text/x-uil' => [%w(uil), %w(text/plain), "X-Motif UIL table"],
1244
- 'text/x-uri' => [%w(uri url), %w(text/plain), "resource location"],
1250
+ 'text/x-uri' => [%w(url uri), %w(text/plain), "resource location"],
1245
1251
  'text/x-vala' => [%w(vala vapi), %w(text/x-csrc), "Vala source code"],
1246
1252
  'text/x-verilog' => [%w(v), %w(text/plain), "Verilog source code"],
1247
1253
  'text/x-vhdl' => [%w(vhd vhdl), %w(text/plain), "VHDL source code"],
@@ -1251,15 +1257,15 @@ class MimeMagic
1251
1257
  'video/3gpp2' => [%w(3g2 3gp2 3gpp2), %w(video/mp4), "3GPP2 multimedia file"],
1252
1258
  'video/annodex' => [%w(axv), %w(application/annodex), "Annodex Video"],
1253
1259
  'video/dv' => [%w(dv), %w(), "DV video"],
1254
- 'video/mp2t' => [%w(bdm bdmv clpi cpi m2t m2ts mpl mpls mts ts), %w(), "MPEG-2 transport stream"],
1255
- 'video/mp4' => [%w(f4v m4v mp4), %w(), "MPEG-4 video"],
1256
- 'video/mpeg' => [%w(mp2 mpe mpeg mpg vob), %w(), "MPEG video"],
1260
+ 'video/mp2t' => [%w(m2ts m2t bdm bdmv clpi cpi mpl mpls mts ts), %w(), "MPEG-2 transport stream"],
1261
+ 'video/mp4' => [%w(mp4 m4v f4v), %w(), "MPEG-4 video"],
1262
+ 'video/mpeg' => [%w(mpeg mpg mp2 mpe vob), %w(), "MPEG video"],
1257
1263
  'video/ogg' => [%w(ogv), %w(application/ogg), "Ogg Video"],
1258
- 'video/quicktime' => [%w(moov mov qt qtvr), %w(), "QuickTime video"],
1264
+ 'video/quicktime' => [%w(mov qt moov qtvr), %w(), "QuickTime video"],
1259
1265
  'video/vivo' => [%w(viv vivo), %w(), "Vivo video"],
1260
1266
  'video/vnd.rn-realvideo' => [%w(rv rvx), %w(), "RealVideo document"],
1261
1267
  'video/webm' => [%w(webm), %w(), "WebM video"],
1262
- 'video/x-flic' => [%w(flc fli), %w(), "FLIC animation"],
1268
+ 'video/x-flic' => [%w(fli flc), %w(), "FLIC animation"],
1263
1269
  'video/x-flv' => [%w(flv), %w(), "Flash video"],
1264
1270
  'video/x-javafx' => [%w(fxm), %w(video/x-flv), "JavaFX video"],
1265
1271
  'video/x-matroska' => [%w(mkv), %w(application/x-matroska), "Matroska video"],
@@ -458,6 +458,14 @@ class Path
458
458
  open { |io| MimeMagic.by_magic(io) }
459
459
  end
460
460
 
461
+ #
462
+ # The filetype (as a standard file extension), verified with Magic.
463
+ #
464
+ # (In other words, this will give you the *true* extension, even if the file's
465
+ # extension is wrong.)
466
+ #
467
+ # Note: Prefers long extensions (eg: jpeg over jpg)
468
+ #
461
469
  def type
462
470
  @magictype ||= proc do
463
471
 
@@ -465,7 +473,7 @@ class Path
465
473
  magic = self.magic
466
474
 
467
475
  if !ext and magic
468
- magic.extensions.first
476
+ magic.ext
469
477
  elsif ext and !magic
470
478
  ext
471
479
  elsif !ext and !magic
@@ -474,7 +482,7 @@ class Path
474
482
  if magic.extensions.include? ext
475
483
  ext
476
484
  else
477
- magic.extensions.first # just incase the extension is incorrect
485
+ magic.ext # in case the supplied extension is wrong...
478
486
  end
479
487
  end
480
488
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epitools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.48
4
+ version: 0.4.49
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
17
- requirement: &75924720 !ruby/object:Gem::Requirement
17
+ requirement: &75824280 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 2.2.0
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *75924720
25
+ version_requirements: *75824280
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: mechanize
28
- requirement: &75924440 !ruby/object:Gem::Requirement
28
+ requirement: &75824040 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 1.0.0
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *75924440
36
+ version_requirements: *75824040
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: sqlite3-ruby
39
- requirement: &75924150 !ruby/object:Gem::Requirement
39
+ requirement: &75823750 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: '0'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *75924150
47
+ version_requirements: *75823750
48
48
  description: Miscellaneous utility libraries to make my life easier.
49
49
  email: chris@ill-logic.com
50
50
  executables: []