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