mini_mime 0.1.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yml +40 -0
- data/.github/workflows/db.yml +26 -0
- data/.rubocop.yml +5 -0
- data/CHANGELOG +21 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +1 -1
- data/README.md +39 -21
- data/Rakefile +9 -8
- data/bench/bench.rb +3 -4
- data/bin/console +1 -0
- data/bin/db_pull_request +20 -0
- data/lib/db/content_type_mime.db +36 -13
- data/lib/db/ext_mime.db +53 -18
- data/lib/mini_mime.rb +31 -17
- data/lib/mini_mime/version.rb +2 -1
- data/mini_mime.gemspec +3 -1
- metadata +40 -10
- data/.travis.yml +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5964a78cdb6202afa80b9788475645b553cca8c21d5251688575d6f6aa4c93b1
|
4
|
+
data.tar.gz: 8db41b34cca4eaf5bc9bcef1819b856407634e8fc7e7010f3b92217f2917d05e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99e35154670350af4094cf018cb7d4e51aa5a4611da19c160f47bc34e5f05c168e5c6666ccace0a6471998756cad018ad556c369f309391b4037a1923a6bd7b9
|
7
|
+
data.tar.gz: 5dab4d56f34faba6944d7837a0ca7689d7996cd93e01740739234b5543c3eedb076243b35ae0a33b8948dde24f185b9a7beae372e673add0af0cf780890410d0
|
@@ -0,0 +1,40 @@
|
|
1
|
+
name: Mini Mime Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
push:
|
6
|
+
branches:
|
7
|
+
- master
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
name: "Ruby ${{ matrix.ruby }} / Failure allowed: ${{ matrix.experimental }}"
|
13
|
+
continue-on-error: ${{ matrix.experimental }}
|
14
|
+
strategy:
|
15
|
+
fail-fast: false
|
16
|
+
matrix:
|
17
|
+
ruby: ["2.4", "2.5", "2.6", "2.7"]
|
18
|
+
experimental: [false]
|
19
|
+
include:
|
20
|
+
- ruby: "ruby-head"
|
21
|
+
experimental: true
|
22
|
+
- ruby: "truffleruby-head"
|
23
|
+
experimental: true
|
24
|
+
- ruby: "jruby-head"
|
25
|
+
experimental: true
|
26
|
+
- ruby: "jruby-9.1.17.0"
|
27
|
+
experimental: true
|
28
|
+
- ruby: "jruby-9.2.13.0"
|
29
|
+
experimental: true
|
30
|
+
steps:
|
31
|
+
- uses: actions/checkout@v2
|
32
|
+
- uses: ruby/setup-ruby@v1
|
33
|
+
with:
|
34
|
+
ruby-version: ${{ matrix.ruby }}
|
35
|
+
bundler-cache: true
|
36
|
+
- name: Rubocop
|
37
|
+
run: bundle exec rubocop
|
38
|
+
if: "!contains(matrix.ruby, 'jruby')"
|
39
|
+
- name: Tests
|
40
|
+
run: bundle exec rake test
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: Update MIME type DB
|
2
|
+
|
3
|
+
on:
|
4
|
+
schedule:
|
5
|
+
# 10am on the 1st every month https://crontab.guru/#0_10_1_*_*
|
6
|
+
- cron: "0 10 1 * *"
|
7
|
+
workflow_dispatch:
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
update_db:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
name: "Update MIME type DB"
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
- uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: "2.7"
|
18
|
+
bundler-cache: true
|
19
|
+
- name: Update mime-types-data
|
20
|
+
run: bundle update mime-types-data
|
21
|
+
- name: Update DB
|
22
|
+
run: bundle exec rake rebuild_db
|
23
|
+
- name: Create PR
|
24
|
+
run: bin/db_pull_request
|
25
|
+
env:
|
26
|
+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
data/.rubocop.yml
ADDED
data/CHANGELOG
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
05-04-2021
|
2
|
+
- Version 1.1.0
|
3
|
+
- MiniMime.lookup_by_extension is now case insensitive
|
4
|
+
|
5
|
+
26-03-2021
|
6
|
+
- Version 1.0.3
|
7
|
+
- Update mime types from upstream
|
8
|
+
|
9
|
+
08-07-2019
|
10
|
+
- Version 1.0.2
|
11
|
+
- Update mime types from upstream
|
12
|
+
|
13
|
+
14-08-2018
|
14
|
+
- Version 1.0.1
|
15
|
+
- Update mime types from upstream
|
16
|
+
- Add lookup_by_extension to the public API
|
17
|
+
|
18
|
+
08-11-2017
|
19
|
+
- Version 1.0.0
|
20
|
+
- Other than the version number, no difference from 0.1.4
|
21
|
+
|
1
22
|
11-08-2017
|
2
23
|
- Version 0.1.4
|
3
24
|
- Return preferred extension when looking up by content type
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2016
|
3
|
+
Copyright (c) 2016 Discourse Construction Kit, Inc.
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -26,6 +26,9 @@ require 'mini_mime'
|
|
26
26
|
MiniMime.lookup_by_filename("a.txt").content_type
|
27
27
|
# => "text/plain"
|
28
28
|
|
29
|
+
MiniMime.lookup_by_extension("txt").content_type
|
30
|
+
# => "text/plain"
|
31
|
+
|
29
32
|
MiniMime.lookup_by_content_type("text/plain").extension
|
30
33
|
# => "txt"
|
31
34
|
|
@@ -34,46 +37,63 @@ MiniMime.lookup_by_content_type("text/plain").binary?
|
|
34
37
|
|
35
38
|
```
|
36
39
|
|
40
|
+
## Configuration
|
41
|
+
|
42
|
+
If you'd like to add your own mime types, try using custom database files:
|
43
|
+
|
44
|
+
```
|
45
|
+
MiniMime::Configuration.ext_db_path = "path_to_file_extension_db"
|
46
|
+
MiniMime::Configuration.content_type_db_path = "path_to_content_type_db"
|
47
|
+
```
|
48
|
+
|
49
|
+
Check out the [default databases](lib/db) for proper formatting and structure hints.
|
50
|
+
|
37
51
|
## Performance
|
38
52
|
|
39
|
-
MiniMime is optimised to minimize memory usage. It keeps a cache of 100 mime type lookups (and 100 misses). There are benchmarks in the [bench directory](https://github.com/discourse/mini_mime/bench/bench.rb)
|
53
|
+
MiniMime is optimised to minimize memory usage. It keeps a cache of 100 mime type lookups (and 100 misses). There are benchmarks in the [bench directory](https://github.com/discourse/mini_mime/blob/master/bench/bench.rb)
|
40
54
|
|
41
55
|
```
|
42
56
|
Memory stats for requiring mime/types/columnar
|
43
|
-
Total allocated:
|
44
|
-
Total retained:
|
57
|
+
Total allocated: 8712144 bytes (98242 objects)
|
58
|
+
Total retained: 3372545 bytes (33599 objects)
|
45
59
|
|
46
60
|
Memory stats for requiring mini_mime
|
47
|
-
Total allocated:
|
48
|
-
Total retained:
|
61
|
+
Total allocated: 42625 bytes (369 objects)
|
62
|
+
Total retained: 8992 bytes (72 objects)
|
49
63
|
Warming up --------------------------------------
|
50
64
|
cached content_type lookup MiniMime
|
51
|
-
|
52
|
-
content_type lookup
|
53
|
-
|
65
|
+
85.109k i/100ms
|
66
|
+
content_type lookup MIME::Types
|
67
|
+
17.879k i/100ms
|
54
68
|
Calculating -------------------------------------
|
55
69
|
cached content_type lookup MiniMime
|
56
|
-
|
57
|
-
content_type lookup
|
58
|
-
|
70
|
+
1.105M (± 4.1%) i/s - 5.532M in 5.014895s
|
71
|
+
content_type lookup MIME::Types
|
72
|
+
193.528k (± 7.1%) i/s - 965.466k in 5.013925s
|
59
73
|
Warming up --------------------------------------
|
60
74
|
uncached content_type lookup MiniMime
|
61
|
-
|
62
|
-
content_type lookup
|
63
|
-
|
75
|
+
1.410k i/100ms
|
76
|
+
content_type lookup MIME::Types
|
77
|
+
18.012k i/100ms
|
64
78
|
Calculating -------------------------------------
|
65
79
|
uncached content_type lookup MiniMime
|
66
|
-
|
67
|
-
content_type lookup
|
68
|
-
|
80
|
+
14.689k (± 4.2%) i/s - 73.320k in 5.000779s
|
81
|
+
content_type lookup MIME::Types
|
82
|
+
193.459k (± 6.9%) i/s - 972.648k in 5.050731s
|
69
83
|
```
|
70
84
|
|
71
|
-
As a general guideline, cached lookups are
|
85
|
+
As a general guideline, cached lookups are 6x faster than MIME::Types equivalent. Uncached lookups are 10x slower.
|
86
|
+
|
87
|
+
Note: It was run on macOS 10.14.2, and versions of Ruby and gems are below.
|
72
88
|
|
89
|
+
- Ruby 2.6.0
|
90
|
+
- mini_mime (1.0.1)
|
91
|
+
- mime-types (3.2.2)
|
92
|
+
- mime-types-data (3.2018.0812)
|
73
93
|
|
74
94
|
## Development
|
75
95
|
|
76
|
-
MiniMime uses the officially maintained list of mime types at [mime-types-data](https://github.com/mime-types/mime-types-data)repo to build the internal database.
|
96
|
+
MiniMime uses the officially maintained list of mime types at [mime-types-data](https://github.com/mime-types/mime-types-data) repo to build the internal database.
|
77
97
|
|
78
98
|
To update the database run:
|
79
99
|
|
@@ -89,8 +109,6 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
89
109
|
|
90
110
|
Bug reports and pull requests are welcome on GitHub at https://github.com/discourse/mini_mime. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
91
111
|
|
92
|
-
|
93
112
|
## License
|
94
113
|
|
95
114
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
96
|
-
|
data/Rakefile
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require "bundler/gem_tasks"
|
2
3
|
require "rake/testtask"
|
3
4
|
|
@@ -7,7 +8,7 @@ Rake::TestTask.new(:test) do |t|
|
|
7
8
|
t.test_files = FileList['test/**/*_test.rb']
|
8
9
|
end
|
9
10
|
|
10
|
-
task :
|
11
|
+
task default: :test
|
11
12
|
|
12
13
|
def pad(array)
|
13
14
|
max = []
|
@@ -36,11 +37,11 @@ task :rebuild_db do
|
|
36
37
|
index = {}
|
37
38
|
|
38
39
|
MIME::Types.each do |type|
|
39
|
-
type.extensions.each {|ext| (index[ext.downcase] ||= []) << type}
|
40
|
+
type.extensions.each { |ext| (index[ext.downcase] ||= []) << type }
|
40
41
|
end
|
41
42
|
|
42
|
-
index.each do |k,list|
|
43
|
-
list.sort!{|a,b| a.priority_compare(b)}
|
43
|
+
index.each do |k, list|
|
44
|
+
list.sort! { |a, b| a.priority_compare(b) }
|
44
45
|
end
|
45
46
|
|
46
47
|
buffer = []
|
@@ -54,9 +55,9 @@ task :rebuild_db do
|
|
54
55
|
|
55
56
|
pad(buffer)
|
56
57
|
|
57
|
-
buffer.sort!{|a,b| a[0] <=> b[0]}
|
58
|
+
buffer.sort! { |a, b| a[0] <=> b[0] }
|
58
59
|
|
59
|
-
File.open("lib/db/ext_mime.db", File::CREAT|File::TRUNC|File::RDWR) do |f|
|
60
|
+
File.open("lib/db/ext_mime.db", File::CREAT | File::TRUNC | File::RDWR) do |f|
|
60
61
|
buffer.each do |row|
|
61
62
|
f.write "#{row[0]} #{row[1]} #{row[2]}\n"
|
62
63
|
end
|
@@ -64,7 +65,7 @@ task :rebuild_db do
|
|
64
65
|
|
65
66
|
puts "#{buffer.count} rows written to lib/db/ext_mime.db"
|
66
67
|
|
67
|
-
buffer.sort!{|a,b| [a[1], a[0]] <=> [b[1], b[0]]}
|
68
|
+
buffer.sort! { |a, b| [a[1], a[0]] <=> [b[1], b[0]] }
|
68
69
|
|
69
70
|
# strip cause we are going to re-pad
|
70
71
|
buffer.each do |row|
|
@@ -80,7 +81,7 @@ task :rebuild_db do
|
|
80
81
|
|
81
82
|
pad(buffer)
|
82
83
|
|
83
|
-
File.open("lib/db/content_type_mime.db", File::CREAT|File::TRUNC|File::RDWR) do |f|
|
84
|
+
File.open("lib/db/content_type_mime.db", File::CREAT | File::TRUNC | File::RDWR) do |f|
|
84
85
|
last = nil
|
85
86
|
count = 0
|
86
87
|
buffer.each do |row|
|
data/bench/bench.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'memory_profiler'
|
2
3
|
require 'benchmark/ips'
|
3
4
|
|
4
5
|
$: << File.expand_path('../../lib', __FILE__)
|
5
6
|
|
6
|
-
|
7
7
|
puts
|
8
8
|
puts "Memory stats for requiring mime/types/columnar"
|
9
9
|
result = MemoryProfiler.report do
|
@@ -22,13 +22,12 @@ end
|
|
22
22
|
puts "Total allocated: #{result.total_allocated_memsize} bytes (#{result.total_allocated} objects)"
|
23
23
|
puts "Total retained: #{result.total_retained_memsize} bytes (#{result.total_retained} objects)"
|
24
24
|
|
25
|
-
|
26
25
|
Benchmark.ips do |bm|
|
27
26
|
bm.report 'cached content_type lookup MiniMime' do
|
28
27
|
MiniMime.lookup_by_filename("a.txt").content_type
|
29
28
|
end
|
30
29
|
|
31
|
-
bm.report 'content_type lookup
|
30
|
+
bm.report 'content_type lookup MIME::Types' do
|
32
31
|
MIME::Types.type_for("a.txt")[0].content_type
|
33
32
|
end
|
34
33
|
end
|
@@ -46,7 +45,7 @@ Benchmark.ips do |bm|
|
|
46
45
|
MiniMime.lookup_by_filename("a.txt").content_type
|
47
46
|
end
|
48
47
|
|
49
|
-
bm.report 'content_type lookup
|
48
|
+
bm.report 'content_type lookup MIME::Types' do
|
50
49
|
MIME::Types.type_for("a.txt")[0].content_type
|
51
50
|
end
|
52
51
|
end
|
data/bin/console
CHANGED
data/bin/db_pull_request
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "time"
|
5
|
+
|
6
|
+
if `git status --porcelain lib/db`.empty?
|
7
|
+
puts "Skipping, no DB changes to commit..."
|
8
|
+
return
|
9
|
+
end
|
10
|
+
|
11
|
+
moment = Time.now.utc
|
12
|
+
branch_name = "db-updates-#{moment.strftime("%Y%m%d%H%M%S")}"
|
13
|
+
|
14
|
+
system("git", "checkout", "-b", branch_name) || abort("Unable to create branch")
|
15
|
+
system("git", "add", "lib/db")
|
16
|
+
system("git", "config", "--local", "user.email", "actions@github.com")
|
17
|
+
system("git", "config", "--local", "user.name", "github-actions")
|
18
|
+
system("git", "commit", "-m", "DB updates #{moment.iso8601}") || abort("Unable to commit changes")
|
19
|
+
system("git", "push", "-u", "origin", branch_name) || abort("Unable to push branch")
|
20
|
+
system("gh", "pr", "create", "--title", "DB updates #{moment.iso8601}", "--body", "From Github Actions") || abort("Unable to create PR")
|
data/lib/db/content_type_mime.db
CHANGED
@@ -19,9 +19,7 @@ ecma application/ecmascript
|
|
19
19
|
emma application/emma+xml base64
|
20
20
|
epub application/epub+zip base64
|
21
21
|
exi application/exi base64
|
22
|
-
otf application/font-sfnt base64
|
23
22
|
pfr application/font-tdpfr base64
|
24
|
-
woff application/font-woff base64
|
25
23
|
gml application/gml+xml base64
|
26
24
|
gpx application/gpx+xml base64
|
27
25
|
gxf application/gxf base64
|
@@ -31,7 +29,6 @@ ink application/inkml+xml
|
|
31
29
|
ipfix application/ipfix base64
|
32
30
|
jar application/java-archive base64
|
33
31
|
ser application/java-serialized-object base64
|
34
|
-
class application/java-vm base64
|
35
32
|
js application/javascript 8bit
|
36
33
|
json application/json 8bit
|
37
34
|
jsonml application/jsonml+json base64
|
@@ -74,8 +71,7 @@ crl application/pkix-crl
|
|
74
71
|
pkipath application/pkix-pkipath base64
|
75
72
|
pki application/pkixcmp base64
|
76
73
|
pls application/pls+xml base64
|
77
|
-
|
78
|
-
ppt application/powerpoint base64
|
74
|
+
eps application/postscript 8bit
|
79
75
|
cw application/prs.cww base64
|
80
76
|
rnd application/prs.nprend base64
|
81
77
|
pskcxml application/pskc+xml base64
|
@@ -325,6 +321,7 @@ thmx application/vnd.ms-officetheme
|
|
325
321
|
msg application/vnd.ms-outlook base64
|
326
322
|
cat application/vnd.ms-pki.seccat base64
|
327
323
|
stl application/vnd.ms-pki.stl base64
|
324
|
+
ppt application/vnd.ms-powerpoint base64
|
328
325
|
ppam application/vnd.ms-powerpoint.addin.macroEnabled.12 base64
|
329
326
|
pptm application/vnd.ms-powerpoint.presentation.macroEnabled.12 base64
|
330
327
|
sldm application/vnd.ms-powerpoint.slide.macroEnabled.12 base64
|
@@ -490,10 +487,10 @@ cmp application/vnd.yellowriver-custom-menu
|
|
490
487
|
zir application/vnd.zul base64
|
491
488
|
zaz application/vnd.zzazz.deck+xml base64
|
492
489
|
vxml application/voicexml+xml base64
|
490
|
+
wasm application/wasm 8bit
|
493
491
|
wif application/watcherinfo+xml base64
|
494
492
|
wgt application/widget base64
|
495
|
-
|
496
|
-
wp application/wordperfect5.1 base64
|
493
|
+
wp5 application/wordperfect5.1 base64
|
497
494
|
wsdl application/wsdl+xml base64
|
498
495
|
wspolicy application/wspolicy+xml base64
|
499
496
|
wk application/x-123 base64
|
@@ -538,7 +535,6 @@ gsf application/x-font-ghostscript
|
|
538
535
|
psf application/x-font-linux-psf base64
|
539
536
|
pcf application/x-font-pcf base64
|
540
537
|
snf application/x-font-snf base64
|
541
|
-
ttc application/x-font-ttf base64
|
542
538
|
afm application/x-font-type1 base64
|
543
539
|
arc application/x-freearc base64
|
544
540
|
spl application/x-futuresplash base64
|
@@ -565,11 +561,12 @@ cpt application/x-mac-compactpro
|
|
565
561
|
mie application/x-mie base64
|
566
562
|
mobi application/x-mobipocket-ebook base64
|
567
563
|
application application/x-ms-application base64
|
564
|
+
exe application/x-ms-dos-executable base64
|
568
565
|
lnk application/x-ms-shortcut base64
|
569
566
|
wmd application/x-ms-wmd base64
|
570
567
|
wmz application/x-ms-wmz base64
|
571
568
|
xbap application/x-ms-xbap base64
|
572
|
-
|
569
|
+
mda application/x-msaccess base64
|
573
570
|
obd application/x-msbinder base64
|
574
571
|
crd application/x-mscardfile base64
|
575
572
|
clp application/x-msclip base64
|
@@ -599,6 +596,7 @@ sh application/x-sh
|
|
599
596
|
shar application/x-shar 8bit
|
600
597
|
swf application/x-shockwave-flash base64
|
601
598
|
xap application/x-silverlight-app base64
|
599
|
+
notebook application/x-smarttech-notebook base64
|
602
600
|
sav application/x-spss base64
|
603
601
|
sql application/x-sql base64
|
604
602
|
sit application/x-stuffit base64
|
@@ -615,9 +613,6 @@ tfm application/x-tex-tfm
|
|
615
613
|
texinfo application/x-texinfo 8bit
|
616
614
|
obj application/x-tgif base64
|
617
615
|
tbk application/x-toolbook base64
|
618
|
-
man application/x-troff-man 8bit
|
619
|
-
me application/x-troff-me base64
|
620
|
-
ms application/x-troff-ms base64
|
621
616
|
ustar application/x-ustar base64
|
622
617
|
src application/x-wais-source base64
|
623
618
|
webapp application/x-web-app-manifest+json base64
|
@@ -671,6 +666,7 @@ ecelp9600 audio/vnd.nuera.ecelp9600
|
|
671
666
|
qcp audio/vnd.qcelp base64
|
672
667
|
rip audio/vnd.rip base64
|
673
668
|
smp3 audio/vnd.sealedmedia.softseal.mpeg base64
|
669
|
+
wav audio/wav base64
|
674
670
|
weba audio/webm base64
|
675
671
|
aac audio/x-aac base64
|
676
672
|
aif audio/x-aiff base64
|
@@ -683,16 +679,25 @@ wma audio/x-ms-wma
|
|
683
679
|
wmv audio/x-ms-wmv base64
|
684
680
|
ra audio/x-pn-realaudio base64
|
685
681
|
rmp audio/x-pn-realaudio-plugin base64
|
686
|
-
wav audio/x-wav base64
|
687
682
|
xm audio/xm base64
|
688
683
|
cdx chemical/x-cdx base64
|
689
684
|
cif chemical/x-cif base64
|
690
685
|
cmdf chemical/x-cmdf base64
|
691
686
|
cml chemical/x-cml base64
|
692
687
|
csml chemical/x-csml base64
|
688
|
+
ttc font/collection base64
|
689
|
+
otf font/otf base64
|
690
|
+
ttf font/ttf base64
|
691
|
+
woff font/woff base64
|
692
|
+
woff2 font/woff2 base64
|
693
|
+
avif image/avif base64
|
693
694
|
cgm image/cgm base64
|
694
695
|
g3 image/g3fax base64
|
695
696
|
gif image/gif base64
|
697
|
+
heic image/heic base64
|
698
|
+
heics image/heic-sequence base64
|
699
|
+
heif image/heif base64
|
700
|
+
heifs image/heif-sequence base64
|
696
701
|
ief image/ief base64
|
697
702
|
jp2 image/jp2 base64
|
698
703
|
jpeg image/jpeg base64
|
@@ -724,21 +729,37 @@ wbmp image/vnd.wap.wbmp
|
|
724
729
|
xif image/vnd.xiff base64
|
725
730
|
webp image/webp base64
|
726
731
|
3ds image/x-3ds base64
|
732
|
+
dng image/x-adobe-dng base64
|
727
733
|
bmp image/x-bmp base64
|
734
|
+
cr2 image/x-canon-cr2 base64
|
735
|
+
crw image/x-canon-crw base64
|
728
736
|
ras image/x-cmu-raster base64
|
729
737
|
cmx image/x-cmx base64
|
730
738
|
xcfbz2 image/x-compressed-xcf base64
|
739
|
+
erf image/x-epson-erf base64
|
731
740
|
fh image/x-freehand base64
|
741
|
+
raf image/x-fuji-raf base64
|
732
742
|
3fr image/x-hasselblad-3fr base64
|
743
|
+
k25 image/x-kodak-k25 base64
|
744
|
+
kdc image/x-kodak-kdc base64
|
745
|
+
mrw image/x-minolta-mrw base64
|
733
746
|
sid image/x-mrsid-image base64
|
747
|
+
nef image/x-nikon-nef base64
|
748
|
+
orf image/x-olympus-orf base64
|
734
749
|
psp image/x-paintshoppro base64
|
750
|
+
raw image/x-panasonic-raw base64
|
735
751
|
pcx image/x-pcx base64
|
752
|
+
pef image/x-pentax-pef base64
|
736
753
|
pct image/x-pict base64
|
737
754
|
pnm image/x-portable-anymap base64
|
738
755
|
pbm image/x-portable-bitmap base64
|
739
756
|
pgm image/x-portable-graymap base64
|
740
757
|
ppm image/x-portable-pixmap base64
|
741
758
|
rgb image/x-rgb base64
|
759
|
+
x3f image/x-sigma-x3f base64
|
760
|
+
arw image/x-sony-arw base64
|
761
|
+
sr2 image/x-sony-sr2 base64
|
762
|
+
srf image/x-sony-srf base64
|
742
763
|
tga image/x-targa base64
|
743
764
|
dgn image/x-vnd.dgn base64
|
744
765
|
xbm image/x-xbitmap 7bit
|
@@ -765,6 +786,7 @@ ics text/calendar
|
|
765
786
|
css text/css 8bit
|
766
787
|
csv text/csv 8bit
|
767
788
|
html text/html 8bit
|
789
|
+
markdown text/markdown quoted-printable
|
768
790
|
n3 text/n3 quoted-printable
|
769
791
|
txt text/plain quoted-printable
|
770
792
|
dsc text/prs.lines.tag quoted-printable
|
@@ -804,6 +826,7 @@ uu text/x-uuencode
|
|
804
826
|
vcs text/x-vcalendar 8bit
|
805
827
|
vcf text/x-vcard 8bit
|
806
828
|
yaml text/x-yaml 8bit
|
829
|
+
xml text/xml 8bit
|
807
830
|
3gp video/3gpp base64
|
808
831
|
3g2 video/3gpp2 base64
|
809
832
|
dv video/DV base64
|
data/lib/db/ext_mime.db
CHANGED
@@ -24,7 +24,7 @@ aep application/vnd.audiograph
|
|
24
24
|
afm application/x-font-type1 base64
|
25
25
|
afp application/vnd.ibm.modcap base64
|
26
26
|
ahead application/vnd.ahead.space base64
|
27
|
-
ai application/
|
27
|
+
ai application/pdf base64
|
28
28
|
aif audio/x-aiff base64
|
29
29
|
aifc audio/x-aiff base64
|
30
30
|
aiff audio/x-aiff base64
|
@@ -38,6 +38,7 @@ appcache text/cache-manifest
|
|
38
38
|
application application/x-ms-application base64
|
39
39
|
apr application/vnd.lotus-approach base64
|
40
40
|
arc application/x-freearc base64
|
41
|
+
arw image/x-sony-arw base64
|
41
42
|
asc application/pgp-signature base64
|
42
43
|
asf application/vnd.ms-asf base64
|
43
44
|
asm text/x-asm quoted-printable
|
@@ -50,6 +51,7 @@ atomsvc application/atomsvc+xml
|
|
50
51
|
atx application/vnd.antix.game-component base64
|
51
52
|
au audio/basic base64
|
52
53
|
avi video/x-msvideo base64
|
54
|
+
avif image/avif base64
|
53
55
|
aw application/applixware base64
|
54
56
|
awb audio/AMR-WB base64
|
55
57
|
azf application/vnd.airzip.filesecure.azf base64
|
@@ -120,13 +122,14 @@ cif chemical/x-cif
|
|
120
122
|
cii application/vnd.anser-web-certificate-issue-initiation base64
|
121
123
|
cil application/vnd.ms-artgalry base64
|
122
124
|
cla application/vnd.claymore base64
|
123
|
-
class application/
|
125
|
+
class application/octet-stream base64
|
124
126
|
clkk application/vnd.crick.clicker.keyboard base64
|
125
127
|
clkp application/vnd.crick.clicker.palette base64
|
126
128
|
clkt application/vnd.crick.clicker.template base64
|
127
129
|
clkw application/vnd.crick.clicker.wordbank base64
|
128
130
|
clkx application/vnd.crick.clicker base64
|
129
131
|
clp application/x-msclip base64
|
132
|
+
clpi video/MP2T base64
|
130
133
|
cmc application/vnd.cosmocaller base64
|
131
134
|
cmd application/x-msdos-program base64
|
132
135
|
cmdf chemical/x-cmdf base64
|
@@ -137,12 +140,15 @@ cod application/vnd.rim.cod
|
|
137
140
|
coffee text/x-coffescript 8bit
|
138
141
|
com application/x-msdos-program base64
|
139
142
|
conf text/plain quoted-printable
|
143
|
+
cpi video/MP2T base64
|
140
144
|
cpio application/x-cpio base64
|
141
145
|
cpp text/plain quoted-printable
|
142
146
|
cpt application/x-mac-compactpro base64
|
147
|
+
cr2 image/x-canon-cr2 base64
|
143
148
|
crd application/x-mscardfile base64
|
144
149
|
crl application/pkix-crl base64
|
145
150
|
crt application/x-x509-ca-cert base64
|
151
|
+
crw image/x-canon-crw base64
|
146
152
|
crx application/x-chrome-extension base64
|
147
153
|
cryptonote application/vnd.rig.cryptonote base64
|
148
154
|
csh application/x-csh 8bit
|
@@ -190,6 +196,7 @@ dmg application/x-apple-diskimage
|
|
190
196
|
dmp application/vnd.tcpdump.pcap base64
|
191
197
|
dms application/octet-stream base64
|
192
198
|
dna application/vnd.dna base64
|
199
|
+
dng image/x-adobe-dng base64
|
193
200
|
doc application/msword base64
|
194
201
|
docm application/vnd.ms-word.document.macroEnabled.12 base64
|
195
202
|
docx application/vnd.openxmlformats-officedocument.wordprocessingml.document base64
|
@@ -235,6 +242,8 @@ eol audio/vnd.digital-winds
|
|
235
242
|
eot application/vnd.ms-fontobject base64
|
236
243
|
eps application/postscript 8bit
|
237
244
|
epub application/epub+zip base64
|
245
|
+
erf image/x-epson-erf base64
|
246
|
+
es application/ecmascript base64
|
238
247
|
es3 application/vnd.eszigno3+xml base64
|
239
248
|
esa application/vnd.osgi.subsystem base64
|
240
249
|
esf application/vnd.epson.esf base64
|
@@ -243,7 +252,7 @@ etx text/x-setext
|
|
243
252
|
eva application/x-eva base64
|
244
253
|
evc audio/EVRC base64
|
245
254
|
evy application/x-envoy base64
|
246
|
-
exe application/
|
255
|
+
exe application/x-ms-dos-executable base64
|
247
256
|
exi application/exi base64
|
248
257
|
ext application/vnd.novadigm.EXT base64
|
249
258
|
ez application/andrew-inset base64
|
@@ -337,9 +346,14 @@ hal application/vnd.hal+xml
|
|
337
346
|
hbc application/vnd.hbci base64
|
338
347
|
hbci application/vnd.hbci base64
|
339
348
|
hdf application/x-hdf base64
|
349
|
+
heic image/heic base64
|
350
|
+
heics image/heic-sequence base64
|
351
|
+
heif image/heif base64
|
352
|
+
heifs image/heif-sequence base64
|
340
353
|
hep application/x-hep base64
|
341
354
|
hh text/plain quoted-printable
|
342
|
-
|
355
|
+
hif image/heic base64
|
356
|
+
hlp text/plain quoted-printable
|
343
357
|
hpgl application/vnd.hp-HPGL base64
|
344
358
|
hpid application/vnd.hp-hpid base64
|
345
359
|
hpp text/plain quoted-printable
|
@@ -380,6 +394,7 @@ ink application/inkml+xml
|
|
380
394
|
inkml application/inkml+xml base64
|
381
395
|
install application/x-install-instructions base64
|
382
396
|
iota application/vnd.astraea-software.iota base64
|
397
|
+
ipa application/octet-stream base64
|
383
398
|
ipfix application/ipfix base64
|
384
399
|
ipk application/vnd.shana.informed.package base64
|
385
400
|
irm application/vnd.ibm.rights-management base64
|
@@ -410,9 +425,11 @@ jpx image/jpx
|
|
410
425
|
js application/javascript 8bit
|
411
426
|
json application/json 8bit
|
412
427
|
jsonml application/jsonml+json base64
|
428
|
+
k25 image/x-kodak-k25 base64
|
413
429
|
kar audio/midi base64
|
414
430
|
karbon application/vnd.kde.karbon base64
|
415
431
|
kcm application/vnd.nervana base64
|
432
|
+
kdc image/x-kodak-kdc base64
|
416
433
|
key application/x-iwork-keynote-sffkey base64
|
417
434
|
kfo application/vnd.kde.kformula base64
|
418
435
|
kia application/vnd.kidspiration base64
|
@@ -457,6 +474,7 @@ m14 application/x-msmediaview
|
|
457
474
|
m1v video/mpeg base64
|
458
475
|
m21 application/mp21 base64
|
459
476
|
m2a audio/mpeg base64
|
477
|
+
m2ts video/MP2T base64
|
460
478
|
m2v video/mpeg base64
|
461
479
|
m3a audio/mpeg base64
|
462
480
|
m3u audio/x-mpegurl base64
|
@@ -468,10 +486,10 @@ ma application/mathematica
|
|
468
486
|
mads application/mads+xml base64
|
469
487
|
mag application/vnd.ecowin.chart base64
|
470
488
|
maker application/vnd.framemaker base64
|
471
|
-
man
|
489
|
+
man text/troff 8bit
|
472
490
|
manifest text/cache-manifest quoted-printable
|
473
491
|
mar application/octet-stream base64
|
474
|
-
markdown text/
|
492
|
+
markdown text/markdown quoted-printable
|
475
493
|
mathml application/mathml+xml base64
|
476
494
|
mb application/mathematica base64
|
477
495
|
mbk application/vnd.Mobius.MBK base64
|
@@ -479,13 +497,13 @@ mbox application/mbox
|
|
479
497
|
mc1 application/vnd.medcalcdata base64
|
480
498
|
mcd application/vnd.mcd base64
|
481
499
|
mcurl text/vnd.curl.mcurl quoted-printable
|
482
|
-
md text/
|
500
|
+
md text/markdown quoted-printable
|
483
501
|
mda application/x-msaccess base64
|
484
502
|
mdb application/x-msaccess base64
|
485
503
|
mde application/x-msaccess base64
|
486
504
|
mdf application/x-msaccess base64
|
487
505
|
mdi image/vnd.ms-modi base64
|
488
|
-
me
|
506
|
+
me text/troff 8bit
|
489
507
|
mesh model/mesh base64
|
490
508
|
meta4 application/metalink4+xml base64
|
491
509
|
metalink application/metalink+xml base64
|
@@ -503,8 +521,10 @@ mj2 video/MJ2
|
|
503
521
|
mjp2 video/MJ2 base64
|
504
522
|
mjpeg video/x-motion-jpeg base64
|
505
523
|
mjpg video/x-motion-jpeg base64
|
524
|
+
mjs application/javascript 8bit
|
506
525
|
mk3d video/x-matroska base64
|
507
526
|
mka audio/x-matroska base64
|
527
|
+
mkd text/markdown quoted-printable
|
508
528
|
mks video/x-matroska base64
|
509
529
|
mkv video/x-matroska base64
|
510
530
|
mlp application/vnd.dolby.mlp base64
|
@@ -533,6 +553,8 @@ mpg video/mpeg
|
|
533
553
|
mpg4 application/mp4 base64
|
534
554
|
mpga audio/mpeg base64
|
535
555
|
mpkg application/vnd.apple.installer+xml base64
|
556
|
+
mpl video/MP2T base64
|
557
|
+
mpls video/MP2T base64
|
536
558
|
mpm application/vnd.blueice.multipass base64
|
537
559
|
mpn application/vnd.mophun.application base64
|
538
560
|
mpp application/vnd.ms-project base64
|
@@ -541,7 +563,8 @@ mpy application/vnd.ibm.MiniPay
|
|
541
563
|
mqy application/vnd.Mobius.MQY base64
|
542
564
|
mrc application/marc base64
|
543
565
|
mrcx application/marcxml+xml base64
|
544
|
-
|
566
|
+
mrw image/x-minolta-mrw base64
|
567
|
+
ms text/troff 8bit
|
545
568
|
mscml application/mediaservercontrol+xml base64
|
546
569
|
mseed application/vnd.fdsn.mseed base64
|
547
570
|
mseq application/vnd.mseq base64
|
@@ -568,6 +591,7 @@ nb application/mathematica
|
|
568
591
|
nbp application/vnd.wolfram.player base64
|
569
592
|
nc application/netcdf base64
|
570
593
|
ncx application/x-dtbncx+xml base64
|
594
|
+
nef image/x-nikon-nef base64
|
571
595
|
nfo text/x-nfo quoted-printable
|
572
596
|
ngdat application/vnd.nokia.n-gage.data base64
|
573
597
|
nim video/vnd.nokia.interleaved-multimedia base64
|
@@ -577,6 +601,7 @@ nml application/vnd.enliven
|
|
577
601
|
nnd application/vnd.noblenet-directory base64
|
578
602
|
nns application/vnd.noblenet-sealer base64
|
579
603
|
nnw application/vnd.noblenet-web base64
|
604
|
+
notebook application/x-smarttech-notebook base64
|
580
605
|
npx image/vnd.net-fpx base64
|
581
606
|
nsc application/x-conference base64
|
582
607
|
nsf application/vnd.lotus-notes base64
|
@@ -612,11 +637,13 @@ onetoc2 application/onenote
|
|
612
637
|
opf application/oebps-package+xml base64
|
613
638
|
opml text/x-opml quoted-printable
|
614
639
|
oprc application/vnd.palm base64
|
640
|
+
opus audio/ogg base64
|
641
|
+
orf image/x-olympus-orf base64
|
615
642
|
org application/vnd.lotus-organizer base64
|
616
643
|
osf application/vnd.yamaha.openscoreformat base64
|
617
644
|
osfpvg application/vnd.yamaha.openscoreformat.osfpvg+xml base64
|
618
645
|
otc application/vnd.oasis.opendocument.chart-template base64
|
619
|
-
otf
|
646
|
+
otf font/otf base64
|
620
647
|
otg application/vnd.oasis.opendocument.graphics-template base64
|
621
648
|
oth application/vnd.oasis.opendocument.text-web base64
|
622
649
|
oti application/vnd.oasis.opendocument.image-template base64
|
@@ -649,6 +676,7 @@ pcurl application/vnd.curl.pcurl
|
|
649
676
|
pcx image/x-pcx base64
|
650
677
|
pdb application/vnd.palm base64
|
651
678
|
pdf application/pdf base64
|
679
|
+
pef image/x-pentax-pef base64
|
652
680
|
pfa application/x-font-type1 base64
|
653
681
|
pfb application/x-font-type1 base64
|
654
682
|
pfm application/x-font-type1 base64
|
@@ -680,16 +708,16 @@ pml application/vnd.ctc-posml
|
|
680
708
|
png image/png base64
|
681
709
|
pnm image/x-portable-anymap base64
|
682
710
|
portpkg application/vnd.macports.portpkg base64
|
683
|
-
pot application/powerpoint
|
711
|
+
pot application/vnd.ms-powerpoint base64
|
684
712
|
potm application/vnd.ms-powerpoint.template.macroEnabled.12 base64
|
685
713
|
potx application/vnd.openxmlformats-officedocument.presentationml.template base64
|
686
714
|
ppam application/vnd.ms-powerpoint.addin.macroEnabled.12 base64
|
687
715
|
ppd application/vnd.cups-ppd base64
|
688
716
|
ppm image/x-portable-pixmap base64
|
689
|
-
pps application/powerpoint
|
717
|
+
pps application/vnd.ms-powerpoint base64
|
690
718
|
ppsm application/vnd.ms-powerpoint.slideshow.macroEnabled.12 base64
|
691
719
|
ppsx application/vnd.openxmlformats-officedocument.presentationml.slideshow base64
|
692
|
-
ppt application/powerpoint
|
720
|
+
ppt application/vnd.ms-powerpoint base64
|
693
721
|
pptm application/vnd.ms-powerpoint.presentation.macroEnabled.12 base64
|
694
722
|
pptx application/vnd.openxmlformats-officedocument.presentationml.presentation base64
|
695
723
|
pqa application/vnd.palm base64
|
@@ -727,9 +755,11 @@ qxd application/vnd.Quark.QuarkXPress
|
|
727
755
|
qxl application/vnd.Quark.QuarkXPress 8bit
|
728
756
|
qxt application/vnd.Quark.QuarkXPress 8bit
|
729
757
|
ra audio/x-pn-realaudio base64
|
758
|
+
raf image/x-fuji-raf base64
|
730
759
|
ram audio/x-pn-realaudio base64
|
731
760
|
rar application/x-rar-compressed base64
|
732
761
|
ras image/x-cmu-raster base64
|
762
|
+
raw image/x-panasonic-raw base64
|
733
763
|
rb application/x-ruby 8bit
|
734
764
|
rbw application/x-ruby 8bit
|
735
765
|
rcprofile application/vnd.ipunplugged.rcprofile base64
|
@@ -874,7 +904,9 @@ spq application/scvp-vp-request
|
|
874
904
|
sps application/x-spss base64
|
875
905
|
spx audio/ogg base64
|
876
906
|
sql application/x-sql base64
|
907
|
+
sr2 image/x-sony-sr2 base64
|
877
908
|
src application/x-wais-source base64
|
909
|
+
srf image/x-sony-srf base64
|
878
910
|
srt application/x-subrip base64
|
879
911
|
sru application/sru+xml base64
|
880
912
|
srx application/sparql-results+xml base64
|
@@ -951,8 +983,8 @@ troff text/troff
|
|
951
983
|
ts video/MP2T base64
|
952
984
|
tsd application/timestamped-data base64
|
953
985
|
tsv text/tab-separated-values quoted-printable
|
954
|
-
ttc
|
955
|
-
ttf
|
986
|
+
ttc font/collection base64
|
987
|
+
ttf font/ttf base64
|
956
988
|
ttl text/turtle quoted-printable
|
957
989
|
twd application/vnd.SimTech-MindMapper base64
|
958
990
|
twds application/vnd.SimTech-MindMapper base64
|
@@ -1027,7 +1059,8 @@ vtu model/vnd.vtu
|
|
1027
1059
|
vxml application/voicexml+xml base64
|
1028
1060
|
w3d application/x-director base64
|
1029
1061
|
wad application/x-doom base64
|
1030
|
-
|
1062
|
+
wasm application/wasm 8bit
|
1063
|
+
wav audio/wav base64
|
1031
1064
|
wax audio/x-ms-wax base64
|
1032
1065
|
wbmp image/vnd.wap.wbmp base64
|
1033
1066
|
wbs application/vnd.criticaltools.wbs+xml base64
|
@@ -1056,8 +1089,8 @@ wmlsc application/vnd.wap.wmlscriptc
|
|
1056
1089
|
wmv audio/x-ms-wmv base64
|
1057
1090
|
wmx video/x-ms-wmx base64
|
1058
1091
|
wmz application/x-ms-wmz base64
|
1059
|
-
woff
|
1060
|
-
woff2
|
1092
|
+
woff font/woff base64
|
1093
|
+
woff2 font/woff2 base64
|
1061
1094
|
wp application/wordperfect5.1 base64
|
1062
1095
|
wp5 application/wordperfect5.1 base64
|
1063
1096
|
wp6 application/x-wordperfect6.1 base64
|
@@ -1081,6 +1114,7 @@ x3dbz model/x3d+binary
|
|
1081
1114
|
x3dv model/x3d+vrml base64
|
1082
1115
|
x3dvz model/x3d+vrml base64
|
1083
1116
|
x3dz model/x3d+xml base64
|
1117
|
+
x3f image/x-sigma-x3f base64
|
1084
1118
|
x_b model/vnd.parasolid.transmit.binary base64
|
1085
1119
|
x_t model/vnd.parasolid.transmit.text quoted-printable
|
1086
1120
|
xaml application/xaml+xml base64
|
@@ -1131,6 +1165,7 @@ xpr application/vnd.is-xpr
|
|
1131
1165
|
xps application/vnd.ms-xpsdocument 8bit
|
1132
1166
|
xpw application/vnd.intercon.formnet base64
|
1133
1167
|
xpx application/vnd.intercon.formnet base64
|
1168
|
+
xsd text/xml 8bit
|
1134
1169
|
xsl application/xml 8bit
|
1135
1170
|
xslt application/xslt+xml base64
|
1136
1171
|
xsm application/vnd.syncml+xml base64
|
data/lib/mini_mime.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require "mini_mime/version"
|
2
3
|
require "thread"
|
3
4
|
|
@@ -6,10 +7,24 @@ module MiniMime
|
|
6
7
|
Db.lookup_by_filename(filename)
|
7
8
|
end
|
8
9
|
|
10
|
+
def self.lookup_by_extension(extension)
|
11
|
+
Db.lookup_by_extension(extension)
|
12
|
+
end
|
13
|
+
|
9
14
|
def self.lookup_by_content_type(mime)
|
10
15
|
Db.lookup_by_content_type(mime)
|
11
16
|
end
|
12
17
|
|
18
|
+
module Configuration
|
19
|
+
class << self
|
20
|
+
attr_accessor :ext_db_path
|
21
|
+
attr_accessor :content_type_db_path
|
22
|
+
end
|
23
|
+
|
24
|
+
self.ext_db_path = File.expand_path("../db/ext_mime.db", __FILE__)
|
25
|
+
self.content_type_db_path = File.expand_path("../db/content_type_mime.db", __FILE__)
|
26
|
+
end
|
27
|
+
|
13
28
|
class Info
|
14
29
|
BINARY_ENCODINGS = %w(base64 8bit)
|
15
30
|
|
@@ -39,17 +54,16 @@ module MiniMime
|
|
39
54
|
|
40
55
|
def self.lookup_by_filename(filename)
|
41
56
|
extension = File.extname(filename)
|
42
|
-
if extension
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
57
|
+
return if extension.empty?
|
58
|
+
extension = extension[1..-1]
|
59
|
+
lookup_by_extension(extension)
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.lookup_by_extension(extension)
|
63
|
+
LOCK.synchronize do
|
64
|
+
@db ||= new
|
65
|
+
@db.lookup_by_extension(extension) ||
|
66
|
+
@db.lookup_by_extension(extension.downcase)
|
53
67
|
end
|
54
68
|
end
|
55
69
|
|
@@ -80,8 +94,8 @@ module MiniMime
|
|
80
94
|
class RandomAccessDb
|
81
95
|
MAX_CACHED = 100
|
82
96
|
|
83
|
-
def initialize(
|
84
|
-
@path =
|
97
|
+
def initialize(path, sort_order)
|
98
|
+
@path = path
|
85
99
|
@file = File.open(@path)
|
86
100
|
|
87
101
|
@row_length = @file.readline.length
|
@@ -116,7 +130,7 @@ module MiniMime
|
|
116
130
|
result = nil
|
117
131
|
|
118
132
|
while from <= to do
|
119
|
-
midpoint = from + (to-from).div(2)
|
133
|
+
midpoint = from + (to - from).div(2)
|
120
134
|
current = resolve(midpoint)
|
121
135
|
data = current[@sort_order]
|
122
136
|
if data > val
|
@@ -132,14 +146,14 @@ module MiniMime
|
|
132
146
|
end
|
133
147
|
|
134
148
|
def resolve(row)
|
135
|
-
@file.seek(row
|
149
|
+
@file.seek(row * @row_length)
|
136
150
|
Info.new(@file.readline)
|
137
151
|
end
|
138
152
|
end
|
139
153
|
|
140
154
|
def initialize
|
141
|
-
@ext_db = RandomAccessDb.new(
|
142
|
-
@content_type_db = RandomAccessDb.new(
|
155
|
+
@ext_db = RandomAccessDb.new(Configuration.ext_db_path, 0)
|
156
|
+
@content_type_db = RandomAccessDb.new(Configuration.content_type_db_path, 1)
|
143
157
|
end
|
144
158
|
|
145
159
|
def lookup_by_extension(extension)
|
data/lib/mini_mime/version.rb
CHANGED
data/mini_mime.gemspec
CHANGED
@@ -22,7 +22,9 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
|
-
spec.add_development_dependency "bundler", "
|
25
|
+
spec.add_development_dependency "bundler", ">= 1.13"
|
26
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
27
27
|
spec.add_development_dependency "minitest", "~> 5.0"
|
28
|
+
spec.add_development_dependency "rubocop"
|
29
|
+
spec.add_development_dependency "rubocop-discourse"
|
28
30
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_mime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.13'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.13'
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop-discourse
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
55
83
|
description: A lightweight mime type lookup toy
|
56
84
|
email:
|
57
85
|
- sam.saffron@gmail.com
|
@@ -59,8 +87,10 @@ executables: []
|
|
59
87
|
extensions: []
|
60
88
|
extra_rdoc_files: []
|
61
89
|
files:
|
90
|
+
- ".github/workflows/ci.yml"
|
91
|
+
- ".github/workflows/db.yml"
|
62
92
|
- ".gitignore"
|
63
|
-
- ".
|
93
|
+
- ".rubocop.yml"
|
64
94
|
- CHANGELOG
|
65
95
|
- CODE_OF_CONDUCT.md
|
66
96
|
- Gemfile
|
@@ -69,6 +99,7 @@ files:
|
|
69
99
|
- Rakefile
|
70
100
|
- bench/bench.rb
|
71
101
|
- bin/console
|
102
|
+
- bin/db_pull_request
|
72
103
|
- bin/setup
|
73
104
|
- lib/db/content_type_mime.db
|
74
105
|
- lib/db/ext_mime.db
|
@@ -79,7 +110,7 @@ homepage: https://github.com/discourse/mini_mime
|
|
79
110
|
licenses:
|
80
111
|
- MIT
|
81
112
|
metadata: {}
|
82
|
-
post_install_message:
|
113
|
+
post_install_message:
|
83
114
|
rdoc_options: []
|
84
115
|
require_paths:
|
85
116
|
- lib
|
@@ -94,9 +125,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
125
|
- !ruby/object:Gem::Version
|
95
126
|
version: '0'
|
96
127
|
requirements: []
|
97
|
-
|
98
|
-
|
99
|
-
signing_key:
|
128
|
+
rubygems_version: 3.2.2
|
129
|
+
signing_key:
|
100
130
|
specification_version: 4
|
101
131
|
summary: A lightweight mime type lookup toy
|
102
132
|
test_files: []
|
data/.travis.yml
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
sudo: false
|
3
|
-
cache: bundler
|
4
|
-
|
5
|
-
before_install: gem install bundler -v 1.13.6
|
6
|
-
|
7
|
-
rvm:
|
8
|
-
- 1.8.7
|
9
|
-
- 1.9.2
|
10
|
-
- 1.9.3
|
11
|
-
- 2.0.0
|
12
|
-
- 2.1.10
|
13
|
-
- 2.2.7
|
14
|
-
- 2.3.4
|
15
|
-
- 2.4.1
|
16
|
-
- ruby-head
|
17
|
-
- jruby
|
18
|
-
- jruby-9.0.5.0
|
19
|
-
- jruby-9.1.6.0
|
20
|
-
- jruby-head
|
21
|
-
- rbx-2
|
22
|
-
|
23
|
-
matrix:
|
24
|
-
allow_failures:
|
25
|
-
- rvm: ruby-head
|
26
|
-
- rvm: jruby-9.0.5.0
|
27
|
-
- rvm: jruby-9.1.6.0
|
28
|
-
- rvm: jruby-head
|
29
|
-
- rvm: rbx-2
|
30
|
-
fast_finish: true
|