mime-types 3.4.1 → 3.5.1

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: 443bfcc0047c25a8ac7cc9e7a2fea95f8d4707e8fa3a98d0b99bee421e168708
4
- data.tar.gz: 39756d60550165df9787a4967c376faac32179fd442d176766893b7454ed977d
3
+ metadata.gz: 2577d95fe119a69a6462f904e9395bd3e2afe41a92e31bb278efd5978edfe450
4
+ data.tar.gz: d014796e5c1647f5a19b45b7993b390540b671fca83471e3d004712b277f3283
5
5
  SHA512:
6
- metadata.gz: d711882ac22adb5a8ab3e4953a508c06e870990ad0d41d0256679bcb66c7953686ba4b23ac1470ea6ee07d6026d793f57fb7d377d321fb972252365c8fd22622
7
- data.tar.gz: 3d20e16be727ee9b62ab599a939524148577b54281a63705b0b75a9eea7c6f51df169bc6979ce8b616c3b707921c1021ac06b226bb8df28f5337d1f76107a293
6
+ metadata.gz: 152b2f7e76b5b54c5dce0f0f97d5b0c301e4df2d71df0ba7643027d3e1015e3a3be838ceff2e49a851a3c62cd802ff2ab1473a1a62f6e359e66252204ce4bc7e
7
+ data.tar.gz: 63b40def9bdb08b5d4acc7af524746e900c6e07fb4b267e6bc816e083b59b1d7b779b3d7884494e1a8e5eea88240aa1a2c4e95e71e1be79f4fdf31dbdb251903
data/.standard.yml ADDED
@@ -0,0 +1,4 @@
1
+ parallel: true
2
+ ruby_version: 2.3
3
+ ignore:
4
+ - 'mime-types.gemspec'
data/Contributing.md CHANGED
@@ -6,11 +6,11 @@ request, or code contributions.
6
6
  There are a few guidelines for contributing to mime-types:
7
7
 
8
8
  - Code changes _will_ _not_ be accepted without tests. The test suite is
9
- written with [minitest].
9
+ written with [minitest][].
10
10
  - Match my coding style.
11
11
  - Use a thoughtfully-named topic branch that contains your change. Rebase your
12
12
  commits into logical chunks as necessary.
13
- - Use [quality commit messages].
13
+ - Use [quality commit messages][].
14
14
  - Do not change the version number; when your patch is accepted and a release
15
15
  is made, the version will be updated at that point.
16
16
  - Submit a GitHub pull request with your changes.
@@ -19,25 +19,23 @@ There are a few guidelines for contributing to mime-types:
19
19
  ## Adding or Modifying MIME Types
20
20
 
21
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.
22
+ [mime-types-data][]. Please see that project for contributions there.
23
23
 
24
24
  ### Test Dependencies
25
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
28
- the tests the same way that `rake test` or `rake travis` will do.
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
29
 
30
30
  To assist with the installation of the development dependencies for
