mime-types 3.6.0.beta1 → 3.6.1
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 +4 -4
- data/{History.md → CHANGELOG.md} +139 -117
- data/CONTRIBUTING.md +104 -0
- data/CONTRIBUTORS.md +50 -0
- data/{Licence.md → LICENCE.md} +9 -10
- data/Manifest.txt +8 -6
- data/README.md +199 -0
- data/Rakefile +46 -90
- data/SECURITY.md +7 -0
- data/lib/mime/type.rb +2 -3
- data/lib/mime/types/container.rb +43 -13
- data/lib/mime/types/logger.rb +34 -3
- data/lib/mime/types/version.rb +14 -0
- data/lib/mime/types.rb +1 -3
- data/test/minitest_helper.rb +3 -3
- metadata +31 -98
- data/.standard.yml +0 -4
- data/Contributing.md +0 -133
- data/README.rdoc +0 -195
- /data/{Code-of-Conduct.md → CODE_OF_CONDUCT.md} +0 -0
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mime-types
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.6.
|
4
|
+
version: 3.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Austin Ziegler
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-03-18 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: mime-types-data
|
@@ -38,96 +37,62 @@ dependencies:
|
|
38
37
|
- - ">="
|
39
38
|
- !ruby/object:Gem::Version
|
40
39
|
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: '5.25'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '5.25'
|
55
40
|
- !ruby/object:Gem::Dependency
|
56
41
|
name: hoe
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '3.0'
|
62
|
-
- - "<"
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
version: '5'
|
65
|
-
type: :development
|
66
|
-
prerelease: false
|
67
|
-
version_requirements: !ruby/object:Gem::Requirement
|
68
|
-
requirements:
|
69
|
-
- - ">="
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
version: '3.0'
|
72
|
-
- - "<"
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '5'
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: hoe-doofus
|
77
42
|
requirement: !ruby/object:Gem::Requirement
|
78
43
|
requirements:
|
79
44
|
- - "~>"
|
80
45
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
46
|
+
version: '4.0'
|
82
47
|
type: :development
|
83
48
|
prerelease: false
|
84
49
|
version_requirements: !ruby/object:Gem::Requirement
|
85
50
|
requirements:
|
86
51
|
- - "~>"
|
87
52
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
53
|
+
version: '4.0'
|
89
54
|
- !ruby/object:Gem::Dependency
|
90
|
-
name: hoe-
|
55
|
+
name: hoe-halostatue
|
91
56
|
requirement: !ruby/object:Gem::Requirement
|
92
57
|
requirements:
|
93
58
|
- - "~>"
|
94
59
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
60
|
+
version: '2.0'
|
96
61
|
type: :development
|
97
62
|
prerelease: false
|
98
63
|
version_requirements: !ruby/object:Gem::Requirement
|
99
64
|
requirements:
|
100
65
|
- - "~>"
|
101
66
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
67
|
+
version: '2.0'
|
103
68
|
- !ruby/object:Gem::Dependency
|
104
|
-
name: hoe-
|
69
|
+
name: hoe-rubygems
|
105
70
|
requirement: !ruby/object:Gem::Requirement
|
106
71
|
requirements:
|
107
72
|
- - "~>"
|
108
73
|
- !ruby/object:Gem::Version
|
109
|
-
version: '1.
|
74
|
+
version: '1.0'
|
110
75
|
type: :development
|
111
76
|
prerelease: false
|
112
77
|
version_requirements: !ruby/object:Gem::Requirement
|
113
78
|
requirements:
|
114
79
|
- - "~>"
|
115
80
|
- !ruby/object:Gem::Version
|
116
|
-
version: '1.
|
81
|
+
version: '1.0'
|
117
82
|
- !ruby/object:Gem::Dependency
|
118
|
-
name:
|
83
|
+
name: minitest
|
119
84
|
requirement: !ruby/object:Gem::Requirement
|
120
85
|
requirements:
|
121
86
|
- - "~>"
|
122
87
|
- !ruby/object:Gem::Version
|
123
|
-
version: '
|
88
|
+
version: '5.0'
|
124
89
|
type: :development
|
125
90
|
prerelease: false
|
126
91
|
version_requirements: !ruby/object:Gem::Requirement
|
127
92
|
requirements:
|
128
93
|
- - "~>"
|
129
94
|
- !ruby/object:Gem::Version
|
130
|
-
version: '
|
95
|
+
version: '5.0'
|
131
96
|
- !ruby/object:Gem::Dependency
|
132
97
|
name: minitest-autotest
|
133
98
|
requirement: !ruby/object:Gem::Requirement
|
@@ -204,40 +169,6 @@ dependencies:
|
|
204
169
|
- - "~>"
|
205
170
|
- !ruby/object:Gem::Version
|
206
171
|
version: '1.0'
|
207
|
-
- !ruby/object:Gem::Dependency
|
208
|
-
name: rdoc
|
209
|
-
requirement: !ruby/object:Gem::Requirement
|
210
|
-
requirements:
|
211
|
-
- - ">="
|
212
|
-
- !ruby/object:Gem::Version
|
213
|
-
version: '4.0'
|
214
|
-
- - "<"
|
215
|
-
- !ruby/object:Gem::Version
|
216
|
-
version: '7'
|
217
|
-
type: :development
|
218
|
-
prerelease: false
|
219
|
-
version_requirements: !ruby/object:Gem::Requirement
|
220
|
-
requirements:
|
221
|
-
- - ">="
|
222
|
-
- !ruby/object:Gem::Version
|
223
|
-
version: '4.0'
|
224
|
-
- - "<"
|
225
|
-
- !ruby/object:Gem::Version
|
226
|
-
version: '7'
|
227
|
-
- !ruby/object:Gem::Dependency
|
228
|
-
name: simplecov
|
229
|
-
requirement: !ruby/object:Gem::Requirement
|
230
|
-
requirements:
|
231
|
-
- - "~>"
|
232
|
-
- !ruby/object:Gem::Version
|
233
|
-
version: '0.21'
|
234
|
-
type: :development
|
235
|
-
prerelease: false
|
236
|
-
version_requirements: !ruby/object:Gem::Requirement
|
237
|
-
requirements:
|
238
|
-
- - "~>"
|
239
|
-
- !ruby/object:Gem::Version
|
240
|
-
version: '0.21'
|
241
172
|
description: |-
|
242
173
|
The mime-types library provides a library and registry for information about
|
243
174
|
MIME content type definitions. It can be used to determine defined filename
|
@@ -256,21 +187,24 @@ email:
|
|
256
187
|
executables: []
|
257
188
|
extensions: []
|
258
189
|
extra_rdoc_files:
|
259
|
-
-
|
260
|
-
-
|
261
|
-
-
|
262
|
-
-
|
190
|
+
- CHANGELOG.md
|
191
|
+
- CODE_OF_CONDUCT.md
|
192
|
+
- CONTRIBUTING.md
|
193
|
+
- CONTRIBUTORS.md
|
194
|
+
- LICENCE.md
|
263
195
|
- Manifest.txt
|
264
|
-
- README.
|
196
|
+
- README.md
|
197
|
+
- SECURITY.md
|
265
198
|
files:
|
266
|
-
-
|
267
|
-
-
|
268
|
-
-
|
269
|
-
-
|
270
|
-
-
|
199
|
+
- CHANGELOG.md
|
200
|
+
- CODE_OF_CONDUCT.md
|
201
|
+
- CONTRIBUTING.md
|
202
|
+
- CONTRIBUTORS.md
|
203
|
+
- LICENCE.md
|
271
204
|
- Manifest.txt
|
272
|
-
- README.
|
205
|
+
- README.md
|
273
206
|
- Rakefile
|
207
|
+
- SECURITY.md
|
274
208
|
- lib/mime-types.rb
|
275
209
|
- lib/mime/type.rb
|
276
210
|
- lib/mime/type/columnar.rb
|
@@ -284,6 +218,7 @@ files:
|
|
284
218
|
- lib/mime/types/loader.rb
|
285
219
|
- lib/mime/types/logger.rb
|
286
220
|
- lib/mime/types/registry.rb
|
221
|
+
- lib/mime/types/version.rb
|
287
222
|
- test/bad-fixtures/malformed
|
288
223
|
- test/fixture/json.json
|
289
224
|
- test/fixture/old-data
|
@@ -300,14 +235,13 @@ licenses:
|
|
300
235
|
- MIT
|
301
236
|
metadata:
|
302
237
|
homepage_uri: https://github.com/mime-types/ruby-mime-types/
|
303
|
-
source_code_uri: https://github.com/mime-types/ruby-mime-types/
|
304
238
|
bug_tracker_uri: https://github.com/mime-types/ruby-mime-types/issues
|
239
|
+
source_code_uri: https://github.com/mime-types/ruby-mime-types/
|
305
240
|
changelog_uri: https://github.com/mime-types/ruby-mime-types/blob/master/History.md
|
306
241
|
rubygems_mfa_required: 'true'
|
307
|
-
post_install_message:
|
308
242
|
rdoc_options:
|
309
243
|
- "--main"
|
310
|
-
- README.
|
244
|
+
- README.md
|
311
245
|
require_paths:
|
312
246
|
- lib
|
313
247
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -321,8 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
321
255
|
- !ruby/object:Gem::Version
|
322
256
|
version: '0'
|
323
257
|
requirements: []
|
324
|
-
rubygems_version: 3.
|
325
|
-
signing_key:
|
258
|
+
rubygems_version: 3.6.2
|
326
259
|
specification_version: 4
|
327
260
|
summary: The mime-types library provides a library and registry for information about
|
328
261
|
MIME content type definitions
|
data/.standard.yml
DELETED
data/Contributing.md
DELETED
@@ -1,133 +0,0 @@
|
|
1
|
-
# Contributing
|
2
|
-
|
3
|
-
I value any contribution to mime-types you can provide: a bug report, a feature
|
4
|
-
request, or code contributions.
|
5
|
-
|
6
|
-
There are a few guidelines for contributing to mime-types:
|
7
|
-
|
8
|
-
- Code changes _will_ _not_ be accepted without tests. The test suite is
|
9
|
-
written with [minitest][].
|
10
|
-
- Match my coding style.
|
11
|
-
- Use a thoughtfully-named topic branch that contains your change. Rebase your
|
12
|
-
commits into logical chunks as necessary.
|
13
|
-
- Use [quality commit messages][].
|
14
|
-
- Do not change the version number; when your patch is accepted and a release
|
15
|
-
is made, the version will be updated at that point.
|
16
|
-
- Submit a GitHub pull request with your changes.
|
17
|
-
- New or changed behaviours require new or updated documentation.
|
18
|
-
|
19
|
-
## Adding or Modifying MIME Types
|
20
|
-
|
21
|
-
The mime-types registry is no longer contained in mime-types, but in
|
22
|
-
[mime-types-data][]. Please see that project for contributions there.
|
23
|
-
|
24
|
-
### Test Dependencies
|
25
|
-
|
26
|
-
mime-types uses Ryan Davis’s [Hoe][] to manage the release process, and it adds
|
27
|
-
a number of rake tasks. You will mostly be interested in `rake`, which runs the
|
28
|
-
tests the same way that `rake test` will do.
|
29
|
-
|
30
|
-
To assist with the installation of the development dependencies for
|
31
|
-
mime-types, I have provided the simplest possible Gemfile pointing to the
|
32
|
-
(generated) `mime-types.gemspec` file. This will permit you to do `bundle install` to get the development dependencies. If you already have `hoe`
|
33
|
-
installed, you can accomplish the same thing with `rake newb`.
|
34
|
-
|
35
|
-
This task will install any missing dependencies, run the tests/specs, and
|
36
|
-
generate the RDoc.
|
37
|
-
|
38
|
-
You can run tests with code coverage analysis by running `rake test:coverage`.
|
39
|
-
|
40
|
-
## Benchmarks
|
41
|
-
|
42
|
-
mime-types offers several benchmark tasks to measure different measures of
|
43
|
-
performance.
|
44
|
-
|
45
|
-
There is a repeated load test, measuring how long it takes to start and load
|
46
|
-
mime-types with its full registry. By default, it runs fifty loops and uses the
|
47
|
-
built-in benchmark library:
|
48
|
-
|
49
|
-
- `rake benchmark:load`
|
50
|
-
|
51
|
-
There are two allocation tracing benchmarks (for normal and columnar loads).
|
52
|
-
These can only be run on Ruby 2.1 or better and requires the
|
53
|
-
[allocation\_tracer][] gem (not installed by default).
|
54
|
-
|
55
|
-
- `rake benchmark:allocations`
|
56
|
-
- `rake benchmark:allocations:columnar`
|
57
|
-
|
58
|
-
There are two loaded object count benchmarks (for normal and columnar loads).
|
59
|
-
These use `ObjectSpace.count_objects`.
|
60
|
-
|
61
|
-
- `rake benchmark:objects`
|
62
|
-
- `rake benchmark:objects:columnar`
|
63
|
-
|
64
|
-
## Workflow
|
65
|
-
|
66
|
-
Here's the most direct way to get your work merged into the project:
|
67
|
-
|
68
|
-
- Fork the project.
|
69
|
-
- Clone down your fork (`git clone git://github.com/<username>/ruby-mime-types.git`).
|
70
|
-
- Create a topic branch to contain your change (`git checkout -b my_awesome_feature`).
|
71
|
-
- Hack away, add tests. Not necessarily in that order.
|
72
|
-
- Make sure everything still passes by running `rake`.
|
73
|
-
- If necessary, rebase your commits into logical chunks, without errors.
|
74
|
-
- Push the branch up (`git push origin my_awesome_feature`).
|
75
|
-
- Create a pull request against mime-types/ruby-mime-types and describe what
|
76
|
-
your change does and the why you think it should be merged.
|
77
|
-
|
78
|
-
## Contributors
|
79
|
-
|
80
|
-
- Austin Ziegler created mime-types.
|
81
|
-
|
82
|
-
Thanks to everyone else who has contributed to mime-types over the years:
|
83
|
-
|
84
|
-
- Aaron Patterson
|
85
|
-
- Aggelos Avgerinos
|
86
|
-
- Al Snow
|
87
|
-
- Alex Vondrak
|
88
|
-
- Andre Pankratz
|
89
|
-
- Andy Brody
|
90
|
-
- Arnaud Meuret
|
91
|
-
- Brandon Galbraith
|
92
|
-
- Burke Libbey
|
93
|
-
- Chris Gat
|
94
|
-
- David Genord
|
95
|
-
- Dillon Welch
|
96
|
-
- Edward Betts
|
97
|
-
- Eric Marden
|
98
|
-
- Garret Alfert
|
99
|
-
- Godfrey Chan
|
100
|
-
- Greg Brockman
|
101
|
-
- Hans de Graaff
|
102
|
-
- Henrik Hodne
|
103
|
-
- Igor Victor
|
104
|
-
- Janko Marohnić
|
105
|
-
- Jean Boussier
|
106
|
-
- Jeremy Evans
|
107
|
-
- Juanito Fatas
|
108
|
-
- Jun Aruga
|
109
|
-
- Keerthi Siva
|
110
|
-
- Ken Ip
|
111
|
-
- Kevin Menard
|
112
|
-
- Koichi ITO
|
113
|
-
- Łukasz Śliwa
|
114
|
-
- Martin d'Allens
|
115
|
-
- Masato Nakamura
|
116
|
-
- Mauricio Linhares
|
117
|
-
- Nicholas La Roux
|
118
|
-
- Nicolas Leger
|
119
|
-
- nycvotes-dev
|
120
|
-
- Olle Jonsson
|
121
|
-
- Postmodern
|
122
|
-
- Richard Hirner
|
123
|
-
- Richard Hurt
|
124
|
-
- Richard Schneeman
|
125
|
-
- Robb Shecter
|
126
|
-
- Tibor Szolár
|
127
|
-
- Todd Carrico
|
128
|
-
|
129
|
-
[minitest]: https://github.com/seattlerb/minitest
|
130
|
-
[quality commit messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
|
131
|
-
[mime-types-data]: https://github.com/mime-types/mime-types-data
|
132
|
-
[hoe]: https://github.com/seattlerb/hoe
|
133
|
-
[allocation\_tracer]: https://github.com/ko1/allocation_tracer
|
data/README.rdoc
DELETED
@@ -1,195 +0,0 @@
|
|
1
|
-
= mime-types for Ruby
|
2
|
-
|
3
|
-
home :: https://github.com/mime-types/ruby-mime-types/
|
4
|
-
code :: https://github.com/mime-types/ruby-mime-types/
|
5
|
-
bugs :: https://github.com/mime-types/ruby-mime-types/issues
|
6
|
-
rdoc :: http://rdoc.info/gems/mime-types/
|
7
|
-
clog :: https://github.com/mime-types/ruby-mime-types/blob/master/History.md
|
8
|
-
continuous integration :: {<img src="https://github.com/mime-types/ruby-mime-types/actions/workflows/ci.yml/badge.svg" alt="Build Status" />}[https://github.com/mime-types/ruby-mime-types/actions/workflows/ci.yml]
|
9
|
-
test coverage :: {<img src="https://coveralls.io/repos/mime-types/ruby-mime-types/badge.svg?branch=master&service=github" alt="Coverage Status" />}[https://coveralls.io/github/mime-types/ruby-mime-types?branch=master]
|
10
|
-
|
11
|
-
== Description
|
12
|
-
|
13
|
-
The mime-types library provides a library and registry for information about
|
14
|
-
MIME content type definitions. It can be used to determine defined filename
|
15
|
-
extensions for MIME types, or to use filename extensions to look up the likely
|
16
|
-
MIME type definitions.
|
17
|
-
|
18
|
-
Version 3.0 is a major release that requires Ruby 2.0 compatibility and removes
|
19
|
-
deprecated functions. The columnar registry format introduced in 2.6 has been
|
20
|
-
made the primary format; the registry data has been extracted from this library
|
21
|
-
and put into {mime-types-data}[https://github.com/mime-types/mime-types-data].
|
22
|
-
Additionally, mime-types is now licensed exclusively under the MIT licence and
|
23
|
-
there is a code of conduct in effect. There are a number of other smaller
|
24
|
-
changes described in the History file.
|
25
|
-
|
26
|
-
=== About MIME Media Types
|
27
|
-
|
28
|
-
MIME content types are used in MIME-compliant communications, as in e-mail or
|
29
|
-
HTTP traffic, to indicate the type of content which is transmitted. The
|
30
|
-
mime-types library provides the ability for detailed information about MIME
|
31
|
-
entities (provided as an enumerable collection of MIME::Type objects) to be
|
32
|
-
determined and used. There are many types defined by RFCs and vendors, so the
|
33
|
-
list is long but by definition incomplete; don't hesitate to add additional
|
34
|
-
type definitions. MIME type definitions found in mime-types are from RFCs, W3C
|
35
|
-
recommendations, the {IANA Media Types
|
36
|
-
registry}[https://www.iana.org/assignments/media-types/media-types.xhtml], and
|
37
|
-
user contributions. It conforms to RFCs 2045 and 2231.
|
38
|
-
|
39
|
-
=== mime-types 3.x
|
40
|
-
|
41
|
-
Users are encouraged to upgrade to mime-types 3.x as soon as is practical.
|
42
|
-
mime-types 3.x requires Ruby 2.0 compatibility and a simpler licensing scheme.
|
43
|
-
|
44
|
-
== Synopsis
|
45
|
-
|
46
|
-
MIME types are used in MIME entities, as in email or HTTP traffic. It is useful
|
47
|
-
at times to have information available about MIME types (or, inversely, about
|
48
|
-
files). A MIME::Type stores the known information about one MIME type.
|
49
|
-
|
50
|
-
require 'mime/types'
|
51
|
-
|
52
|
-
plaintext = MIME::Types['text/plain'] # => [ text/plain ]
|
53
|
-
text = plaintext.first
|
54
|
-
puts text.media_type # => 'text'
|
55
|
-
puts text.sub_type # => 'plain'
|
56
|
-
|
57
|
-
puts text.extensions.join(' ') # => 'txt asc c cc h hh cpp hpp dat hlp'
|
58
|
-
puts text.preferred_extension # => 'txt'
|
59
|
-
puts text.friendly # => 'Text Document'
|
60
|
-
puts text.i18n_key # => 'text.plain'
|
61
|
-
|
62
|
-
puts text.encoding # => quoted-printable
|
63
|
-
puts text.default_encoding # => quoted-printable
|
64
|
-
puts text.binary? # => false
|
65
|
-
puts text.ascii? # => true
|
66
|
-
puts text.obsolete? # => false
|
67
|
-
puts text.registered? # => true
|
68
|
-
puts text.provisional? # => false
|
69
|
-
puts text.complete? # => true
|
70
|
-
|
71
|
-
puts text # => 'text/plain'
|
72
|
-
|
73
|
-
puts text == 'text/plain' # => true
|
74
|
-
puts 'text/plain' == text # => true
|
75
|
-
puts text == 'text/x-plain' # => false
|
76
|
-
puts 'text/x-plain' == text # => false
|
77
|
-
|
78
|
-
puts MIME::Type.simplified('x-appl/x-zip') # => 'x-appl/x-zip'
|
79
|
-
puts MIME::Type.i18n_key('x-appl/x-zip') # => 'x-appl.x-zip'
|
80
|
-
|
81
|
-
puts text.like?('text/x-plain') # => true
|
82
|
-
puts text.like?(MIME::Type.new('x-text/x-plain')) # => true
|
83
|
-
|
84
|
-
puts text.xrefs.inspect # => { "rfc" => [ "rfc2046", "rfc3676", "rfc5147" ] }
|
85
|
-
puts text.xref_urls # => [ "http://www.iana.org/go/rfc2046",
|
86
|
-
# "http://www.iana.org/go/rfc3676",
|
87
|
-
# "http://www.iana.org/go/rfc5147" ]
|
88
|
-
|
89
|
-
xtext = MIME::Type.new('x-text/x-plain')
|
90
|
-
puts xtext.media_type # => 'text'
|
91
|
-
puts xtext.raw_media_type # => 'x-text'
|
92
|
-
puts xtext.sub_type # => 'plain'
|
93
|
-
puts xtext.raw_sub_type # => 'x-plain'
|
94
|
-
puts xtext.complete? # => false
|
95
|
-
|
96
|
-
puts MIME::Types.any? { |type| type.content_type == 'text/plain' } # => true
|
97
|
-
puts MIME::Types.all?(&:registered?) # => false
|
98
|
-
|
99
|
-
# Various string representations of MIME types
|
100
|
-
qcelp = MIME::Types['audio/QCELP'].first # => audio/QCELP
|
101
|
-
puts qcelp.content_type # => 'audio/QCELP'
|
102
|
-
puts qcelp.simplified # => 'audio/qcelp'
|
103
|
-
|
104
|
-
xwingz = MIME::Types['application/x-Wingz'].first # => application/x-Wingz
|
105
|
-
puts xwingz.content_type # => 'application/x-Wingz'
|
106
|
-
puts xwingz.simplified # => 'application/x-wingz'
|
107
|
-
|
108
|
-
=== Columnar Store
|
109
|
-
|
110
|
-
mime-types uses as its primary registry storage format a columnar storage
|
111
|
-
format reducing the default memory footprint. This is done by selectively
|
112
|
-
loading the data on a per-attribute basis. When the registry is first loaded
|
113
|
-
from the columnar store, only the canonical MIME content type and known
|
114
|
-
extensions and the MIME type will be connected to its loading registry. When
|
115
|
-
other data about the type is required (including +preferred_extension+,
|
116
|
-
<tt>obsolete?</tt>, and <tt>registered?</tt>) that data is loaded from its own
|
117
|
-
column file for all types in the registry.
|
118
|
-
|
119
|
-
The load of any column data is performed with a Mutex to ensure that types are
|
120
|
-
updated safely in a multithreaded environment. Benchmarks show that while
|
121
|
-
columnar data loading is slower than the JSON store, it cuts the memory use by
|
122
|
-
a third over the JSON store.
|
123
|
-
|
124
|
-
If you prefer to load all the data at once, this can be specified in your
|
125
|
-
application Gemfile as:
|
126
|
-
|
127
|
-
gem 'mime-types', require: 'mime/types/full'
|
128
|
-
|
129
|
-
Projects that do not use Bundler should +require+ the same:
|
130
|
-
|
131
|
-
require 'mime/types/full'
|
132
|
-
|
133
|
-
Libraries that use mime-types are discouraged from choosing the JSON store.
|
134
|
-
|
135
|
-
For applications and clients that used mime-types 2.6 when the columnar store
|
136
|
-
was introduced, the require used previously will still work through at least
|
137
|
-
{version
|
138
|
-
4}[https://github.com/mime-types/ruby-mime-types/pull/96#issuecomment-100725400]
|
139
|
-
and possibly beyond; it is effectively an empty operation. You are recommended
|
140
|
-
to change your Gemfile as soon as is practical.
|
141
|
-
|
142
|
-
require 'mime/types/columnar'
|
143
|
-
|
144
|
-
Note that MIME::Type::Columnar and MIME::Types::Columnar are considered private
|
145
|
-
variant implementations of MIME::Type and MIME::Types and the specific
|
146
|
-
implementation should not be relied upon by consumers of the mime-types
|
147
|
-
library. Instead, depend on the public implementations (MIME::Type and
|
148
|
-
MIME::Types) only.
|
149
|
-
|
150
|
-
=== Cached Storage
|
151
|
-
|
152
|
-
mime-types supports a cache of MIME types using <tt>Marshal.dump</tt>. The
|
153
|
-
cache is invalidated for each version of the mime-types-data gem so that data
|
154
|
-
version 3.2015.1201 will not be reused with data version 3.2016.0101. If the
|
155
|
-
environment variable +RUBY_MIME_TYPES_CACHE+ is set to a cache file, mime-types
|
156
|
-
will attempt to load the MIME type registry from the cache file. If it cannot,
|
157
|
-
it will load the types normally and then saves the registry to the cache file.
|
158
|
-
|
159
|
-
The caching works with both full stores and columnar stores. Only the data that
|
160
|
-
has been loaded prior to saving the cache will be stored.
|
161
|
-
|
162
|
-
== mime-types Modified Semantic Versioning
|
163
|
-
|
164
|
-
The mime-types library has one version number, but this single version number
|
165
|
-
tracks both API changes and registry data changes; this is not wholly
|
166
|
-
compatible with all aspects of {Semantic Versioning}[http://semver.org/];
|
167
|
-
removing a MIME type from the registry *could* be considered a breaking change
|
168
|
-
under some interpretations of semantic versioning (as lookups for that
|
169
|
-
particular type would no longer work by default).
|
170
|
-
|
171
|
-
mime-types uses a modified semantic versioning scheme. Given the version
|
172
|
-
MAJOR.MINOR:
|
173
|
-
|
174
|
-
1. If an incompatible API (code) change is made, the MAJOR version will be
|
175
|
-
incremented, MINOR will be set to zero, and PATCH will be reset to the
|
176
|
-
implied zero.
|
177
|
-
|
178
|
-
2. If an API (code) feature is added that does not break compatibility, the
|
179
|
-
MINOR version will be incremented and PATCH will be reset to the implied zero.
|
180
|
-
|
181
|
-
3. If there is a bugfix to a feature added in the most recent MAJOR.MINOR
|
182
|
-
release, the implied PATCH value will be incremented resulting in
|
183
|
-
MAJOR.MINOR.PATCH.
|
184
|
-
|
185
|
-
In practical terms, there will be fewer releases of mime-types focussing on
|
186
|
-
features because of the existence of the
|
187
|
-
{mime-types-data}[https://github.com/mime-types/mime-types-data] gem, and if
|
188
|
-
features are marked deprecated in the course of mime-types 3.x, they will not
|
189
|
-
be removed until mime-types 4.x or possibly later.
|
190
|
-
|
191
|
-
{Code of Conduct}[Code-of-Conduct_md.html]
|
192
|
-
|
193
|
-
{Contributing}[Contributing_md.html]
|
194
|
-
|
195
|
-
{Licence}[Licence_md.html]
|
File without changes
|