typor 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0364d61fca8f071d08eede93a928ca812e517ea5
4
+ data.tar.gz: bc55e534e5dcec384fea52b18e585f4dcf46c4fc
5
+ SHA512:
6
+ metadata.gz: bff0e1e5655d22a133f96b5f23500b8cc9318b9b5fd6967e5dff6548685c6ff4771a5292b57139cf1d89c705c9291843b46e5c6138b06e6a7335225a54c2941a
7
+ data.tar.gz: 6c72de5c1d3979df3f8212afee9963f2129c48903b3755c855a438b04521855ef80f680ff34a3a9cfe96a13329a8960724e7df85e018daa9bbd5080c8dded9d0
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .idea
2
+ Gemfile.lock
3
+ pkg
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Paul Duncan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # Typor
2
+
3
+ Stupid Type Magic for Ruby
4
+
5
+ ## Presentation
6
+
7
+ This library provides MIME detection magic based on file contents - nothing more.
8
+
9
+ ## Installation
10
+
11
+ ### Gemfile
12
+ ```ruby
13
+ gem 'typor'
14
+ ```
15
+
16
+ ### Terminal
17
+ ```bash
18
+ gem install -V typor
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ Typor provides basic detection of most MIME types, based on actual file contents.
24
+
25
+ ```ruby
26
+ # Determine File Type
27
+ Typor.file 'raccoon.png'
28
+ # => 'image/png'
29
+
30
+ # Determine Data Type
31
+ data = File.read 'raccoon.png'
32
+ Typor.data data
33
+ # => 'image/png'
34
+ ```
35
+
36
+ ## License
37
+
38
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require 'rake/testtask'
2
+ require 'bundler/gem_tasks'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'test'
6
+ t.pattern = 'test/**/test*.rb'
7
+ end
8
+
9
+ task :default => :test
data/lib/typor.rb ADDED
@@ -0,0 +1,30 @@
1
+ # Typor
2
+ # by Eresse <eresse@eresse.net>
3
+
4
+ # External Includes
5
+ require 'aromat'
6
+
7
+ # Internal Includes
8
+ require 'typor/version'
9
+ require 'typor/magic'
10
+
11
+ # Typor Module
12
+ # Root Module for Typor
13
+ module Typor
14
+
15
+ # Get File Type
16
+ # Determines MIME Type of Local File
17
+ # @param [String] f Path to a File
18
+ # @return [String] MIME Type
19
+ def self.file f
20
+ (Magic.detect_magic(File.read(f)) || []).try :first
21
+ end
22
+
23
+ # Get Data Type
24
+ # Determine MIME Type of Data String
25
+ # @param [String] d Data String
26
+ # @return [String] MIME Type
27
+ def self.data d
28
+ (Magic.detect_magic(d) || []).try :first
29
+ end
30
+ end
@@ -0,0 +1,413 @@
1
+ # Typor
2
+ # by Eresse <eresse@eresse.net>
3
+
4
+ # Typor Module
5
+ module Typor
6
+
7
+ # Magic Module
8
+ module Magic
9
+
10
+ # Magic
11
+ MAGIC = [
12
+ ['image/jpeg', [[0, "\377\330\377"], [0, "\377\330"]]],
13
+ ['image/png', [[0, "\211PNG"]]],
14
+ ['image/gif', [[0, 'GIF8']]],
15
+ ['image/tiff', [[0, "MM\000*"], [0, "II*\000"]]],
16
+ ['image/bmp', [[0, 'BM', [[14, "\f"], [14, '@'], [14, '(']]]]],
17
+ ['image/vnd.adobe.photoshop', []],
18
+ ['image/webp', [[0, 'RIFF', [[8, 'WEBP']]]]],
19
+ ['image/svg+xml', [[0..256, '<!DOCTYPE svg'], [0..256, '<svg']]],
20
+ ['video/x-msvideo', [[0, 'RIFF', [[8, 'AVI ']]], [0, 'AVF0', [[8, 'AVI ']]]]],
21
+ ['video/mp4', [[4, 'ftypisom'], [4, 'ftypmp42'], [4, 'ftypMSNV'], [4, 'ftypM4V '], [4, 'ftypf4v ']]],
22
+ ['video/quicktime', [[12, 'mdat'], [4, 'mdat'], [4, 'moov'], [4, 'ftypqt']]],
23
+ ['video/mpeg', [[0, "G?\377\020"], [0, "\000\000\001\263"], [0, "\000\000\001\272"]]],
24
+ ['video/ogg', [[0, 'OggS']]],
25
+ ['video/webm', [[0, "\032E\337\243", [[5..65, "B\202", [[8..75, 'webm']]]]]]],
26
+ ['video/x-flv', [[0, 'FLV']]],
27
+ ['audio/mpeg', [[0, "\377\373"], [0, 'ID3']]],
28
+ ['audio/x-wav', [[8, 'WAVE'], [8, 'WAV ']]],
29
+ ['audio/aac', [[0, 'ADIF']]],
30
+ ['audio/flac', [[0, 'fLaC']]],
31
+ ['audio/mp4', [[4, 'ftypM4A']]],
32
+ ['audio/ogg', [[0, 'OggS']]],
33
+ ['application/pdf', [[0..1024, '%PDF-']]],
34
+ ['application/msword', [[0, "1\276\000\000"], [0, 'PO^Q`'], [0, "\3767\000#"], [0, "\333\245-\000\000\000"], [2112, 'MSWordDoc'], [2108, 'MSWordDoc'], [2112, 'Microsoft Word document data'], [546, 'bjbj'], [546, 'jbjb']]],
35
+ ['application/vnd.ms-excel', [[2080, 'Microsoft Excel 5.0 Worksheet']]],
36
+ ['application/vnd.stardivision.writer', [[2089, 'StarWriter']]],
37
+ ['application/x-docbook+xml', [[0, '<?xml', [[0..100, '-//OASIS//DTD DocBook XML'], [0..100, '-//KDE//DTD DocBook XML']]]]],
38
+ ['image/x-eps', [[0, '%!', [[15, 'EPS']]], [0, "\004%!", [[16, 'EPS']]], [0, "\305\320\323\306"]]],
39
+ ['application/prs.plucker', [[60, 'DataPlkr']]],
40
+ ['application/vnd.corel-draw', []],
41
+ ['application/x-fictionbook+xml', [[0..256, '<FictionBook']]],
42
+ ['application/x-mobipocket-ebook', [[60, 'BOOKMOBI']]],
43
+ ['application/x-mozilla-bookmarks', [[0..64, '<!DOCTYPE NETSCAPE-Bookmark-file-1>']]],
44
+ ['application/x-nzb', [[0..256, '<nzb']]],
45
+ ['application/x-pak', [[0, 'PACK']]],
46
+ ['application/x-php', [[0..64, '<?php']]],
47
+ ['application/x-xliff', [[0..256, '<xliff']]],
48
+ ['application/x-zip-compressed-fb2', [[0, "PK\003\004", [[30..256, '.fb2']]]]],
49
+ ['audio/x-flac+ogg', [[0, 'OggS', [[28, 'fLaC']]], [0, 'OggS', [[28, "\177FLAC"]]]]],
50
+ ['audio/x-opus+ogg', [[0, 'OggS', [[28, 'OpusHead']]]]],
51
+ ['audio/x-speex+ogg', [[0, 'OggS', [[28, 'Speex ']]]]],
52
+ ['audio/x-vorbis+ogg', [[0, 'OggS', [[28, "\001vorbis"]]]]],
53
+ ['image/x-kodak-kdc', [[242, 'EASTMAN KODAK COMPANY']]],
54
+ ['image/x-niff', [[0, 'IIN1']]],
55
+ ['text/x-qml', [[0..256, 'import Qt ']]],
56
+ ['video/x-ogm+ogg', [[0, 'OggS', [[29, 'video']]]]],
57
+ ['video/x-theora+ogg', [[0, 'OggS', [[28, "\200theora"]]]]],
58
+ ['application/atom+xml', [[0..256, '<feed ']]],
59
+ ['application/rss+xml', [[0..256, '<rss '], [0..256, '<RSS ']]],
60
+ ['application/vnd.apple.mpegurl', [[0, '#EXTM3U', [[0..128, '#EXT-X-TARGETDURATION'], [0..128, '#EXT-X-STREAM-INF']]]]],
61
+ ['text/x-opml+xml', [[0..256, '<opml ']]],
62
+ ['application/vnd.ms-cab-compressed', [[0, "MSCF\000\000\000\000"]]],
63
+ ['application/vnd.ms-wpl', [[0..256, '<?wpl']]],
64
+ ['application/x-7z-compressed', [[0, "7z\274\257'\034"]]],
65
+ ['application/x-ace', [[7, '**ACE**']]],
66
+ ['application/x-arc', []],
67
+ ['application/x-cpio', [[0, "\307q"], [0, '070701'], [0, '070702'], [0, "q\307"]]],
68
+ ['application/x-font-type1', [[0, 'LWFN'], [65, 'LWFN'], [0, '%!PS-AdobeFont-1.'], [6, '%!PS-AdobeFont-1.'], [0, '%!FontType1-1.'], [6, '%!FontType1-1.']]],
69
+ ['application/x-java-pack200', [[0, "\312\376\320\r"]]],
70
+ ['application/x-karbon', [[0, "\037\213", [[10, 'KOffice', [[18, "application/x-karbon\004\006"]]]]], [0, "PK\003\004", [[30, 'mimetype', [[38, 'application/x-karbon']]]]]]],
71
+ ['application/x-kchart', [[0, "\037\213", [[10, 'KOffice', [[18, "application/x-kchart\004\006"]]]]], [0, "PK\003\004", [[30, 'mimetype', [[38, 'application/x-kchart']]]]]]],
72
+ ['application/x-kformula', [[0, "\037\213", [[10, 'KOffice', [[18, "application/x-kformula\004\006"]]]]], [0, "PK\003\004", [[30, 'mimetype', [[38, 'application/x-kformula']]]]]]],
73
+ ['application/x-killustrator', [[0, "\037\213", [[10, 'KOffice', [[18, "application/x-killustrator\004\006"]]]]]]],
74
+ ['application/x-kivio', [[0, "\037\213", [[10, 'KOffice', [[18, "application/x-kivio\004\006"]]]]], [0, "PK\003\004", [[30, 'mimetype', [[38, 'application/x-kivio']]]]]]],
75
+ ['application/x-kontour', [[0, "\037\213", [[10, 'KOffice', [[18, "application/x-kontour\004\006"]]]]], [0, "PK\003\004", [[30, 'mimetype', [[38, 'application/x-kontour']]]]]]],
76
+ ['application/x-kpresenter', [[0, "\037\213", [[10, 'KOffice', [[18, "application/x-kpresenter\004\006"]]]]], [0, "PK\003\004", [[30, 'mimetype', [[38, 'application/x-kpresenter']]]]]]],
77
+ ['application/x-krita', [[0, "\037\213", [[10, 'KOffice', [[18, "application/x-krita\004\006"]]]]], [0, "PK\003\004", [[30, 'mimetype', [[38, 'application/x-krita']]]]]]],
78
+ ['application/x-kspread', [[0, "\037\213", [[10, 'KOffice', [[18, "application/x-kspread\004\006"]]]]], [0, "PK\003\004", [[30, 'mimetype', [[38, 'application/x-kspread']]]]]]],
79
+ ['application/x-kword', [[0, "\037\213", [[10, 'KOffice', [[18, "application/x-kword\004\006"]]]]], [0, "PK\003\004", [[30, 'mimetype', [[38, 'application/x-kword']]]]]]],
80
+ ['application/x-lha', [[2, '-lh -'], [2, '-lh0-'], [2, '-lh1-'], [2, '-lh2-'], [2, '-lh3-'], [2, '-lh4-'], [2, '-lh5-'], [2, '-lh40-'], [2, '-lhd-'], [2, '-lz4-'], [2, '-lz5-'], [2, '-lzs-']]],
81
+ ['application/x-lrzip', [[0, 'LRZI']]],
82
+ ['application/x-lz4', [[0, "\004\"M\030"], [0, "\002!L\030"]]],
83
+ ['application/x-lzip', [[0, 'LZIP']]],
84
+ ['application/x-lzop', [[0, "\211LZO\000\r\n\032\n"]]],
85
+ ['application/x-par2', [[0, 'PAR2']]],
86
+ ['application/x-qpress', [[0, 'qpress10']]],
87
+ ['application/x-quicktime-media-link', [[0, '<?xml', [[0..64, '<?quicktime']]], [0, 'RTSPtext'], [0, 'rtsptext'], [0, 'SMILtext']]],
88
+ ['application/x-rar', [[0, 'Rar!']]],
89
+ ['application/x-stuffit', [[0, 'StuffIt '], [0, 'SIT!']]],
90
+ ['application/x-tar', [[257, "ustar\000"], [257, "ustar \000"]]],
91
+ ['application/x-xar', [[0, 'xar!']]],
92
+ ['application/x-xz', [[0, "\3757zXZ\000"]]],
93
+ ['application/x-zoo', [[20, "\334\247\304\375"]]],
94
+ ['application/xhtml+xml', [[0..256, '//W3C//DTD XHTML '], [0..256, 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'], [0..256, "<html xmlns=\"http://www.w3.org/1999/xhtml"], [0..256, "<HTML xmlns=\"http://www.w3.org/1999/xhtml"]]],
95
+ ['audio/vnd.dts.hd', [[0..18725, 'dX %']]],
96
+ ['text/x-txt2tags', [[0, '%!postproc'], [0, '%!encoding']]],
97
+ ['application/smil+xml', [[0..256, '<smil']]],
98
+ ['audio/x-ms-asx', [[0, 'ASF '], [0..64, '<ASX'], [0..64, '<asx'], [0..64, '<Asx']]],
99
+ ['application/annodex', [[0, 'OggS', [[28, "fishead\000", [[56..512, "CMML\000\000\000\000"]]]]]]],
100
+ ['application/dicom', [[128, 'DICM']]],
101
+ ['application/epub+zip', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/epub+zip'], [43, 'application/epub+zip']]]]]]],
102
+ ['application/font-woff', [[0, 'wOFF']]],
103
+ ['application/gnunet-directory', [[0, "\211GND\r\n\032\n"]]],
104
+ ['application/gzip', [[0, "\037\213"]]],
105
+ ['application/mac-binhex40', [[11, 'must be converted with BinHex']]],
106
+ ['application/mathematica', [[0, '(************** Content-type: application/mathematica'], [100..256, 'This notebook can be used on any computer system with Mathematica'], [10..256, 'This is a Mathematica Notebook file. It contains ASCII text']]],
107
+ ['application/metalink+xml', [[0..256, "<metalink version=\"3.0\""]]],
108
+ ['application/metalink4+xml', [[0..256, "<metalink xmlns=\"urn"]]],
109
+ ['application/mxf', [[0..256, "\006\016+4\002\005\001\001\r\001\002\001\001\002"]]],
110
+ ['application/ogg', [[0, 'OggS']]],
111
+ ['application/owl+xml', [[0..256, '<Ontology']]],
112
+ ['application/pgp-encrypted', [[0, '-----BEGIN PGP MESSAGE-----']]],
113
+ ['application/pgp-keys', [[0, '-----BEGIN PGP PUBLIC KEY BLOCK-----'], [0, '-----BEGIN PGP PRIVATE KEY BLOCK-----'], [0, "\225\001"], [0, "\225\000"], [0, "\231\000"], [0, "\231\001"]]],
114
+ ['application/pgp-signature', [[0, '-----BEGIN PGP SIGNATURE-----']]],
115
+ ['application/postscript', [[0, "\004%!"], [0, '%!']]],
116
+ ['application/rtf', [[0, "{\\rtf"]]],
117
+ ['application/sdp', [[0, 'v=', [[0..256, 's=']]]]],
118
+ ['application/vnd.adobe.flash.movie', [[0, 'FWS'], [0, 'CWS']]],
119
+ ['application/vnd.debian.binary-package', [[0, '!<arch>', [[8, 'debian']]]]],
120
+ ['application/vnd.emusic-emusic_package', [[0, 'nF7YLao']]],
121
+ ['application/vnd.iccprofile', [[36, 'acsp']]],
122
+ ['application/vnd.lotus-1-2-3', [[0, "\000\000\002\000\006\004\006\000\b\000\000\000\000\000"]]],
123
+ ['application/vnd.lotus-wordpro', [[0, 'WordPro']]],
124
+ ['application/vnd.ms-access', [[0, "\000\001\000\000Standard Jet DB"]]],
125
+ ['application/vnd.ms-asf', [[0, "0&\262u"], [0, '[Reference]']]],
126
+ ['application/vnd.ms-tnef', [[0, "x\237>\""]]],
127
+ ['application/vnd.oasis.opendocument.chart', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.chart']]]]]]],
128
+ ['application/vnd.oasis.opendocument.chart-template', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.chart-template']]]]]]],
129
+ ['application/vnd.oasis.opendocument.database', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.base']]]]]]],
130
+ ['application/vnd.oasis.opendocument.formula', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.formula']]]]]]],
131
+ ['application/vnd.oasis.opendocument.formula-template', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.formula-template']]]]]]],
132
+ ['application/vnd.oasis.opendocument.graphics', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.graphics']]]]]]],
133
+ ['application/vnd.oasis.opendocument.graphics-template', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.graphics-template']]]]]]],
134
+ ['application/vnd.oasis.opendocument.image', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.image']]]]]]],
135
+ ['application/vnd.oasis.opendocument.presentation', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.presentation']]]]]]],
136
+ ['application/vnd.oasis.opendocument.presentation-template', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.presentation-template']]]]]]],
137
+ ['application/vnd.oasis.opendocument.spreadsheet', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.spreadsheet']]]]]]],
138
+ ['application/vnd.oasis.opendocument.spreadsheet-template', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.spreadsheet-template']]]]]]],
139
+ ['application/vnd.oasis.opendocument.text', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.text']]]]]]],
140
+ ['application/vnd.oasis.opendocument.text-master', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.text-master']]]]]]],
141
+ ['application/vnd.oasis.opendocument.text-template', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.text-template']]]]]]],
142
+ ['application/vnd.oasis.opendocument.text-web', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.text-web']]]]]]],
143
+ ['application/vnd.rn-realmedia', [[0, '.RMF']]],
144
+ ['application/vnd.sun.xml.calc', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.sun.xml.calc']]]]]]],
145
+ ['application/vnd.sun.xml.calc.template', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.sun.xml.calc']]]]]]],
146
+ ['application/vnd.sun.xml.draw', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.sun.xml.draw']]]]]]],
147
+ ['application/vnd.sun.xml.draw.template', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.sun.xml.draw']]]]]]],
148
+ ['application/vnd.sun.xml.impress', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.sun.xml.impress']]]]]]],
149
+ ['application/vnd.sun.xml.impress.template', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.sun.xml.impress']]]]]]],
150
+ ['application/vnd.sun.xml.math', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.sun.xml.math']]]]]]],
151
+ ['application/vnd.sun.xml.writer', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.sun.xml.writer']]]]]]],
152
+ ['application/vnd.sun.xml.writer.global', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.sun.xml.writer']]]]]]],
153
+ ['application/vnd.sun.xml.writer.template', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.sun.xml.writer']]]]]]],
154
+ ['application/vnd.symbian.install', [[8, "\031\004\000\020"]]],
155
+ ['application/vnd.tcpdump.pcap', [[0, "\324\303\262\241"], [0, "\241\262\303\324"]]],
156
+ ['application/vnd.wordperfect', [[1, 'WPC']]],
157
+ ['application/vnd.xdgapp', [[0, "xdg-app\000\001\000\211\345"]]],
158
+ ['application/winhlp', [[0, "?_\003\000"]]],
159
+ ['application/x-abiword', [[0..256, '<abiword'], [0..256, '<!DOCTYPE abiword']]],
160
+ ['application/x-alz', [[0, 'ALZ']]],
161
+ ['application/x-amiga-disk-format', [[0, "DOS\000"]]],
162
+ ['application/x-aportisdoc', [[60, 'TEXtREAd'], [60, 'TEXtTlDc']]],
163
+ ['application/x-applix-spreadsheet', [[0, '*BEGIN SPREADSHEETS'], [0, '*BEGIN', [[7, 'SPREADSHEETS']]]]],
164
+ ['application/x-applix-word', [[0, '*BEGIN', [[7, 'WORDS']]]]],
165
+ ['application/x-arj', [[0, "`\352"]]],
166
+ ['application/x-awk', [[0, '#!/bin/gawk'], [0, '#! /bin/gawk'], [0, '#!/usr/bin/gawk'], [0, '#! /usr/bin/gawk'], [0, '#!/usr/local/bin/gawk'], [0, '#! /usr/local/bin/gawk'], [0, '#!/bin/awk'], [0, '#! /bin/awk'], [0, '#!/usr/bin/awk'], [0, '#! /usr/bin/awk']]],
167
+ ['application/x-bittorrent', [[0, 'd8:announce']]],
168
+ ['application/x-blender', [[0, 'BLENDER']]],
169
+ ['application/x-bzip', [[0, 'BZh']]],
170
+ ['application/x-ccmx', [[0, 'CCMX']]],
171
+ ['application/x-cdrdao-toc', [[0, "CD_ROM\n"], [0, "CD_DA\n"], [0, "CD_ROM_XA\n"], [0, 'CD_TEXT '], [0, "CATALOG \"", [[22, "\""]]]]],
172
+ ['application/x-chess-pgn', [[0, '[Event ']]],
173
+ ['application/x-cisco-vpn-settings', [[0, '[main]', [[0..256, 'AuthType=']]]]],
174
+ ['application/x-compress', [[0, "\037\235"]]],
175
+ ['application/x-core', [[0, "\177ELF", [[5, "\001", [[16, "\004\000"]]]]], [0, "\177ELF", [[5, "\002", [[16, "\000\004"]]]]], [0, "Core\001"], [0, "Core\002"]]],
176
+ ['application/x-csh', [[2..16, '/bin/tcsh'], [2..16, '/bin/csh'], [2..16, '/bin/env csh'], [2..16, '/bin/env tcsh']]],
177
+ ['application/x-dar', [[0, "\000\000\000{"]]],
178
+ ['application/x-designer', [[0..256, '<ui '], [0..256, '<UI ']]],
179
+ ['application/x-desktop', [[0..32, '[Desktop Entry]'], [0, '[Desktop Action'], [0, '[KDE Desktop Entry]'], [0, '# Config File'], [0, '# KDE Config File']]],
180
+ ['application/x-dia-diagram', [[5..100, '<dia:']]],
181
+ ['application/x-dia-shape', [[5..100, '<shape']]],
182
+ ['application/x-doom-wad', [[0, 'IWAD'], [0, 'PWAD']]],
183
+ ['application/x-dvi', [[0, "\367\002"]]],
184
+ ['application/x-fluid', [[0, '# data file for the Fltk']]],
185
+ ['application/x-font-bdf', [[0, 'STARTFONT ']]],
186
+ ['application/x-font-dos', [[0, "\377FON"], [7, "\000EGA"], [7, "\000VID"]]],
187
+ ['application/x-font-framemaker', [[0, '<MakerScreenFont']]],
188
+ ['application/x-font-libgrx', [[0, "\024\002Y\031"]]],
189
+ ['application/x-font-linux-psf', [[0, "6\004"]]],
190
+ ['application/x-font-otf', [[0, 'OTTO']]],
191
+ ['application/x-font-pcf', [[0, "\001fcp"]]],
192
+ ['application/x-font-speedo', [[0, "D1.0\r"]]],
193
+ ['application/x-font-sunos-news', [[0, 'StartFont'], [0, "\023z)"], [8, "\023z+"]]],
194
+ ['application/x-font-tex', [[0, "\367\203"], [0, "\367Y"], [0, "\367\312"]]],
195
+ ['application/x-font-tex-tfm', [[2, "\000\021"], [2, "\000\022"]]],
196
+ ['application/x-font-ttf', [[0, 'FFIL'], [65, 'FFIL'], [0, "\000\001\000\000\000"]]],
197
+ ['application/x-font-ttx', [[0..256, "<ttFont sfntVersion=\"\\000\\001\\000\\000\" ttLibVersion=\""]]],
198
+ ['application/x-font-vfont', [[0, 'FONT']]],
199
+ ['application/x-frame', [[0, '<MakerFile'], [0, '<MIFFile'], [0, '<MakerDictionary'], [0, '<MakerScreenFon'], [0, '<MML'], [0, '<Book'], [0, '<Maker']]],
200
+ ['application/x-gameboy-rom', [[260, "\316\355ff\314\r\000\v\003s\000\203\000\f\000\r\000\b\021\037\210\211\000\016"]]],
201
+ ['application/x-gamecube-rom', [[28, "\3023\237="]]],
202
+ ['application/x-gdbm', [[0, "\023W\232\316"], [0, "\316\232W\023"], [0, 'GDBM']]],
203
+ ['application/x-gedcom', [[0, '0 HEAD']]],
204
+ ['application/x-genesis-rom', [[256, 'SEGA'], [640, 'EAGN'], [640, 'EAMG']]],
205
+ ['application/x-gettext-translation', [[0, "\336\022\004\225"], [0, "\225\004\022\336"]]],
206
+ ['application/x-glade', [[0..256, '<glade-interface']]],
207
+ ['application/x-gnumeric', [[0..64, 'gmr:Workbook'], [0..64, 'gnm:Workbook']]],
208
+ ['application/x-go-sgf', [[0, '(;FF[3]'], [0, '(;FF[4]']]],
209
+ ['application/x-gtk-builder', [[0..256, '<interface']]],
210
+ ['application/x-gtktalog', [[4, 'gtktalog ']]],
211
+ ['application/x-hdf', [[0, "\211HDF\r\n\032\n"], [0, "\016\003\023\001"]]],
212
+ ['application/x-hwp', [[0, 'HWP Document File']]],
213
+ ['application/x-ipod-firmware', [[0, 'S T O P']]],
214
+ ['application/x-it87', [[0, 'IT8.7']]],
215
+ ['application/x-iwork-keynote-sffkey', [[0, "PK\003\004", [[30, 'index.apxl']]]]],
216
+ ['application/x-java', [[0, "\312\376\272\276"]]],
217
+ ['application/x-java-jce-keystore', [[0, "\316\316\316\316"]]],
218
+ ['application/x-java-jnlp-file', [[0..256, '<jnlp']]],
219
+ ['application/x-java-keystore', [[0, "\355\376\355\376"]]],
220
+ ['application/x-kspread-crypt', [[0, "\r\032'\002"]]],
221
+ ['application/x-ksysv-package', [[4, 'KSysV', [[15, "\001"]]]]],
222
+ ['application/x-kword-crypt', [[0, "\r\032'\001"]]],
223
+ ['application/x-lyx', [[0, '#LyX']]],
224
+ ['application/x-macbinary', [[102, 'mBIN']]],
225
+ ['application/x-matroska', [[0, "\032E\337\243", [[5..65, "B\202", [[8..75, 'matroska']]]]]]],
226
+ ['application/x-ms-dos-executable', [[0, 'MZ']]],
227
+ ['application/x-ms-wim', [[0, "MSWIM\000\000\000"]]],
228
+ ['application/x-mswinurl', [[1, 'InternetShortcut'], [1, 'DEFAULT', [[11, 'BASEURL=']]]]],
229
+ ['application/x-n64-rom', [[0, "\2007\022@"], [0, "7\200@\022"], [0, "@\0227\200"]]],
230
+ ['application/x-nautilus-link', [[0..32, '<nautilus_object nautilus_link']]],
231
+ ['application/x-navi-animation', [[0, 'RIFF', [[8, 'ACON']]]]],
232
+ ['application/x-netshow-channel', [[0, '[Address]']]],
233
+ ['application/x-object', [[0, "\177ELF", [[5, "\001", [[16, "\001\000"]]]]], [0, "\177ELF", [[5, "\002", [[16, "\000\001"]]]]]]],
234
+ ['application/x-ole-storage', [[0, "\320\317\021\340\241\261\032\341"], [0, "\320\317\021\340"]]],
235
+ ['application/x-oleo', [[31, 'Oleo']]],
236
+ ['application/x-pef-executable', [[0, 'Joy!']]],
237
+ ['application/x-perl', [[0, "eval \"exec /usr/local/bin/perl"], [2..16, '/bin/perl'], [2..16, '/bin/env perl'], [0..256, 'use strict'], [0..256, 'use warnings'], [0..256, 'use diagnostics'], [0..256, 'use Test::'], [0..256, 'BEGIN {']]],
238
+ ['application/x-pocket-word', [[0, "{\\pwi"]]],
239
+ ['application/x-python-bytecode', [[0, "\231N\r\n"]]],
240
+ ['application/x-qtiplot', [[0, 'QtiPlot']]],
241
+ ['application/x-rpm', [[0, "\355\253\356\333"]]],
242
+ ['application/x-ruby', [[2..16, '/bin/env ruby'], [2..16, '/bin/ruby']]],
243
+ ['application/x-sami', [[0..256, '<SAMI>']]],
244
+ ['application/x-saturn-rom', [[0, 'SEGA SEGASATURN'], [16, 'SEGA SEGASATURN']]],
245
+ ['application/x-sc', [[38, 'Spreadsheet']]],
246
+ ['application/x-sharedlib', [[0, "\177ELF", [[5, "\001", [[16, "\003\000"]]]]], [0, "\177ELF", [[5, "\002", [[16, "\000\003"]]]]], [0, "\203\001"]]],
247
+ ['application/x-shellscript', [[10, '# This is a shell archive'], [2..16, '/bin/bash'], [2..16, '/bin/nawk'], [2..16, '/bin/zsh'], [2..16, '/bin/sh'], [2..16, '/bin/ksh'], [2..16, '/bin/dash'], [2..16, '/bin/env sh'], [2..16, '/bin/env bash'], [2..16, '/bin/env zsh'], [2..16, '/bin/env ksh']]],
248
+ ['application/x-shorten', [[0, 'ajkg']]],
249
+ ['application/x-smaf', [[0, 'MMMD']]],
250
+ ['application/x-spss-por', [[40, 'ASCII SPSS PORT FILE']]],
251
+ ['application/x-spss-sav', [[0, '$FL2'], [0, '$FL3']]],
252
+ ['application/x-sqlite2', [[0, '** This file contains an SQLite']]],
253
+ ['application/x-sqlite3', [[0, 'SQLite format 3']]],
254
+ ['application/x-subrip', [[0, '1', [[0..256, ' --> ']]]]],
255
+ ['application/x-t602', [[0, '@CT 0'], [0, '@CT 1'], [0, '@CT 2']]],
256
+ ['application/x-tgif', [[0, '%TGIF']]],
257
+ ['application/x-wii-rom', [[24, "]\034\236\243"], [0, 'WBFS'], [0, "WII\001DISC"]]],
258
+ ['application/x-wii-wad', [[4, "Is\000\000"], [4, "ib\000\000"], [4, "Bk\000\000"]]],
259
+ ['application/x-xbel', [[0..256, '<!DOCTYPE xbel']]],
260
+ ['application/x-yaml', [[0, '%YAML']]],
261
+ ['application/xslt+xml', [[0..256, '<xsl:stylesheet']]],
262
+ ['application/xspf+xml', [[0..64, "<playlist version=\"1"], [0..64, "<playlist version='1"]]],
263
+ ['audio/AMR', [[0, "#!AMR\n"], [0, "#!AMR_MC1.0\n"]]],
264
+ ['audio/AMR-WB', [[0, "#!AMR-WB\n"], [0, "#!AMR-WB_MC1.0\n"]]],
265
+ ['audio/ac3', [[0, "\vw"]]],
266
+ ['audio/annodex', [[0, 'OggS', [[28, "fishead\000", [[56..512, "CMML\000\000\000\000"]]]]]]],
267
+ ['audio/midi', [[0, 'MThd']]],
268
+ ['audio/prs.sid', [[0, 'PSID']]],
269
+ ['audio/vnd.dts', [[0, "\177\376\200\001"], [0, "\200\001\177\376"], [0, "\037\377\350\000"], [0, "\350\000\037\377"]]],
270
+ ['audio/x-adpcm', [[0, '.snd', [[12, "\000\000\000\027"]]], [0, ".sd\000", [[12, "\001\000\000\000"], [12, "\002\000\000\000"], [12, "\003\000\000\000"], [12, "\004\000\000\000"], [12, "\005\000\000\000"], [12, "\006\000\000\000"], [12, "\a\000\000\000"], [12, "\027\000\000\000"]]]]],
271
+ ['audio/x-aifc', [[8, 'AIFC']]],
272
+ ['audio/x-aiff', [[8, 'AIFF'], [8, '8SVX']]],
273
+ ['audio/x-ape', [[0, 'MAC ']]],
274
+ ['audio/x-iriver-pla', [[4, 'iriver UMS PLA']]],
275
+ ['audio/x-it', [[0, 'IMPM']]],
276
+ ['audio/x-m4b', [[4, 'ftypM4B']]],
277
+ ['audio/x-mo3', [[0, 'MO3']]],
278
+ ['audio/x-mod', [[0, 'MTM'], [0, 'MMD0'], [0, 'MMD1'], [0, 'if'], [0, 'JN'], [0, 'MAS_UTrack_V00']]],
279
+ ['audio/x-mpegurl', [[0, '#EXTM3U']]],
280
+ ['audio/x-musepack', [[0, 'MP+']]],
281
+ ['audio/x-psf', [[0, 'PSF']]],
282
+ ['audio/x-s3m', [[44, 'SCRM']]],
283
+ ['audio/x-scpls', [[0, '[playlist]'], [0, '[Playlist]'], [0, '[PLAYLIST]']]],
284
+ ['audio/x-speex', [[0, 'Speex']]],
285
+ ['audio/x-stm', [[20, "!Scream!\032"], [20, "!SCREAM!\032"], [20, "BMOD2STM\032"]]],
286
+ ['audio/x-tta', [[0, 'TTA1']]],
287
+ ['audio/x-wavpack', [[0, 'wvpk']]],
288
+ ['audio/x-wavpack-correction', [[0, 'wvpk']]],
289
+ ['audio/x-xi', [[0, 'Extended Instrument:']]],
290
+ ['audio/x-xm', [[0, 'Extended Module:']]],
291
+ ['audio/x-xmf', [[0, 'XMF_'], [0, "XMF_2.00\000\000\000\002"]]],
292
+ ['image/dpx', [[0, 'SDPX']]],
293
+ ['image/fits', [[0, 'SIMPLE =']]],
294
+ ['image/jp2', [[0, "\377O\377Q\000"], [3, "\fjP "], [20, 'jp2']]],
295
+ ['image/openraster', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'image/openraster']]]]]]],
296
+ ['image/vnd.djvu', [[0, 'AT&TFORM', [[12, 'DJVU']]], [0, 'FORM', [[8, 'DJVU']]]]],
297
+ ['image/vnd.djvu+multipage', [[0, 'AT&TFORM', [[12, 'DJVM']]], [0, 'FORM', [[8, 'DJVM']]]]],
298
+ ['image/vnd.dxf', [[0..64, "\nHEADER\n"], [0..64, "\r\nHEADER\r\n"]]],
299
+ ['image/vnd.microsoft.icon', [[0, "\000\000\001\000", [[5, "\000"]]]]],
300
+ ['image/vnd.ms-modi', [[0, "EP*\000"]]],
301
+ ['image/vnd.zbrush.pcx', [[0, "\n", [[1, "\000"], [1, "\002"], [1, "\003"], [1, "\005"]]]]],
302
+ ['image/x-applix-graphics', [[0, '*BEGIN', [[7, 'GRAPHICS']]]]],
303
+ ['image/x-canon-crw', [[0, "II\032\000\000\000HEAPCCDR"]]],
304
+ ['image/x-dds', [[0, 'DDS']]],
305
+ ['image/x-dib', [[0, "(\000\000\000"]]],
306
+ ['image/x-emf', [[0, "\001\000\000\000", [[40, ' EMF', [[44, "\000\000\001\000", [[58, "\000\000"]]]]]]]]],
307
+ ['image/x-exr', [[0, "v/1\001"]]],
308
+ ['image/x-fpx', [[0, 'FPix']]],
309
+ ['image/x-fuji-raf', [[0, 'FUJIFILMCCD-RAW ']]],
310
+ ['image/x-icns', [[0, 'icns']]],
311
+ ['image/x-ilbm', [[8, 'ILBM'], [8, 'PBM ']]],
312
+ ['image/x-minolta-mrw', [[0, "\000MRM"]]],
313
+ ['image/x-olympus-orf', [[0, "IIRO\b\000\000\000"]]],
314
+ ['image/x-panasonic-raw', [[0, "IIU\000\b\000\000\000"]]],
315
+ ['image/x-panasonic-raw2', [[0, "IIU\000\030\000\000\000"]]],
316
+ ['image/x-pict', [[522, "\000\021", [[524, "\002\377", [[526, "\f\000", [[528, "\377\376"]]]]]]]]],
317
+ ['image/x-pict', [[10, "\000\021", [[12, "\002\377", [[14, "\f\000", [[16, "\377\376"]]]]]]]]],
318
+ ['image/x-portable-bitmap', [[0, 'P1', [[2, "\n"], [2, ' '], [2, "\t"], [2, "\r"]]], [0, 'P4', [[2, "\n"], [2, ' '], [2, "\t"], [2, "\r"]]]]],
319
+ ['image/x-portable-graymap', [[0, 'P2', [[2, "\n"], [2, ' '], [2, "\t"], [2, "\r"]]], [0, 'P5', [[2, "\n"], [2, ' '], [2, "\t"], [2, "\r"]]]]],
320
+ ['image/x-portable-pixmap', [[0, 'P3', [[2, "\n"], [2, ' '], [2, "\t"], [2, "\r"]]], [0, 'P6', [[2, "\n"], [2, ' '], [2, "\t"], [2, "\r"]]]]],
321
+ ['image/x-quicktime', [[4, 'idat']]],
322
+ ['image/x-sigma-x3f', [[0, 'FOVb']]],
323
+ ['image/x-skencil', [[0, '##Sketch']]],
324
+ ['image/x-sun-raster', [[0, "Y\246j\225"]]],
325
+ ['image/x-tga', [[1, "\000\002", [[16, "\b"], [16, "\020"], [16, "\030"], [16, ' ']]]]],
326
+ ['image/x-win-bitmap', [[0, "\000\000\002\000", [[5, "\000"]]]]],
327
+ ['image/x-wmf', [[0, "\327\315\306\232", [[22, "\001\000", [[24, "\t\000"]]]]], [0, "\001\000", [[2, "\t\000"]]]]],
328
+ ['image/x-xcf', [[0, 'gimp xcf file'], [0, 'gimp xcf v']]],
329
+ ['image/x-xcursor', [[0, 'Xcur']]],
330
+ ['image/x-xfig', [[0, '#FIG']]],
331
+ ['image/x-xpixmap', [[0, '/* XPM']]],
332
+ ['message/news', [[0, 'Article'], [0, 'Path:'], [0, 'Xref:']]],
333
+ ['message/rfc822', [[0, '#! rnews'], [0, 'Forward to'], [0, 'From:'], [0, 'N#! rnews'], [0, 'Pipe to'], [0, 'Received:'], [0, 'Relay-Version:'], [0, 'Return-Path:'], [0, 'Return-path:'], [0, 'Subject: ']]],
334
+ ['text/cache-manifest', [[0, 'CACHE MANIFEST', [[14, ' '], [14, "\t"], [14, "\n"], [14, "\r"]]]]],
335
+ ['text/calendar', [[0, 'BEGIN:VCALENDAR'], [0, 'begin:vcalendar']]],
336
+ ['text/html', [[0..256, '<!DOCTYPE HTML'], [0..256, '<!doctype html'], [0..256, '<HEAD'], [0..256, '<head'], [0..256, '<TITLE'], [0..256, '<title'], [0..256, '<HTML'], [0..256, '<html'], [0..256, '<SCRIPT'], [0..256, '<script'], [0, '<BODY'], [0, '<body'], [0, '<!--'], [0, '<h1'], [0, '<H1'], [0, '<!doctype HTML'], [0, '<!DOCTYPE html']]],
337
+ ['text/plain', [[0, 'This is TeX,'], [0, 'This is METAFONT,']]],
338
+ ['text/spreadsheet', [[0, 'ID;']]],
339
+ ['text/troff', [[0, ".\\\""], [0, "'\\\""], [0, "'.\\\""], [0, "\\\""]]],
340
+ ['text/vcard', [[0, 'BEGIN:VCARD'], [0, 'begin:vcard']]],
341
+ ['text/vnd.graphviz', [[0, 'digraph '], [0, 'strict digraph '], [0, 'graph '], [0, 'strict graph ']]],
342
+ ['text/vnd.sun.j2me.app-descriptor', [[0, 'MIDlet-']]],
343
+ ['text/vnd.trolltech.linguist', [[0..256, '<TS']]],
344
+ ['text/vtt', [[0, 'WEBVTT']]],
345
+ ['text/x-bibtex', [[0, '% This file was created with JabRef']]],
346
+ ['text/x-emacs-lisp', [[0, "\n("], [0, ";ELC\023\000\000\000"]]],
347
+ ['text/x-gettext-translation-template', [[0..256, "#, fuzzy\nmsgid \"\"\nmsgstr \"\"\n\"Project-Id-Version:"]]],
348
+ ['text/x-google-video-pointer', [[0, '#.download.the.free.Google.Video.Player'], [0, '# download the free Google Video Player']]],
349
+ ['text/x-iMelody', [[0, 'BEGIN:IMELODY']]],
350
+ ['text/x-iptables', [[0..256, '/etc/sysconfig/iptables'], [0..256, '*filter', [[0..256, ':INPUT', [[0..256, ':FORWARD', [[0..256, ':OUTPUT']]]]]]], [0..256, '-A INPUT', [[0..256, '-A FORWARD', [[0..256, '-A OUTPUT']]]]], [0..256, '-P INPUT', [[0..256, '-P FORWARD', [[0..256, '-P OUTPUT']]]]]]],
351
+ ['text/x-ldif', [[0, 'dn: cn='], [0, 'dn: mail=']]],
352
+ ['text/x-lua', [[2..16, '/bin/lua'], [2..16, '/bin/luajit'], [2..16, '/bin/env lua'], [2..16, '/bin/env luajit']]],
353
+ ['text/x-makefile', [[0, '#!/usr/bin/make'], [0, '#! /usr/bin/make']]],
354
+ ['text/x-matlab', [[0, 'function']]],
355
+ ['text/x-microdvd', [[0, '{1}'], [0, '{0}'], [0..6, '}{']]],
356
+ ['text/x-modelica', [[0, 'class']]],
357
+ ['text/x-modelica', [[0, 'record']]],
358
+ ['text/x-modelica', [[0, 'model']]],
359
+ ['text/x-modelica', [[0, 'function']]],
360
+ ['text/x-mpsub', [[0..256, 'FORMAT=']]],
361
+ ['text/x-mrml', [[0, '<mrml ']]],
362
+ ['text/x-ms-regedit', [[0, 'REGEDIT'], [0, 'Windows Registry Editor Version 5.00'], [0, "\377\376W\000i\000n\000d\000o\000w\000s\000 \000R\000e\000g\000i\000s\000t\000r\000y\000 \000E\000d\000i\000t\000o\000r\000"]]],
363
+ ['text/x-mup', [[0, '//!Mup']]],
364
+ ['text/x-patch', [[0, "diff\t"], [0, 'diff '], [0, "***\t"], [0, '*** '], [0, '=== '], [0, '--- '], [0, "Only in\t"], [0, 'Only in '], [0, 'Common subdirectories: '], [0, 'Index:']]],
365
+ ['text/x-python', [[0, '#!/bin/python'], [0, '#! /bin/python'], [0, "eval \"exec /bin/python"], [0, '#!/usr/bin/python'], [0, '#! /usr/bin/python'], [0, "eval \"exec /usr/bin/python"], [0, '#!/usr/local/bin/python'], [0, '#! /usr/local/bin/python'], [0, "eval \"exec /usr/local/bin/python"], [2..16, '/bin/env python']]],
366
+ ['text/x-rpm-spec', [[0, 'Summary: '], [0, '%define ']]],
367
+ ['text/x-ssa', [[0..256, '[Script Info]'], [0..256, 'Dialogue: ']]],
368
+ ['text/x-subviewer', [[0, '[INFORMATION]']]],
369
+ ['text/x-tex', [[1, 'documentclass']]],
370
+ ['text/x-uuencode', [[0, 'begin ']]],
371
+ ['text/xmcd', [[0, '# xmcd']]],
372
+ ['video/3gpp', [[4, 'ftyp3ge'], [4, 'ftyp3gg'], [4, 'ftyp3gp'], [4, 'ftyp3gs']]],
373
+ ['video/3gpp2', [[4, 'ftyp3g2']]],
374
+ ['video/annodex', [[0, 'OggS', [[28, "fishead\000", [[56..512, "CMML\000\000\000\000"]]]]]]],
375
+ ['video/dv', []],
376
+ ['video/mp2t', []],
377
+ ['video/vnd.mpegurl', [[0, '#EXTM4U']]],
378
+ ['video/x-flic', [[0, "\021\257"], [0, "\022\257"]]],
379
+ ['video/x-mng', [[0, "\212MNG\r\n\032\n"]]],
380
+ ['video/x-nsv', [[0, 'NSVf']]],
381
+ ['video/x-sgi-movie', [[0, 'MOVI']]],
382
+ ['x-epoc/x-sisx-app', [[0, "z\032 \020"]]],
383
+ ['application/x-archive', [[0, '<ar>'], [0, '!<arch>']]],
384
+ ['application/x-riff', [[0, 'RIFF']]],
385
+ ['application/x-executable', [[0, "\177ELF", [[5, "\001", [[16, "\002\000"]]]]], [0, "\177ELF", [[5, "\002", [[16, "\000\002"]]]]], [0, 'MZ'], [0, "\034R"], [0, "\020\001"], [0, "\021\001"], [0, "\203\001"]]],
386
+ ['application/x-iff', [[0, 'FORM']]],
387
+ ['application/x-perl', [[0..256, "\n=pod"], [0..256, "\n=head1 NAME"], [0..256, "\n=head1 DESCRIPTION"]]],
388
+ ['application/xml', [[0, '<?xml'], [0, '<!--']]],
389
+ ['application/zip', [[0, "PK\003\004"]]],
390
+ ['audio/basic', [[0, '.snd']]],
391
+ ['video/x-javafx', [[0, 'FLV']]],
392
+ ['application/x-mobipocket-ebook', [[60, 'TEXtREAd']]],
393
+ ['text/x-csrc', [[0, '/*'], [0, '//'], [0, '#include']]],
394
+ ['text/x-objcsrc', [[0, '#import']]],
395
+ ['application/mbox', [[0, 'From ']]],
396
+ ['image/x-tga', [[1, "\001\001"], [1, "\0019"], [1, "\000\003"], [1, "\000\n"], [1, "\000\v"]]],
397
+ ['text/x-matlab', [[0, '%']]],
398
+ ['text/x-matlab', [[0, '##']]],
399
+ ['text/x-modelica', [[0, '//']]],
400
+ ['text/x-tex', [[0, '%']]]
401
+ ]
402
+
403
+ # Detect Magic
404
+ def self.detect_magic data
405
+ MAGIC.find { |_type, magic| check_magic data, magic }
406
+ end
407
+
408
+ # Check Magic
409
+ def self.check_magic data, magic
410
+ magic.any? { |off, val, sub| ((Range === off) ? data.slice(off).include?(val) : (data.slice(off, val.size) == val)) && (!sub || check_magic(data, sub)) }
411
+ end
412
+ end
413
+ end
@@ -0,0 +1,9 @@
1
+ # Typor
2
+ # by Eresse <eresse@eresse.net>
3
+
4
+ # Typor Module
5
+ module Typor
6
+
7
+ # Version
8
+ VERSION = '0.1.0'
9
+ end
data/typor.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'typor/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'typor'
8
+ spec.version = Typor::VERSION
9
+ spec.authors = ['Eresse']
10
+ spec.email = ['eresse@eresse.net']
11
+
12
+ spec.summary = 'Detect File Type from MIME Magic'
13
+ spec.description = 'Provides MIME detection magic based on file contents - nothing more.'
14
+ spec.homepage = 'http://redmine.eresse.net/projects/typor'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_development_dependency 'bundler'
21
+ spec.add_development_dependency 'rake'
22
+ spec.add_runtime_dependency 'minitest'
23
+ spec.add_runtime_dependency 'aromat'
24
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: typor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Eresse
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-02-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: aromat
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Provides MIME detection magic based on file contents - nothing more.
70
+ email:
71
+ - eresse@eresse.net
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - Gemfile.lock
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - lib/typor.rb
83
+ - lib/typor/magic.rb
84
+ - lib/typor/version.rb
85
+ - typor.gemspec
86
+ homepage: http://redmine.eresse.net/projects/typor
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.5.1
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Detect File Type from MIME Magic
110
+ test_files: []