31
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
33
- install` to get the development dependencies. If you aleady have `hoe`
32
+ (generated) `mime-types.gemspec` file. This will permit you to do `bundle install` to get the development dependencies. If you already have `hoe`
34
33
  installed, you can accomplish the same thing with `rake newb`.
35
34
 
36
35
  This task will install any missing dependencies, run the tests/specs, and
37
36
  generate the RDoc.
38
37
 
39
- You can run tests with code coverage analysis by running `rake
40
- test:coverage`.
38
+ You can run tests with code coverage analysis by running `rake test:coverage`.
41
39
 
42
40
  ## Benchmarks
43
41
 
@@ -52,7 +50,7 @@ built-in benchmark library:
52
50
 
53
51
  There are two allocation tracing benchmarks (for normal and columnar loads).
54
52
  These can only be run on Ruby 2.1 or better and requires the
55
- [allocation\_tracer] gem (not installed by default).
53
+ [allocation\_tracer][] gem (not installed by default).
56
54
 
57
55
  - `rake benchmark:allocations`
58
56
  - `rake benchmark:allocations:columnar`
@@ -84,6 +82,7 @@ Here's the most direct way to get your work merged into the project:
84
82
  Thanks to everyone else who has contributed to mime-types over the years:
85
83
 
86
84
  - Aaron Patterson
85
+ - Alex Vondrak
87
86
  - Aggelos Avgerinos
88
87
  - Al Snow
89
88
  - Andre Pankratz
@@ -122,6 +121,7 @@ Thanks to everyone else who has contributed to mime-types over the years:
122
121
  - Richard Hirner
123
122
  - Richard Hurt
124
123
  - Richard Schneeman
124
+ - Robb Shecter
125
125
  - Tibor Szolár
126
126
  - Todd Carrico
127
127
 
data/History.md CHANGED
@@ -1,8 +1,51 @@
1
1
  # Changelog
2
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
+
3
46
  ## 3.4.1 / 2021-11-16
4
47
 
5
- - 1 bugfix:
48
+ - 1 bug fix:
6
49
 
7
50
  - Fixed a Ruby < 2.3 incompatibility introduced by the use of standardrb,
8
51
  where `<<-` heredocs were converted to `<<~` heredocs. These have been
@@ -26,7 +69,7 @@
26
69
  - Added Ruby 3.0 to the CI test matrix. Added `windows/jruby` to the
27
70
  CI exclusion list; it refuses to run successfully.
28
71
  - Removed the Travis CI configuration and changed it to Github Workflows
29
- [#150]. Removed Coveralls configuration.
72
+ [#150][]. Removed Coveralls configuration.
30
73
  - Igor Victor added TruffleRuby to the Travis CI configuration. [#149]
31
74
  - Koichi ITO loosened an excessively tight dependency. [#147]
32
75
  - Started using `standardrb` for Ruby formatting and validation.
@@ -34,7 +77,7 @@
34
77
 
35
78
  ## 3.3.1 / 2019-12-26
36
79
 
37
- - 1 minor bugfix:
80
+ - 1 minor bug fix:
38
81
 
39
82
  - Al Snow fixed a warning with MIME::Types::Logger producing a warning
40
83
  because Ruby 2.7 introduces numbered block parameters. Because of the way
@@ -44,7 +87,7 @@
44
87
 
45
88
  - Administrivia:
46
89
 
47
- - Olle Jonsson removed an outdated Travis configuration option (`sudo: false`). [#142]
90
+ - Olle Jonsson removed an outdated Travis configuration option. [#142][]
48
91
 
49
92
  ## 3.3 / 2019-09-04
50
93
 
@@ -79,8 +122,9 @@
79
122
  to be in the same family even if strict sorting would cause an
80
123
  unregistered type to be sorted first. [#132]
81
124
 
82
- - Dillon Welch contributed a change that added `frozen_string_literal: true` to files so that modern Rubies can automatically reduce duplicate
83
- string allocations. [#135]
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]
84
128
 
85
129
  - 2 bug fixes
86
130
 
@@ -91,7 +135,7 @@
91
135
  because when Enumerable#inject isn't provided a starting value, the first
92
136
  value is used as the default value. In every case where this error was
93
137
  happening, the result was supposed to be an array containing Set objects
94
- so they can be reduced to a single Set. [#117], [#127], [#134]
138
+ so they can be reduced to a single Set. [#117][], [#127][], [#134][]
95
139
 
96
140
  - Fixed an uncontrolled growth bug in MIME::Types::Container where a key
97
141
  miss would create a new entry with an empty Set in the container. This
@@ -113,12 +157,12 @@
113
157
  - The history file has been modified to remove all history prior to 3.0.
114
158
  This history can be found in previous commits.
115
159
 
116
- - A spelling error was corrected by Edward Betts ([#129]).
160
+ - A spelling error was corrected by Edward Betts ([#129][]).
117
161
 
118
162
  - Administrivia:
119
163
 
120
164
  - CI configuration for more modern versions of Ruby were added by Nicolas
121
- Leger ([#130]), Jun Aruga ([#125]), and Austin Ziegler. Removed
165
+ Leger ([#130][]), Jun Aruga ([#125][]), and Austin Ziegler. Removed
122
166
  ruby-head-clang and rbx (Rubinius) from CI.
123
167
 
124
168
  - Fixed tests which were asserting equality against nil, which will become
@@ -129,18 +173,18 @@
129
173
  - 1 documentation change:
130
174
 
131
175
  - Tim Smith (@tas50) updated the build badges to be SVGs to improve
132
- readability on high-density (retina) screens with pull request [#112].
176
+ readability on high-density (retina) screens with pull request [#112][].
133
177
 
134
178
  - 3 bug fixes
135
179
 
136
180
  - A test for `MIME::Types::Cache` fails under Ruby 2.3 because of frozen
137
- strings, [#118]. This has been fixed.
181
+ strings, [#118][]. This has been fixed.
138
182
 
139
183
  - The JSON data has been incorrectly encoded since the release of
140
184
  mime-types 3 on the `xrefs` field, because of the switch to using a Set
141
185
  to store cross-reference information. This has been fixed.
142
186
 
143
- - A tentative fix for [#117] has been applied, removing the only circular
187
+ - A tentative fix for [#117][] has been applied, removing the only circular
144
188
  require dependencies that exist (and for which there was code to prevent,
145
189
  but the current fix is simpler). I have no way to verify this fix and
146
190
  depending on how things are loaded by `delayed_job`, this fix may not be
@@ -155,22 +199,22 @@
155
199
  - 2 governance changes
156
200
 
157
201
  - This project and the related mime-types-data project are now exclusively
158
- MIT licensed. Resolves [#95].
202
+ MIT licensed. Resolves [#95][].
159
203
 
160
204
  - All projects under the mime-types organization now have a standard code
161
- of conduct adapted from the [Contributor Covenant]. This text can be
162
- found in the [Code-of-Conduct.md] file.
205
+ of conduct adapted from the [Contributor Covenant][]. This text can be
206
+ found in the [Code-of-Conduct.md][] file.
163
207
 
164
208
  - 3 major changes
165
209
 
166
210
  - All methods deprecated in mime-types 2.x have been removed.
167
211
 
168
212
  - mime-types now requires Ruby 2.0 compatibility or later. Resolves
169
- [#97].
213
+ [#97][].
170
214
 
171
215
  - The registry data has been removed from mime-types and put into
172
216
  mime-types-data, maintained and released separately. It can be found at
173
- [mime-types-data].
217
+ [mime-types-data][].
174
218
 
175
219
  - 17 minor changes:
176
220
 
@@ -183,8 +227,9 @@
183
227
  `x-` prefixes.
184
228
 
185
229
  - Improved initialization with an Array works so that extensions do not
186
- need to be wrapped in another array. This means that `%w(text/yaml yaml yml)` works in the same way that `['text/yaml', %w(yaml yml)]` did (and
187
- still does).
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).
188
233
 
189
234
  - Changed `priority_compare` to conform with attributes that no longer
190
235
  exist.
@@ -192,8 +237,8 @@
192
237
  - Changed the internal implementation of extensions to use a frozen Set.
193
238
 
194
239
  - When extensions are set or modified with `add_extensions`, the primary
195
- registry will be informed of a need to reindex extensions. Resolves
196
- [#84].
240
+ registry will be informed of a need to re-index extensions. Resolves
241
+ [#84][].
197
242
 
198
243
  - The preferred extension can be set explicitly. If not set, it will be
199
244
  the first extension. If the preferred extension is not in the extension
@@ -216,7 +261,7 @@
216
261
  - Extracted the class methods to a separate file.
217
262
 
218
263
  - Changed the container implementation to use a Set instead of an Array
219
- to prevent data duplication. Resolves [#79].
264
+ to prevent data duplication. Resolves [#79][].
220
265
 
221
266
  - `MIME::Types::Cache` changes:
222
267
 
@@ -235,7 +280,7 @@
235
280
 
236
281
  - The registry is default loaded from the columnar store by default. The
237
282
  internal format of the columnar store has changed; many of the boolean
238
- flags are now loaded from a single file. Resolves [#85].
283
+ flags are now loaded from a single file. Resolves [#85][].
239
284
 
240
285
  [#79]: https://github.com/mime-types/ruby-mime-types/pull/79
241
286
  [#84]: https://github.com/mime-types/ruby-mime-types/pull/84
@@ -264,6 +309,11 @@
264
309
  [#149]: https://github.com/mime-types/ruby-mime-types/pull/149
265
310
  [#150]: https://github.com/mime-types/ruby-mime-types/pull/150
266
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
267
317
  [code-of-conduct.md]: Code-of-Conduct_md.html
268
318
  [contributor covenant]: http://contributor-covenant.org
269
319
  [mime-types-data]: https://github.com/mime-types/mime-types-data
data/Manifest.txt CHANGED
@@ -1,3 +1,4 @@
1
+ .standard.yml
1
2
  Code-of-Conduct.md
2
3
  Contributing.md
3
4
  History.md
data/README.rdoc CHANGED
@@ -5,7 +5,7 @@ code :: https://github.com/mime-types/ruby-mime-types/
5
5
  bugs :: https://github.com/mime-types/ruby-mime-types/issues
6
6
  rdoc :: http://rdoc.info/gems/mime-types/
7
7
  clog :: https://github.com/mime-types/ruby-mime-types/blob/master/History.md
8
- continuous integration :: {<img src="https://travis-ci.org/mime-types/ruby-mime-types.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/mime-types/ruby-mime-types]
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
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
10
 
11
11
  == Description
data/Rakefile CHANGED
@@ -1,78 +1,40 @@
1
- # frozen_string_literal: true
2
-
3
1
  require "rubygems"
4
2
  require "hoe"
5
3
  require "rake/clean"
6
4
 
7
- # This is required until https://github.com/seattlerb/hoe/issues/112 is fixed
8
- class Hoe
9
- def with_config
10
- config = Hoe::DEFAULT_CONFIG
11
-
12
- rc = File.expand_path("~/.hoerc")
13
- homeconfig = load_config(rc)
14
- config = config.merge(homeconfig)
15
-
16
- localconfig = load_config(File.expand_path(File.join(Dir.pwd, ".hoerc")))
17
- config = config.merge(localconfig)
18
-
19
- yield config, rc
20
- end
21
-
22
- def load_config(name)
23
- File.exist?(name) ? safe_load_yaml(name) : {}
24
- end
25
-
26
- def safe_load_yaml(name)
27
- return safe_load_yaml_file(name) if YAML.respond_to?(:safe_load_file)
28
-
29
- data = IO.binread(name)
30
- YAML.safe_load(data, permitted_classes: [Regexp])
31
- rescue
32
- YAML.safe_load(data, [Regexp])
33
- end
34
-
35
- def safe_load_yaml_file(name)
36
- YAML.safe_load_file(name, permitted_classes: [Regexp])
37
- rescue
38
- YAML.safe_load_file(name, [Regexp])
39
- end
40
- end
41
-
5
+ Hoe.plugin :cov
42
6
  Hoe.plugin :doofus
43
7
  Hoe.plugin :gemspec2
44
- Hoe.plugin :git
8
+ Hoe.plugin :git2
45
9
  Hoe.plugin :minitest
46
- Hoe.plugin :email unless ENV["CI"]
10
+ Hoe.plugin :rubygems
47
11
 
48
12
  spec = Hoe.spec "mime-types" do
49
13
  developer("Austin Ziegler", "halostatue@gmail.com")
50
- self.need_tar = true
51
-
52
- require_ruby_version ">= 2.0"
53
14
 
54
15
  self.history_file = "History.md"
55
16
  self.readme_file = "README.rdoc"
56
17
 
57
18
  license "MIT"
58
19
 
20
+ require_ruby_version ">= 2.0"
21
+
22
+ spec_extras[:metadata] = ->(val) { val["rubygems_mfa_required"] = "true" }
23
+
59
24
  extra_deps << ["mime-types-data", "~> 3.2015"]
60
25
 
26
+ extra_dev_deps << ["hoe", ">= 3.0", "< 5"]
61
27
  extra_dev_deps << ["hoe-doofus", "~> 1.0"]
62
28
  extra_dev_deps << ["hoe-gemspec2", "~> 1.1"]
63
- extra_dev_deps << ["hoe-git", "~> 1.6"]
29
+ extra_dev_deps << ["hoe-git2", "~> 1.7"]
64
30
  extra_dev_deps << ["hoe-rubygems", "~> 1.0"]
65
- extra_dev_deps << ["standard", "~> 1.0"]
66
- extra_dev_deps << ["minitest", "~> 5.4"]
31
+ extra_dev_deps << ["minitest", "~> 5.0"]
67
32
  extra_dev_deps << ["minitest-autotest", "~> 1.0"]
68
- extra_dev_deps << ["minitest-focus", "~> 1.0"]
69
33
  extra_dev_deps << ["minitest-bonus-assertions", "~> 3.0"]
34
+ extra_dev_deps << ["minitest-focus", "~> 1.0"]
70
35
  extra_dev_deps << ["minitest-hooks", "~> 1.4"]
71
36
  extra_dev_deps << ["rake", ">= 10.0", "< 14.0"]
72
-
73
- if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.0")
74
- extra_dev_deps << ["simplecov", "~> 0.7"]
75
- end
37
+ extra_dev_deps << ["standard", "~> 1.0"]
76
38
  end
77
39
 
78
40
  namespace :benchmark do
@@ -235,9 +197,7 @@ namespace :convert do
235
197
 
236
198
  file mark => [rdoc, :setup] do |t|
237
199
  puts "#{rdoc} => #{mark}"
238
- File.open(t.name, "wb") { |target|
239
- target.write @doc_converter.convert(IO.read(t.prerequisites.first))
240
- }
200
+ File.binwrite(t.name, @doc_converter.convert(IO.read(t.prerequisites.first)))
241
201
  end
242
202
 
243
203
  CLEAN.add mark
data/lib/mime/type.rb CHANGED
@@ -93,7 +93,7 @@ class MIME::Type
93
93
  end
94
94
 
95
95
  # The released version of the mime-types library.
96
- VERSION = "3.4.1"
96
+ VERSION = "3.5.1"
97
97
 
98
98
  include Comparable
99
99
 
@@ -224,6 +224,32 @@ class MIME::Type
224
224
  other.is_a?(MIME::Type) && (self == other)
225
225
  end
226
226
 
227
+ # Returns a hash based on the #simplified value.
228
+ #
229
+ # This maintains the invariant that two #eql? instances must have the same
230
+ # #hash (although having the same #hash does *not* imply that the objects are
231
+ # #eql?).
232
+ #
233
+ # To see why, suppose a MIME::Type instance +a+ is compared to another object
234
+ # +b+, and that <code>a.eql?(b)</code> is true. By the definition of #eql?,
235
+ # we know the following:
236
+ #
237
+ # 1. +b+ is a MIME::Type instance itself.
238
+ # 2. <code>a == b</code> is true.
239
+ #
240
+ # Due to the first point, we know that +b+ should respond to the #simplified
241
+ # method. Thus, per the definition of #<=>, we know that +a.simplified+ must
242
+ # be equal to +b.simplified+, as compared by the <=> method corresponding to
243
+ # +a.simplified+.
244
+ #
245
+ # Presumably, if <code>a.simplified <=> b.simplified</code> is +0+, then
246
+ # +a.simplified+ has the same hash as +b.simplified+. So we assume it's
247
+ # suitable for #hash to delegate to #simplified in service of the #eql?
248
+ # invariant.
249
+ def hash
250
+ simplified.hash
251
+ end
252
+
227
253
  # Returns the whole MIME content-type string.
228
254
  #
229
255
  # The content type is a presentation value from the MIME type registry and
@@ -338,7 +364,7 @@ class MIME::Type
338
364
 
339
365
  # Returns the default encoding for the MIME::Type based on the media type.
340
366
  def default_encoding
341
- @media_type == "text" ? "quoted-printable" : "base64"
367
+ (@media_type == "text") ? "quoted-printable" : "base64"
342
368
  end
343
369
 
344
370
  ##
@@ -22,13 +22,13 @@ class << MIME::Types::Cache
22
22
  if cache.version == MIME::Types::Data::VERSION
23
23
  Marshal.load(cache.data)
24
24
  else
25
- MIME::Types.logger.warn <<-WARNING.chomp.strip
25
+ MIME::Types.logger.error <<-WARNING.chomp.strip
26
26
  Could not load MIME::Types cache: invalid version
27
27
  WARNING
28
28
  nil
29
29
  end
30
30
  rescue => e
31
- MIME::Types.logger.warn <<-WARNING.chomp.strip
31
+ MIME::Types.logger.error <<-WARNING.chomp.strip
32
32
  Could not load MIME::Types cache: #{e}
33
33
  WARNING
34
34
  nil
@@ -49,10 +49,6 @@ class << MIME::Types::Cache
49
49
 
50
50
  types ||= MIME::Types.send(:__types__)
51
51
 
52
- File.open(cache_file, "wb") do |f|
53
- f.write(
54
- Marshal.dump(new(MIME::Types::Data::VERSION, Marshal.dump(types)))
55
- )
56
- end
52
+ File.binwrite(cache_file, Marshal.dump(new(MIME::Types::Data::VERSION, Marshal.dump(types))))
57
53
  end
58
54
  end
@@ -10,22 +10,22 @@ module MIME
10
10
  def self.deprecated(klass, sym, message = nil, &block) # :nodoc:
11
11
  level =
12
12
  case klass
13
- when Class, Module
14
- "."
15
- else
16
- klass = klass.class
17
- "#"
13
+ when Class, Module
14
+ "."
15
+ else
16
+ klass = klass.class
17
+ "#"
18
18
  end
19
19
  message =
20
20
  case message
21
- when :private, :protected
22
- "and will be #{message}"
23
- when nil
24
- "and will be removed"
25
- else
26
- message
21
+ when :private, :protected
22
+ "and will be #{message}"
23
+ when nil
24
+ "and will be removed"
25
+ else
26
+ message
27
27
  end
28
- MIME::Types.logger.warn <<-WARNING.chomp.strip
28
+ MIME::Types.logger.debug <<-WARNING.chomp.strip
29
29
  #{caller(2..2).first}: #{klass}#{level}#{sym} is deprecated #{message}.
30
30
  WARNING
31
31
 
@@ -45,7 +45,7 @@ class << MIME::Types
45
45
  def lazy_load?
46
46
  return unless ENV.key?("RUBY_MIME_TYPES_LAZY_LOAD")
47
47
 
48
- MIME::Types.logger.warn <<-WARNING.chomp.strip
48
+ MIME::Types.logger.debug <<-WARNING.chomp.strip
49
49
  Lazy loading ($RUBY_MIME_TYPES_LAZY_LOAD) is deprecated and will be removed.
50
50
  WARNING
51
51
 
data/lib/mime/types.rb CHANGED
@@ -125,12 +125,12 @@ class MIME::Types
125
125
  def [](type_id, complete: false, registered: false)
126
126
  matches =
127
127
  case type_id
128
- when MIME::Type
129
- @type_variants[type_id.simplified]
130
- when Regexp
131
- match(type_id)
132
- else
133
- @type_variants[MIME::Type.simplified(type_id)]
128
+ when MIME::Type
129
+ @type_variants[type_id.simplified]
130
+ when Regexp
131
+ match(type_id)
132
+ else
133
+ @type_variants[MIME::Type.simplified(type_id)]
134
134
  end
135
135
 
136
136
  prune_matches(matches, complete, registered).sort { |a, b|
@@ -152,7 +152,7 @@ class MIME::Types
152
152
  # => [application/xml, image/gif, text/xml]
153
153
  def type_for(filename)
154
154
  Array(filename).flat_map { |fn|
155
- @extension_index[fn.chomp.downcase[/\.?([^.]*?)$/, 1]]
155
+ @extension_index[fn.chomp.downcase[/\.?([^.]*?)\z/m, 1]]
156
156
  }.compact.inject(Set.new, :+).sort { |a, b|
157
157
  a.priority_compare(b)
158
158
  }
@@ -187,7 +187,7 @@ class MIME::Types
187
187
  # truthy value to suppress that warning.
188
188
  def add_type(type, quiet = false)
189
189
  if !quiet && @type_variants[type.simplified].include?(type)
190
- MIME::Types.logger.warn <<-WARNING.chomp.strip
190
+ MIME::Types.logger.debug <<-WARNING.chomp.strip
191
191
  Type #{type} is already registered as a variant of #{type.simplified}.
192
192
  WARNING
193
193
  end
@@ -266,7 +266,27 @@ describe MIME::Type do
266
266
  end
267
267
 
268
268
  it "is true for an equivalent MIME::Type" do
269
- assert text_plain, mime_type("text/Plain")
269
+ assert text_plain.eql?(mime_type("text/Plain"))
270
+ end
271
+
272
+ it "is true for an equivalent subclass of MIME::Type" do
273
+ subclass = Class.new(MIME::Type)
274
+ assert text_plain.eql?(subclass.new("text/plain"))
275
+ end
276
+ end
277
+
278
+ describe "#hash" do
279
+ it "is the same between #eql? MIME::Type instances" do
280
+ assert_equal text_plain.hash, mime_type("text/plain").hash
281
+ end
282
+
283
+ it "is the same between #eql? MIME::Type instances of different classes" do
284
+ subclass = Class.new(MIME::Type)
285
+ assert_equal text_plain.hash, subclass.new("text/plain").hash
286
+ end
287
+
288
+ it "uses the #simplified value" do
289
+ assert_equal text_plain.hash, mime_type("text/Plain").hash
270
290
  end
271
291
  end
272
292
 
@@ -159,6 +159,10 @@ describe MIME::Types do
159
159
  plain_text.add_extensions("xtxt")
160
160
  assert_includes mime_types.type_for("xtxt"), "text/plain"
161
161
  end
162
+
163
+ it "handles newline characters correctly" do
164
+ assert_includes mime_types.type_for("test.pdf\n.txt"), "text/plain"
165
+ end
162
166
  end
163
167
 
164
168
  describe "#count" do
@@ -67,7 +67,7 @@ describe MIME::Types::Cache do
67
67
  it "outputs an error when there is a marshal file incompatibility" do
68
68
  MIME::Types::Cache.save
69
69
  data = File.binread(@cache_file).reverse
70
- File.open(@cache_file, "wb") { |f| f.write(data) }
70
+ File.binwrite(@cache_file, data)
71
71
  MIME::Types.instance_variable_set(:@__types__, nil)
72
72
  assert_output "", /incompatible marshal file format/ do
73
73
  MIME::Types["text/html"]
@@ -100,6 +100,11 @@ describe MIME::Types, "registry" do
100
100
  plain_text.add_extensions("xtxt")
101
101
  assert_includes MIME::Types.type_for("xtxt"), "text/plain"
102
102
  end
103
+
104
+ it "handles newline characters correctly" do
105
+ assert_includes MIME::Types.type_for("test.pdf\n.txt"), "text/plain"
106
+ assert_includes MIME::Types.type_for("test.txt\n.pdf"), "application/pdf"
107
+ end
103
108
  end
104
109
 
105
110
  describe ".count" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mime-types
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.1
4
+ version: 3.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austin Ziegler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-16 00:00:00.000000000 Z
11
+ date: 2023-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types-data
@@ -30,72 +30,78 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '5.14'
33
+ version: '5.19'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '5.14'
40
+ version: '5.19'
41
41
  - !ruby/object:Gem::Dependency
42
- name: hoe-doofus
42
+ name: hoe
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1.0'
47
+ version: '3.0'
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: '5'
48
51
  type: :development
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
51
54
  requirements:
52
- - - "~>"
55
+ - - ">="
53
56
  - !ruby/object:Gem::Version
54
- version: '1.0'
57
+ version: '3.0'
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '5'
55
61
  - !ruby/object:Gem::Dependency
56
- name: hoe-gemspec2
62
+ name: hoe-doofus
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
65
  - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '1.1'
67
+ version: '1.0'
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
72
  - - "~>"
67
73
  - !ruby/object:Gem::Version
68
- version: '1.1'
74
+ version: '1.0'
69
75
  - !ruby/object:Gem::Dependency
70
- name: hoe-git
76
+ name: hoe-gemspec2
71
77
  requirement: !ruby/object:Gem::Requirement
72
78
  requirements:
73
79
  - - "~>"
74
80
  - !ruby/object:Gem::Version
75
- version: '1.6'
81
+ version: '1.1'
76
82
  type: :development
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
86
  - - "~>"
81
87
  - !ruby/object:Gem::Version
82
- version: '1.6'
88
+ version: '1.1'
83
89
  - !ruby/object:Gem::Dependency
84
- name: hoe-rubygems
90
+ name: hoe-git2
85
91
  requirement: !ruby/object:Gem::Requirement
86
92
  requirements:
87
93
  - - "~>"
88
94
  - !ruby/object:Gem::Version
89
- version: '1.0'
95
+ version: '1.7'
90
96
  type: :development
91
97
  prerelease: false
92
98
  version_requirements: !ruby/object:Gem::Requirement
93
99
  requirements:
94
100
  - - "~>"
95
101
  - !ruby/object:Gem::Version
96
- version: '1.0'
102
+ version: '1.7'
97
103
  - !ruby/object:Gem::Dependency
98
- name: standard
104
+ name: hoe-rubygems
99
105
  requirement: !ruby/object:Gem::Requirement
100
106
  requirements:
101
107
  - - "~>"
@@ -123,33 +129,33 @@ dependencies:
123
129
  - !ruby/object:Gem::Version
124
130
  version: '1.0'
125
131
  - !ruby/object:Gem::Dependency
126
- name: minitest-focus
132
+ name: minitest-bonus-assertions
127
133
  requirement: !ruby/object:Gem::Requirement
128
134
  requirements:
129
135
  - - "~>"
130
136
  - !ruby/object:Gem::Version
131
- version: '1.0'
137
+ version: '3.0'
132
138
  type: :development
133
139
  prerelease: false
134
140
  version_requirements: !ruby/object:Gem::Requirement
135
141
  requirements:
136
142
  - - "~>"
137
143
  - !ruby/object:Gem::Version
138
- version: '1.0'
144
+ version: '3.0'
139
145
  - !ruby/object:Gem::Dependency
140
- name: minitest-bonus-assertions
146
+ name: minitest-focus
141
147
  requirement: !ruby/object:Gem::Requirement
142
148
  requirements:
143
149
  - - "~>"
144
150
  - !ruby/object:Gem::Version
145
- version: '3.0'
151
+ version: '1.0'
146
152
  type: :development
147
153
  prerelease: false
148
154
  version_requirements: !ruby/object:Gem::Requirement
149
155
  requirements:
150
156
  - - "~>"
151
157
  - !ruby/object:Gem::Version
152
- version: '3.0'
158
+ version: '1.0'
153
159
  - !ruby/object:Gem::Dependency
154
160
  name: minitest-hooks
155
161
  requirement: !ruby/object:Gem::Requirement
@@ -185,19 +191,19 @@ dependencies:
185
191
  - !ruby/object:Gem::Version
186
192
  version: '14.0'
187
193
  - !ruby/object:Gem::Dependency
188
- name: simplecov
194
+ name: standard
189
195
  requirement: !ruby/object:Gem::Requirement
190
196
  requirements:
191
197
  - - "~>"
192
198
  - !ruby/object:Gem::Version
193
- version: '0.7'
199
+ version: '1.0'
194
200
  type: :development
195
201
  prerelease: false
196
202
  version_requirements: !ruby/object:Gem::Requirement
197
203
  requirements:
198
204
  - - "~>"
199
205
  - !ruby/object:Gem::Version
200
- version: '0.7'
206
+ version: '1.0'
201
207
  - !ruby/object:Gem::Dependency
202
208
  name: rdoc
203
209
  requirement: !ruby/object:Gem::Requirement
@@ -219,19 +225,19 @@ dependencies:
219
225
  - !ruby/object:Gem::Version
220
226
  version: '7'
221
227
  - !ruby/object:Gem::Dependency
222
- name: hoe
228
+ name: simplecov
223
229
  requirement: !ruby/object:Gem::Requirement
224
230
  requirements:
225
231
  - - "~>"
226
232
  - !ruby/object:Gem::Version
227
- version: '3.23'
233
+ version: '0.21'
228
234
  type: :development
229
235
  prerelease: false
230
236
  version_requirements: !ruby/object:Gem::Requirement
231
237
  requirements:
232
238
  - - "~>"
233
239
  - !ruby/object:Gem::Version
234
- version: '3.23'
240
+ version: '0.21'
235
241
  description: |-
236
242
  The mime-types library provides a library and registry for information about
237
243
  MIME content type definitions. It can be used to determine defined filename
@@ -257,6 +263,7 @@ extra_rdoc_files:
257
263
  - Manifest.txt
258
264
  - README.rdoc
259
265
  files:
266
+ - ".standard.yml"
260
267
  - Code-of-Conduct.md
261
268
  - Contributing.md
262
269
  - History.md
@@ -296,6 +303,7 @@ metadata:
296
303
  source_code_uri: https://github.com/mime-types/ruby-mime-types/
297
304
  bug_tracker_uri: https://github.com/mime-types/ruby-mime-types/issues
298
305
  changelog_uri: https://github.com/mime-types/ruby-mime-types/blob/master/History.md
306
+ rubygems_mfa_required: 'true'
299
307
  post_install_message:
300
308
  rdoc_options:
301
309
  - "--main"
@@ -313,7 +321,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
313
321
  - !ruby/object:Gem::Version
314
322
  version: '0'
315
323
  requirements: []
316
- rubygems_version: 3.1.6
324
+ rubygems_version: 3.4.18
317
325
  signing_key:
318
326
  specification_version: 4
319
327
  summary: The mime-types library provides a library and registry for information about