mini_mime 0.1.3 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
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/postscript 8bit
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/java-vm base64
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/octet-stream base64
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
- hlp application/winhlp base64
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 application/x-troff-man 8bit
489
+ man text/troff 8bit
472
490
  manifest text/cache-manifest quoted-printable
473
491
  mar application/octet-stream base64
474
- markdown text/plain quoted-printable
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/plain quoted-printable
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 application/x-troff-me base64
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
- ms application/x-troff-ms base64
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 application/font-sfnt base64
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 base64
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 base64
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 base64
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 application/x-font-ttf base64
955
- ttf application/font-sfnt base64
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
- wav audio/x-wav base64
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 application/font-woff base64
1060
- woff2 application/font-woff base64
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
- extension.sub!(".", "")
44
- extension.downcase!
45
- if extension.length > 0
46
- LOCK.synchronize do
47
- @db ||= new
48
- @db.lookup_by_extension(extension)
49
- end
50
- else
51
- nil
52
- end
57
+ return if extension.empty?
58
+ extension = extension[1..-1]
59
+ extension.downcase!
60
+ lookup_by_extension(extension)
61
+ end
62
+
63
+ def self.lookup_by_extension(extension)
64
+ LOCK.synchronize do
65
+ @db ||= new
66
+ @db.lookup_by_extension(extension)
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(name, sort_order)
84
- @path = File.expand_path("../db/#{name}", __FILE__)
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*@row_length)
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("ext_mime.db", 0)
142
- @content_type_db = RandomAccessDb.new("content_type_mime.db", 1)
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)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module MiniMime
2
- VERSION = "0.1.3"
3
+ VERSION = "1.0.3"
3
4
  end
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", "~> 1.13"
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: 0.1.3
4
+ version: 1.0.3
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: 2017-03-28 00:00:00.000000000 Z
11
+ date: 2021-03-25 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
- - ".travis.yml"
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
- rubyforge_project:
98
- rubygems_version: 2.5.2
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: []