mime-types 3.6.0 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +413 -0
- data/CONTRIBUTING.md +93 -0
- data/CONTRIBUTORS.md +52 -0
- data/{Licence.md → LICENCE.md} +9 -10
- data/Manifest.txt +8 -6
- data/README.md +200 -0
- data/Rakefile +65 -94
- data/SECURITY.md +7 -0
- data/lib/mime/type/columnar.rb +14 -1
- data/lib/mime/type.rb +116 -55
- data/lib/mime/types/_columnar.rb +52 -5
- data/lib/mime/types/container.rb +43 -13
- data/lib/mime/types/loader.rb +1 -1
- data/lib/mime/types/logger.rb +34 -3
- data/lib/mime/types/version.rb +14 -0
- data/lib/mime/types.rb +20 -10
- data/test/minitest_helper.rb +3 -3
- data/test/test_mime_type.rb +32 -34
- data/test/test_mime_types.rb +10 -5
- data/test/test_mime_types_class.rb +10 -4
- metadata +50 -98
- data/.standard.yml +0 -4
- data/Contributing.md +0 -133
- data/History.md +0 -353
- data/README.rdoc +0 -195
- /data/{Code-of-Conduct.md → CODE_OF_CONDUCT.md} +0 -0
data/History.md
DELETED
@@ -1,353 +0,0 @@
|
|
1
|
-
# Changelog
|
2
|
-
|
3
|
-
## 3.6.0 / 2024-10-02
|
4
|
-
|
5
|
-
- 2 deprecations:
|
6
|
-
|
7
|
-
- Array-based MIME::Type initialization
|
8
|
-
- String-based MIME::Type initialization
|
9
|
-
|
10
|
-
Use of these these will result in deprecation warnings.
|
11
|
-
|
12
|
-
- Added `logger` to the gemspec to suppress a bundled gem warning with Ruby
|
13
|
-
3.3.5. This warning should not be showing up until Ruby 3.4.0 is released and
|
14
|
-
will be suppressed in Ruby 3.3.6.
|
15
|
-
|
16
|
-
- Reworked the deprecation message code to be somewhat more flexible and allow
|
17
|
-
for outputting certain warnings once. Because there will be at least one other
|
18
|
-
release after 3.6, we do not need to make the type initialization deprecations
|
19
|
-
frequent with this release.
|
20
|
-
|
21
|
-
## 3.5.2 / 2024-01-02
|
22
|
-
|
23
|
-
There are no primary code changes, but we are releasing this as an update as
|
24
|
-
there are some validation changes and updated code with formatting.
|
25
|
-
|
26
|
-
- Dependency and CI updates:
|
27
|
-
|
28
|
-
- Masato Nakamura added Ruby 3.3 to the CI workflow in [#179][].
|
29
|
-
|
30
|
-
- Fixed regressions in standard formatting in [#180][].
|
31
|
-
|
32
|
-
- Removed `minitest-bonus-assertions` because of a bundler resolution issue.
|
33
|
-
Created a better replacement in-line.
|
34
|
-
|
35
|
-
## 3.5.1 / 2023-08-21
|
36
|
-
|
37
|
-
- 1 bug fix:
|
38
|
-
|
39
|
-
- Better handle possible line-termination strings (legal in Unix filenames)
|
40
|
-
such as `\n` in `MIME::Types.type_for`. Reported by ooooooo-q in [#177][],
|
41
|
-
resolved in [#178][].
|
42
|
-
|
43
|
-
## 3.5.0 / 2023-08-07
|
44
|
-
|
45
|
-
- 1 minor enhancement:
|
46
|
-
|
47
|
-
- Robb Shecter changed the default log level for duplicate type variant from
|
48
|
-
`warn` to `debug` in [#170][]. This works because `MIME::Types.logger` is
|
49
|
-
intended to fit the `::Logger` interface, and the default logger
|
50
|
-
(`WarnLogger`) is a subclass of `::Logger` that passes through to
|
51
|
-
`Kernel.warn`.
|
52
|
-
|
53
|
-
- Further consideration has changed cache load messages from `warn` to
|
54
|
-
`error` and deprecation messages from `warn` to `debug`.
|
55
|
-
|
56
|
-
- 1 bug fix:
|
57
|
-
|
58
|
-
- Added a definition of `MIME::Type#hash`. Contributed by Alex Vondrak in
|
59
|
-
[#167][], fixing [#166][].
|
60
|
-
|
61
|
-
- Dependency and CI updates:
|
62
|
-
|
63
|
-
- Update the .github/workflows/ci.yml workflow to test Ruby 3.2 and more
|
64
|
-
reliably test certain combinations rather than depending on exclusions.
|
65
|
-
|
66
|
-
- Change `.standard.yml` configuration to format for Ruby 2.3 as certain files
|
67
|
-
are not properly detected with Ruby 2.0.
|
68
|
-
|
69
|
-
- Change from `hoe-git` to `hoe-git2` to support Hoe version 4.
|
70
|
-
|
71
|
-
- Apply `standardrb --fix`.
|
72
|
-
|
73
|
-
- The above changes have resulted in the Soft deprecation of Ruby versions
|
74
|
-
below 2.6. Any errors reported for Ruby versions 2.0, 2.1, 2.2, 2.3, 2.4,
|
75
|
-
and 2.5 will be resolved, but maintaining CI for these versions is
|
76
|
-
unsustainable.
|
77
|
-
|
78
|
-
## 3.4.1 / 2021-11-16
|
79
|
-
|
80
|
-
- 1 bug fix:
|
81
|
-
|
82
|
-
- Fixed a Ruby < 2.3 incompatibility introduced by the use of standardrb,
|
83
|
-
where `<<-` heredocs were converted to `<<~` heredocs. These have been
|
84
|
-
reverted back to `<<-` with the indentation kept and a `.strip` call
|
85
|
-
to prevent excess whitespace.
|
86
|
-
|
87
|
-
## 3.4.0 / 2021-11-15
|
88
|
-
|
89
|
-
- 1 minor enhancement:
|
90
|
-
|
91
|
-
- Added a new field to `MIME::Type` for checking provisional registrations
|
92
|
-
from IANA. [#157]
|
93
|
-
|
94
|
-
- Documentation:
|
95
|
-
|
96
|
-
- Kevin Menard synced the documentation so that all examples are correct.
|
97
|
-
[#153]
|
98
|
-
|
99
|
-
- Administrivia:
|
100
|
-
|
101
|
-
- Added Ruby 3.0 to the CI test matrix. Added `windows/jruby` to the
|
102
|
-
CI exclusion list; it refuses to run successfully.
|
103
|
-
- Removed the Travis CI configuration and changed it to Github Workflows
|
104
|
-
[#150][]. Removed Coveralls configuration.
|
105
|
-
- Igor Victor added TruffleRuby to the Travis CI configuration. [#149]
|
106
|
-
- Koichi ITO loosened an excessively tight dependency. [#147]
|
107
|
-
- Started using `standardrb` for Ruby formatting and validation.
|
108
|
-
- Moved `deps:top` functionality to a support file.
|
109
|
-
|
110
|
-
## 3.3.1 / 2019-12-26
|
111
|
-
|
112
|
-
- 1 minor bug fix:
|
113
|
-
|
114
|
-
- Al Snow fixed a warning with MIME::Types::Logger producing a warning
|
115
|
-
because Ruby 2.7 introduces numbered block parameters. Because of the way
|
116
|
-
that the MIME::Types::Logger works for deprecation messages, the
|
117
|
-
initializer parameters had been named `_1`, `_2`, and `_3`. This has now
|
118
|
-
been resolved. [#146]
|
119
|
-
|
120
|
-
- Administrivia:
|
121
|
-
|
122
|
-
- Olle Jonsson removed an outdated Travis configuration option. [#142][]
|
123
|
-
|
124
|
-
## 3.3 / 2019-09-04
|
125
|
-
|
126
|
-
- 1 minor enhancement
|
127
|
-
|
128
|
-
- Jean Boussier reduced memory usage for Ruby versions 2.3 or higher by
|
129
|
-
interning various string values in each type. This is done with a
|
130
|
-
backwards-compatible call that _freezes_ the strings on older versions of
|
131
|
-
Ruby. [#141]
|
132
|
-
|
133
|
-
- Administrivia:
|
134
|
-
|
135
|
-
- Nicholas La Roux updated Travis build configurations. [#139]
|
136
|
-
|
137
|
-
## 3.2.2 / 2018-08-12
|
138
|
-
|
139
|
-
- Hiroto Fukui removed a stray `debugger` statement that I had used in
|
140
|
-
producing v3.2.1. [#137]
|
141
|
-
|
142
|
-
## 3.2.1 / 2018-08-12
|
143
|
-
|
144
|
-
- A few bugs related to MIME::Types::Container and its use in the
|
145
|
-
mime-types-data helper tools reared their head because I released 3.2
|
146
|
-
before verifying against mime-types-data.
|
147
|
-
|
148
|
-
## 3.2 / 2018-08-12
|
149
|
-
|
150
|
-
- 2 minor enhancements
|
151
|
-
|
152
|
-
- Janko Marohnić contributed a change to `MIME::Type#priority_order` that
|
153
|
-
should improve on strict sorting when dealing with MIME types that appear
|
154
|
-
to be in the same family even if strict sorting would cause an
|
155
|
-
unregistered type to be sorted first. [#132]
|
156
|
-
|
157
|
-
- Dillon Welch contributed a change that added `frozen_string_literal: true`
|
158
|
-
to files so that modern Rubies can automatically reduce duplicate string
|
159
|
-
allocations. [#135]
|
160
|
-
|
161
|
-
- 2 bug fixes
|
162
|
-
|
163
|
-
- Burke Libbey fixed a problem with cached data loading. [#126]
|
164
|
-
|
165
|
-
- Resolved an issue where Enumerable#inject returns `nil` when provided an
|
166
|
-
empty enumerable and a default value has not been provided. This is
|
167
|
-
because when Enumerable#inject isn't provided a starting value, the first
|
168
|
-
value is used as the default value. In every case where this error was
|
169
|
-
happening, the result was supposed to be an array containing Set objects
|
170
|
-
so they can be reduced to a single Set. [#117][], [#127][], [#134][]
|
171
|
-
|
172
|
-
- Fixed an uncontrolled growth bug in MIME::Types::Container where a key
|
173
|
-
miss would create a new entry with an empty Set in the container. This
|
174
|
-
was working as designed (this particular feature was heavily used during
|
175
|
-
MIME::Type registry construction), but the design was flawed in that it
|
176
|
-
did not have any way of determining the difference between construction
|
177
|
-
and querying. This would mean that, if you have a function in your web
|
178
|
-
app that queries the MIME::Types registry by extension, the extension
|
179
|
-
registry would grow uncontrollably. [#136]
|
180
|
-
|
181
|
-
- Deprecations:
|
182
|
-
|
183
|
-
- Lazy loading (`$RUBY_MIME_TYPES_LAZY_LOAD`) has been deprecated.
|
184
|
-
|
185
|
-
- Documentation Changes:
|
186
|
-
|
187
|
-
- Supporting files are now Markdown instead of rdoc, except for the README.
|
188
|
-
|
189
|
-
- The history file has been modified to remove all history prior to 3.0.
|
190
|
-
This history can be found in previous commits.
|
191
|
-
|
192
|
-
- A spelling error was corrected by Edward Betts ([#129][]).
|
193
|
-
|
194
|
-
- Administrivia:
|
195
|
-
|
196
|
-
- CI configuration for more modern versions of Ruby were added by Nicolas
|
197
|
-
Leger ([#130][]), Jun Aruga ([#125][]), and Austin Ziegler. Removed
|
198
|
-
ruby-head-clang and rbx (Rubinius) from CI.
|
199
|
-
|
200
|
-
- Fixed tests which were asserting equality against nil, which will become
|
201
|
-
an error in Minitest 6.
|
202
|
-
|
203
|
-
## 3.1 / 2016-05-22
|
204
|
-
|
205
|
-
- 1 documentation change:
|
206
|
-
|
207
|
-
- Tim Smith (@tas50) updated the build badges to be SVGs to improve
|
208
|
-
readability on high-density (retina) screens with pull request [#112][].
|
209
|
-
|
210
|
-
- 3 bug fixes
|
211
|
-
|
212
|
-
- A test for `MIME::Types::Cache` fails under Ruby 2.3 because of frozen
|
213
|
-
strings, [#118][]. This has been fixed.
|
214
|
-
|
215
|
-
- The JSON data has been incorrectly encoded since the release of
|
216
|
-
mime-types 3 on the `xrefs` field, because of the switch to using a Set
|
217
|
-
to store cross-reference information. This has been fixed.
|
218
|
-
|
219
|
-
- A tentative fix for [#117][] has been applied, removing the only circular
|
220
|
-
require dependencies that exist (and for which there was code to prevent,
|
221
|
-
but the current fix is simpler). I have no way to verify this fix and
|
222
|
-
depending on how things are loaded by `delayed_job`, this fix may not be
|
223
|
-
sufficient.
|
224
|
-
|
225
|
-
- 1 governance change
|
226
|
-
|
227
|
-
- Updated to Contributor Covenant 1.4.
|
228
|
-
|
229
|
-
## 3.0 / 2015-11-21
|
230
|
-
|
231
|
-
- 2 governance changes
|
232
|
-
|
233
|
-
- This project and the related mime-types-data project are now exclusively
|
234
|
-
MIT licensed. Resolves [#95][].
|
235
|
-
|
236
|
-
- All projects under the mime-types organization now have a standard code
|
237
|
-
of conduct adapted from the [Contributor Covenant][]. This text can be
|
238
|
-
found in the [Code-of-Conduct.md][] file.
|
239
|
-
|
240
|
-
- 3 major changes
|
241
|
-
|
242
|
-
- All methods deprecated in mime-types 2.x have been removed.
|
243
|
-
|
244
|
-
- mime-types now requires Ruby 2.0 compatibility or later. Resolves
|
245
|
-
[#97][].
|
246
|
-
|
247
|
-
- The registry data has been removed from mime-types and put into
|
248
|
-
mime-types-data, maintained and released separately. It can be found at
|
249
|
-
[mime-types-data][].
|
250
|
-
|
251
|
-
- 17 minor changes:
|
252
|
-
|
253
|
-
- `MIME::Type` changes:
|
254
|
-
|
255
|
-
- Changed the way that simplified types representations are created to
|
256
|
-
reflect the fact that `x-` prefixes are no longer considered special
|
257
|
-
according to IANA. A simplified MIME type is case-folded to lowercase.
|
258
|
-
A new keyword parameter, `remove_x_prefix`, can be provided to remove
|
259
|
-
`x-` prefixes.
|
260
|
-
|
261
|
-
- Improved initialization with an Array works so that extensions do not
|
262
|
-
need to be wrapped in another array. This means that
|
263
|
-
`%w(text/yaml yaml yml)` works in the same way that
|
264
|
-
`['text/yaml', %w(yaml yml)]` did (and still does).
|
265
|
-
|
266
|
-
- Changed `priority_compare` to conform with attributes that no longer
|
267
|
-
exist.
|
268
|
-
|
269
|
-
- Changed the internal implementation of extensions to use a frozen Set.
|
270
|
-
|
271
|
-
- When extensions are set or modified with `add_extensions`, the primary
|
272
|
-
registry will be informed of a need to re-index extensions. Resolves
|
273
|
-
[#84][].
|
274
|
-
|
275
|
-
- The preferred extension can be set explicitly. If not set, it will be
|
276
|
-
the first extension. If the preferred extension is not in the extension
|
277
|
-
list, it will be added.
|
278
|
-
|
279
|
-
- Improved how xref URLs are generated.
|
280
|
-
|
281
|
-
- Converted `obsolete`, `registered` and `signature` to `attr_accessors`.
|
282
|
-
|
283
|
-
- `MIME::Types` changes:
|
284
|
-
|
285
|
-
- Modified `MIME::Types.new` to track instances of `MIME::Types` so that
|
286
|
-
they can be told to reindex the extensions as necessary.
|
287
|
-
|
288
|
-
- Removed `data_version` attribute.
|
289
|
-
|
290
|
-
- Changed `#[]` so that the `complete` and `registered` flags are
|
291
|
-
keywords instead of a generic options parameter.
|
292
|
-
|
293
|
-
- Extracted the class methods to a separate file.
|
294
|
-
|
295
|
-
- Changed the container implementation to use a Set instead of an Array
|
296
|
-
to prevent data duplication. Resolves [#79][].
|
297
|
-
|
298
|
-
- `MIME::Types::Cache` changes:
|
299
|
-
|
300
|
-
- Caching is now based on the data gem version instead of the mime-types
|
301
|
-
version.
|
302
|
-
|
303
|
-
- Caching is compatible with columnar registry stores.
|
304
|
-
|
305
|
-
- `MIME::Types::Loader` changes:
|
306
|
-
|
307
|
-
- `MIME::Types::Loader::PATH` has been removed and replaced with
|
308
|
-
`MIME::Types::Data::PATH` from the mime-types-data gem. The environment
|
309
|
-
variable `RUBY_MIME_TYPES_DATA` is still used.
|
310
|
-
|
311
|
-
- Support for the long-deprecated mime-types v1 format has been removed.
|
312
|
-
|
313
|
-
- The registry is default loaded from the columnar store by default. The
|
314
|
-
internal format of the columnar store has changed; many of the boolean
|
315
|
-
flags are now loaded from a single file. Resolves [#85][].
|
316
|
-
|
317
|
-
[#79]: https://github.com/mime-types/ruby-mime-types/pull/79
|
318
|
-
[#84]: https://github.com/mime-types/ruby-mime-types/pull/84
|
319
|
-
[#85]: https://github.com/mime-types/ruby-mime-types/pull/85
|
320
|
-
[#95]: https://github.com/mime-types/ruby-mime-types/pull/95
|
321
|
-
[#97]: https://github.com/mime-types/ruby-mime-types/pull/97
|
322
|
-
[#112]: https://github.com/mime-types/ruby-mime-types/pull/112
|
323
|
-
[#117]: https://github.com/mime-types/ruby-mime-types/issues/117
|
324
|
-
[#118]: https://github.com/mime-types/ruby-mime-types/pull/118
|
325
|
-
[#125]: https://github.com/mime-types/ruby-mime-types/pull/125
|
326
|
-
[#126]: https://github.com/mime-types/ruby-mime-types/pull/126
|
327
|
-
[#127]: https://github.com/mime-types/ruby-mime-types/issues/127
|
328
|
-
[#129]: https://github.com/mime-types/ruby-mime-types/pull/129
|
329
|
-
[#130]: https://github.com/mime-types/ruby-mime-types/pull/130
|
330
|
-
[#127]: https://github.com/mime-types/ruby-mime-types/issues/127
|
331
|
-
[#132]: https://github.com/mime-types/ruby-mime-types/pull/132
|
332
|
-
[#134]: https://github.com/mime-types/ruby-mime-types/issues/134
|
333
|
-
[#135]: https://github.com/mime-types/ruby-mime-types/pull/135
|
334
|
-
[#136]: https://github.com/mime-types/ruby-mime-types/issues/136
|
335
|
-
[#137]: https://github.com/mime-types/ruby-mime-types/pull/137
|
336
|
-
[#139]: https://github.com/mime-types/ruby-mime-types/pull/139
|
337
|
-
[#141]: https://github.com/mime-types/ruby-mime-types/pull/141
|
338
|
-
[#142]: https://github.com/mime-types/ruby-mime-types/pull/142
|
339
|
-
[#146]: https://github.com/mime-types/ruby-mime-types/pull/146
|
340
|
-
[#147]: https://github.com/mime-types/ruby-mime-types/pull/147
|
341
|
-
[#149]: https://github.com/mime-types/ruby-mime-types/pull/149
|
342
|
-
[#150]: https://github.com/mime-types/ruby-mime-types/pull/150
|
343
|
-
[#153]: https://github.com/mime-types/ruby-mime-types/pull/153
|
344
|
-
[#166]: https://github.com/mime-types/ruby-mime-types/issues/166
|
345
|
-
[#167]: https://github.com/mime-types/ruby-mime-types/pull/167
|
346
|
-
[#170]: https://github.com/mime-types/ruby-mime-types/pull/170
|
347
|
-
[#177]: https://github.com/mime-types/ruby-mime-types/issues/177
|
348
|
-
[#178]: https://github.com/mime-types/ruby-mime-types/pull/178
|
349
|
-
[#179]: https://github.com/mime-types/ruby-mime-types/pull/179
|
350
|
-
[#180]: https://github.com/mime-types/ruby-mime-types/pull/180
|
351
|
-
[code-of-conduct.md]: Code-of-Conduct_md.html
|
352
|
-
[contributor covenant]: http://contributor-covenant.org
|
353
|
-
[mime-types-data]: https://github.com/mime-types/mime-types-data
|
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
|