mini_mime 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6418281c1f9518b9e7afc48f4243db64e69b2b7102f7b5b75ef6222cc71597a7
4
- data.tar.gz: 98a2802a299bea38149948706d8375211be7de314af5afcbf6fd07d50c185c06
3
+ metadata.gz: 6fc13927a7df264030d9607ba6fa3550b2c487a5323ef90fb5a94a1b1822b867
4
+ data.tar.gz: 3f5e7f9bd173e949bd41bbd9fbaf8407a7814a4c444f4e0f4ed1a77af074d93e
5
5
  SHA512:
6
- metadata.gz: ced08523dacb58cd959d3ad4f54b331e6b7332682166477e9a32e5dbd8583071e27c10d6b2c570db29d2d736579c13404d85589466d330de41862faf7c630c63
7
- data.tar.gz: eca14d12f6b9a1408f8754fc59fc10faa0440b34ed0e7ade60d3114ec2ab933dab453fbfa1ae1ac63b765538710d31a224b1d195637c631c1725542f320083dc
6
+ metadata.gz: 1b20d28512acc6caa7cb2886c26599dde41d10cdfe901f43559cb2b7e5d5da1287a282b2ffc7bf80d681436e907f50c7ac481b63ffc7d3917a4cb48b38d079a6
7
+ data.tar.gz: a386bf74037df52b3d07b38a2b7d406fb62a0674dc7abd6a5ffde481751724e00c9e7df5cb3b84f7bf9f28d7091af4b2dc54251c90c995f8ff5287f27357ec56
@@ -1,24 +1,15 @@
1
1
  language: ruby
2
- sudo: false
3
- cache: bundler
4
-
5
- before_install: gem install bundler -v 1.13.6
6
2
 
7
3
  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
4
+ - 2.3
5
+ - 2.4
6
+ - 2.5
7
+ - 2.6
16
8
  - ruby-head
17
9
  - jruby
18
10
  - jruby-9.0.5.0
19
11
  - jruby-9.1.6.0
20
12
  - jruby-head
21
- - rbx-2
22
13
 
23
14
  matrix:
24
15
  allow_failures:
@@ -26,5 +17,4 @@ matrix:
26
17
  - rvm: jruby-9.0.5.0
27
18
  - rvm: jruby-9.1.6.0
28
19
  - rvm: jruby-head
29
- - rvm: rbx-2
30
20
  fast_finish: true
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 08-07-2019
2
+ - Version 1.0.2
3
+ - Update mime types from upstream
4
+
1
5
  14-08-2018
2
6
  - Version 1.0.1
3
7
  - Update mime types from upstream
data/Gemfile CHANGED
@@ -4,3 +4,5 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem "mime-types", "~> 3" if RUBY_VERSION > '2'
7
+ gem "memory_profiler"
8
+ gem "benchmark-ips"
data/README.md CHANGED
@@ -34,46 +34,63 @@ MiniMime.lookup_by_content_type("text/plain").binary?
34
34
 
35
35
  ```
36
36
 
37
+ ## Configuration
38
+
39
+ If you'd like to add your own mime types, try using custom database files:
40
+
41
+ ```
42
+ MiniMime::Configuration.ext_db_path = "path_to_file_extension_db"
43
+ MiniMime::Configuration.content_type_db_path = "path_to_content_type_db"
44
+ ```
45
+
46
+ Check out the [default databases](lib/db) for proper formatting and structure hints.
47
+
37
48
  ## Performance
38
49
 
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)
50
+ 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
51
 
41
52
  ```
42
53
  Memory stats for requiring mime/types/columnar
43
- Total allocated: 9869358 bytes (109796 objects)
44
- Total retained: 3138198 bytes (31165 objects)
54
+ Total allocated: 8712144 bytes (98242 objects)
55
+ Total retained: 3372545 bytes (33599 objects)
45
56
 
46
57
  Memory stats for requiring mini_mime
47
- Total allocated: 58898 bytes (398 objects)
48
- Total retained: 7784 bytes (62 objects)
58
+ Total allocated: 42625 bytes (369 objects)
59
+ Total retained: 8992 bytes (72 objects)
49
60
  Warming up --------------------------------------
50
61
  cached content_type lookup MiniMime
51
- 52.136k i/100ms
62
+ 85.109k i/100ms
52
63
  content_type lookup MIME::Types
53
- 32.701k i/100ms
64
+ 17.879k i/100ms
54
65
  Calculating -------------------------------------
55
66
  cached content_type lookup MiniMime
56
- 641.305k3.2%) i/s - 3.232M in 5.045630s
67
+ 1.105M4.1%) i/s - 5.532M in 5.014895s
57
68
  content_type lookup MIME::Types
58
- 361.041k (± 1.5%) i/s - 1.831M in 5.073290s
69
+ 193.528k7.1%) i/s - 965.466k in 5.013925s
59
70
  Warming up --------------------------------------
60
71
  uncached content_type lookup MiniMime
61
- 3.333k i/100ms
72
+ 1.410k i/100ms
62
73
  content_type lookup MIME::Types
63
- 33.177k i/100ms
74
+ 18.012k i/100ms
64
75
  Calculating -------------------------------------
65
76
  uncached content_type lookup MiniMime
66
- 33.660k1.7%) i/s - 169.983k in 5.051415s
77
+ 14.689k4.2%) i/s - 73.320k in 5.000779s
67
78
  content_type lookup MIME::Types
