mime-types 3.2 → 3.2.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 +6 -0
- data/lib/mime/type.rb +3 -9
- data/lib/mime/types/container.rb +42 -5
- data/test/test_mime_type.rb +1 -3
- data/test/test_mime_types_class.rb +7 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdb4b5717fbcc056be60ca6acbc08a7c607c70844350473acf68aa4b6252e9e8
|
4
|
+
data.tar.gz: b52eacc82336979cd8665abcbc7a9caf6e77834ed159c2232259c5035270a165
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0defd9a40587347fd82255474660e0d0463001d3cbda11884775ccb0a8c026fbd5b204ffefbaf3596222760174301510b5b4dec33545a87bda0a46c528e70740
|
7
|
+
data.tar.gz: 3498c00a5509138051422e425172b931e12ba0d77312fd7e79667607e7a1fe82c921f65e64abb6fdbb8278a3282a5d97db6cfced82293098c92138e26c7f2375
|
data/History.md
CHANGED
data/lib/mime/type.rb
CHANGED
@@ -57,7 +57,7 @@ class MIME::Type
|
|
57
57
|
end
|
58
58
|
|
59
59
|
# The released version of the mime-types library.
|
60
|
-
VERSION = '3.2'
|
60
|
+
VERSION = '3.2.1'
|
61
61
|
|
62
62
|
include Comparable
|
63
63
|
|
@@ -368,13 +368,7 @@ class MIME::Type
|
|
368
368
|
|
369
369
|
##
|
370
370
|
def xrefs=(x) # :nodoc:
|
371
|
-
MIME::Types::Container.new
|
372
|
-
xr.each do |k, v|
|
373
|
-
xr[k] = Set[*v] unless v.kind_of? Set
|
374
|
-
end
|
375
|
-
|
376
|
-
@xrefs = xr
|
377
|
-
end
|
371
|
+
@xrefs = MIME::Types::Container.new(x)
|
378
372
|
end
|
379
373
|
|
380
374
|
# The decoded cross-reference URL list for this MIME::Type.
|
@@ -459,7 +453,7 @@ class MIME::Type
|
|
459
453
|
unless xrefs.empty?
|
460
454
|
{}.tap do |hash|
|
461
455
|
xrefs.each do |k, v|
|
462
|
-
hash[k] = v.sort
|
456
|
+
hash[k] = v.to_a.sort
|
463
457
|
end
|
464
458
|
coder['xrefs'] = hash
|
465
459
|
end
|
data/lib/mime/types/container.rb
CHANGED
@@ -12,20 +12,48 @@ require 'forwardable'
|
|
12
12
|
class MIME::Types::Container #:nodoc:
|
13
13
|
extend Forwardable
|
14
14
|
|
15
|
-
def initialize
|
15
|
+
def initialize(hash = {})
|
16
16
|
@container = {}
|
17
|
+
merge!(hash)
|
17
18
|
end
|
18
19
|
|
19
20
|
def [](key)
|
20
21
|
container[key] || EMPTY_SET
|
21
22
|
end
|
22
23
|
|
24
|
+
def []=(key, value)
|
25
|
+
case value
|
26
|
+
when Set
|
27
|
+
container[key] = value
|
28
|
+
else
|
29
|
+
container[key] = Set[*value]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def merge(other)
|
34
|
+
self.class.new(other)
|
35
|
+
end
|
36
|
+
|
37
|
+
def merge!(other)
|
38
|
+
tap {
|
39
|
+
other = other.kind_of?(MIME::Types::Container) ? other.container : other
|
40
|
+
self.container.merge!(other)
|
41
|
+
normalize
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_hash
|
46
|
+
container
|
47
|
+
end
|
48
|
+
|
23
49
|
def_delegators :@container,
|
50
|
+
:==,
|
24
51
|
:count,
|
52
|
+
:each,
|
25
53
|
:each_value,
|
54
|
+
:empty?,
|
55
|
+
:flat_map,
|
26
56
|
:keys,
|
27
|
-
:merge,
|
28
|
-
:merge!,
|
29
57
|
:select,
|
30
58
|
:values
|
31
59
|
|
@@ -42,16 +70,25 @@ class MIME::Types::Container #:nodoc:
|
|
42
70
|
end
|
43
71
|
|
44
72
|
def encode_with(coder)
|
73
|
+
debugger
|
45
74
|
container.each { |k, v| coder[k] = v.to_a }
|
46
75
|
end
|
47
76
|
|
48
77
|
def init_with(coder)
|
78
|
+
@container = {}
|
49
79
|
coder.map.each { |k, v| container[k] = Set[*v] }
|
50
80
|
end
|
51
81
|
|
52
|
-
|
82
|
+
protected
|
53
83
|
|
54
|
-
|
84
|
+
attr_accessor :container
|
85
|
+
|
86
|
+
def normalize
|
87
|
+
container.each do |k, v|
|
88
|
+
next if v.kind_of?(Set)
|
89
|
+
container[k] = Set[*v]
|
90
|
+
end
|
91
|
+
end
|
55
92
|
|
56
93
|
EMPTY_SET = Set.new.freeze
|
57
94
|
private_constant :EMPTY_SET
|
data/test/test_mime_type.rb
CHANGED
@@ -490,9 +490,7 @@ describe MIME::Type do
|
|
490
490
|
|
491
491
|
describe '#xrefs, #xrefs=' do
|
492
492
|
let(:expected) {
|
493
|
-
{
|
494
|
-
'rfc' => Set[*%w(rfc1234 rfc5678)]
|
495
|
-
}
|
493
|
+
MIME::Types::Container.new({ 'rfc' => Set[*%w(rfc1234 rfc5678)] })
|
496
494
|
}
|
497
495
|
|
498
496
|
it 'returns the expected results' do
|
@@ -44,9 +44,13 @@ describe MIME::Types, 'registry' do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'sorts by priority with multiple matches' do
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
types = MIME::Types[/gzip$/].select { |t|
|
48
|
+
t == 'application/gzip' || t == 'application/x-gzip' || t == 'multipart/x-gzip'
|
49
|
+
}
|
50
|
+
# This is this way because of a new type ending with gzip that only
|
51
|
+
# appears in some data files.
|
52
|
+
assert_equal %w(application/gzip application/x-gzip multipart/x-gzip), types
|
53
|
+
assert_equal 3, types.size
|
50
54
|
end
|
51
55
|
|
52
56
|
it 'can be searched with a string' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mime-types
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Austin Ziegler
|
@@ -338,7 +338,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
338
338
|
version: '0'
|
339
339
|
requirements: []
|
340
340
|
rubyforge_project:
|
341
|
-
rubygems_version: 2.7.
|
341
|
+
rubygems_version: 2.7.7
|
342
342
|
signing_key:
|
343
343
|
specification_version: 4
|
344
344
|
summary: The mime-types library provides a library and registry for information about
|