68
- 364.931k2.8%) i/s - 1.825M in 5.004112s
79
+ 193.459k6.9%) i/s - 972.648k in 5.050731s
69
80
  ```
70
81
 
71
- As a general guideline, cached lookups are 2x faster than MIME::Types equivelent. Uncached lookups are 10x slower.
82
+ As a general guideline, cached lookups are 6x faster than MIME::Types equivalent. Uncached lookups are 10x slower.
72
83
 
84
+ Note: It was run on macOS 10.14.2, and versions of Ruby and gems are below.
85
+
86
+ - Ruby 2.6.0
87
+ - mini_mime (1.0.1)
88
+ - mime-types (3.2.2)
89
+ - mime-types-data (3.2018.0812)
73
90
 
74
91
  ## Development
75
92
 
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.
93
+ 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
94
 
78
95
  To update the database run:
79
96
 
@@ -89,7 +106,6 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
89
106
 
90
107
  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
108
 
92
-
93
109
  ## License
94
110
 
95
111
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -487,6 +487,7 @@ cmp application/vnd.yellowriver-custom-menu
487
487
  zir application/vnd.zul base64
488
488
  zaz application/vnd.zzazz.deck+xml base64
489
489
  vxml application/voicexml+xml base64
490
+ wasm application/wasm 8bit
490
491
  wif application/watcherinfo+xml base64
491
492
  wgt application/widget base64
492
493
  wp5 application/wordperfect5.1 base64
@@ -237,6 +237,7 @@ eol audio/vnd.digital-winds
237
237
  eot application/vnd.ms-fontobject base64
238
238
  eps application/postscript 8bit
239
239
  epub application/epub+zip base64
240
+ es application/ecmascript base64
240
241
  es3 application/vnd.eszigno3+xml base64
241
242
  esa application/vnd.osgi.subsystem base64
242
243
  esf application/vnd.epson.esf base64
@@ -410,7 +411,7 @@ jpgm image/jpm
410
411
  jpgv video/JPEG base64
411
412
  jpm image/jpm base64
412
413
  jpx image/jpx base64
413
- js application/ecmascript base64
414
+ js application/javascript 8bit
414
415
  json application/json 8bit
415
416
  jsonml application/jsonml+json base64
416
417
  kar audio/midi base64
@@ -507,7 +508,7 @@ mj2 video/MJ2
507
508
  mjp2 video/MJ2 base64
508
509
  mjpeg video/x-motion-jpeg base64
509
510
  mjpg video/x-motion-jpeg base64
510
- mjs application/ecmascript base64
511
+ mjs application/javascript 8bit
511
512
  mk3d video/x-matroska base64
512
513
  mka audio/x-matroska base64
513
514
  mkd text/markdown quoted-printable
@@ -1035,6 +1036,7 @@ vtu model/vnd.vtu
1035
1036
  vxml application/voicexml+xml base64
1036
1037
  w3d application/x-director base64
1037
1038
  wad application/x-doom base64
1039
+ wasm application/wasm 8bit
1038
1040
  wav audio/x-wav base64
1039
1041
  wax audio/x-ms-wax base64
1040
1042
  wbmp image/vnd.wap.wbmp base64
@@ -14,6 +14,16 @@ module MiniMime
14
14
  Db.lookup_by_content_type(mime)
15
15
  end
16
16
 
17
+ module Configuration
18
+ class << self
19
+ attr_accessor :ext_db_path
20
+ attr_accessor :content_type_db_path
21
+ end
22
+
23
+ self.ext_db_path = File.expand_path("../db/ext_mime.db", __FILE__)
24
+ self.content_type_db_path = File.expand_path("../db/content_type_mime.db", __FILE__)
25
+ end
26
+
17
27
  class Info
18
28
  BINARY_ENCODINGS = %w(base64 8bit)
19
29
 
@@ -83,8 +93,8 @@ module MiniMime
83
93
  class RandomAccessDb
84
94
  MAX_CACHED = 100
85
95
 
86
- def initialize(name, sort_order)
87
- @path = File.expand_path("../db/#{name}", __FILE__)
96
+ def initialize(path, sort_order)
97
+ @path = path
88
98
  @file = File.open(@path)
89
99
 
90
100
  @row_length = @file.readline.length
@@ -141,8 +151,8 @@ module MiniMime
141
151
  end
142
152
 
143
153
  def initialize
144
- @ext_db = RandomAccessDb.new("ext_mime.db", 0)
145
- @content_type_db = RandomAccessDb.new("content_type_mime.db", 1)
154
+ @ext_db = RandomAccessDb.new(Configuration.ext_db_path, 0)
155
+ @content_type_db = RandomAccessDb.new(Configuration.content_type_db_path, 1)
146
156
  end
147
157
 
148
158
  def lookup_by_extension(extension)
@@ -1,3 +1,3 @@
1
1
  module MiniMime
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -22,7 +22,7 @@ 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
28
  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: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-14 00:00:00.000000000 Z
11
+ date: 2019-07-08 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
@@ -94,8 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  - !ruby/object:Gem::Version
95
95
  version: '0'
96
96
  requirements: []
97
- rubyforge_project:
98
- rubygems_version: 2.7.6
97
+ rubygems_version: 3.0.1
99
98
  signing_key:
100
99
  specification_version: 4
101
100
  summary: A lightweight mime type lookup toy