kinetic_sdk 5.0.18 → 5.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/gems/{mime-types-3.1/Code-of-Conduct.rdoc → mime-types-3.3.1/Code-of-Conduct.md} +19 -20
- data/gems/{mime-types-3.1/Contributing.rdoc → mime-types-3.3.1/Contributing.md} +67 -54
- data/gems/mime-types-3.3.1/History.md +240 -0
- data/gems/{mime-types-data-3.2016.0521 → mime-types-3.3.1}/Licence.md +1 -1
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/Manifest.txt +4 -4
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/README.rdoc +5 -14
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/Rakefile +43 -13
- data/gems/mime-types-3.3.1/lib/mime-types.rb +3 -0
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/lib/mime/type.rb +60 -46
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/lib/mime/type/columnar.rb +4 -2
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/lib/mime/types.rb +11 -8
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/lib/mime/types/_columnar.rb +10 -9
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/lib/mime/types/cache.rb +7 -5
- data/gems/mime-types-3.3.1/lib/mime/types/columnar.rb +3 -0
- data/gems/mime-types-3.3.1/lib/mime/types/container.rb +96 -0
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/lib/mime/types/deprecations.rb +3 -3
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/lib/mime/types/full.rb +2 -0
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/lib/mime/types/loader.rb +2 -4
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/lib/mime/types/logger.rb +3 -1
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/lib/mime/types/registry.rb +12 -3
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/test/bad-fixtures/malformed +0 -0
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/test/fixture/json.json +0 -0
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/test/fixture/old-data +0 -0
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/test/fixture/yaml.yaml +0 -0
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/test/minitest_helper.rb +1 -1
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/test/test_mime_type.rb +33 -26
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/test/test_mime_types.rb +33 -25
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/test/test_mime_types_cache.rb +15 -6
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/test/test_mime_types_class.rb +18 -14
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/test/test_mime_types_lazy.rb +10 -4
- data/gems/{mime-types-3.1 → mime-types-3.3.1}/test/test_mime_types_loader.rb +1 -1
- data/gems/{mime-types-data-3.2016.0521 → mime-types-data-3.2021.0225}/Code-of-Conduct.md +10 -10
- data/gems/mime-types-data-3.2021.0225/Contributing.md +224 -0
- data/gems/mime-types-data-3.2021.0225/History.md +468 -0
- data/gems/{mime-types-3.1/Licence.rdoc → mime-types-data-3.2021.0225/Licence.md} +3 -3
- data/gems/{mime-types-data-3.2016.0521 → mime-types-data-3.2021.0225}/Manifest.txt +13 -0
- data/gems/mime-types-data-3.2021.0225/README.md +63 -0
- data/gems/mime-types-data-3.2021.0225/Rakefile +159 -0
- data/gems/mime-types-data-3.2021.0225/data/mime-types.json +1 -0
- data/gems/{mime-types-data-3.2016.0521 → mime-types-data-3.2021.0225}/data/mime.content_type.column +364 -13
- data/gems/{mime-types-data-3.2016.0521 → mime-types-data-3.2021.0225}/data/mime.docs.column +351 -0
- data/gems/{mime-types-data-3.2016.0521 → mime-types-data-3.2021.0225}/data/mime.encoding.column +351 -0
- data/gems/{mime-types-data-3.2016.0521 → mime-types-data-3.2021.0225}/data/mime.flags.column +352 -1
- data/gems/{mime-types-data-3.2016.0521 → mime-types-data-3.2021.0225}/data/mime.friendly.column +351 -0
- data/gems/{mime-types-data-3.2016.0521 → mime-types-data-3.2021.0225}/data/mime.pext.column +351 -0
- data/gems/{mime-types-data-3.2016.0521 → mime-types-data-3.2021.0225}/data/mime.use_instead.column +351 -0
- data/gems/{mime-types-data-3.2016.0521 → mime-types-data-3.2021.0225}/data/mime.xrefs.column +480 -129
- data/gems/{mime-types-data-3.2016.0521 → mime-types-data-3.2021.0225}/lib/mime-types-data.rb +0 -0
- data/gems/{mime-types-data-3.2016.0521 → mime-types-data-3.2021.0225}/lib/mime/types/data.rb +1 -1
- data/gems/mime-types-data-3.2021.0225/types/application.yaml +16933 -0
- data/gems/mime-types-data-3.2021.0225/types/audio.yaml +1714 -0
- data/gems/mime-types-data-3.2021.0225/types/chemical.yaml +71 -0
- data/gems/mime-types-data-3.2021.0225/types/conference.yaml +9 -0
- data/gems/mime-types-data-3.2021.0225/types/drawing.yaml +15 -0
- data/gems/mime-types-data-3.2021.0225/types/font.yaml +65 -0
- data/gems/mime-types-data-3.2021.0225/types/image.yaml +1251 -0
- data/gems/mime-types-data-3.2021.0225/types/message.yaml +200 -0
- data/gems/mime-types-data-3.2021.0225/types/model.yaml +331 -0
- data/gems/mime-types-data-3.2021.0225/types/multipart.yaml +179 -0
- data/gems/mime-types-data-3.2021.0225/types/text.yaml +1145 -0
- data/gems/mime-types-data-3.2021.0225/types/video.yaml +1094 -0
- data/gems/mime-types-data-3.2021.0225/types/world.yaml +8 -0
- data/kinetic_sdk.gemspec +3 -3
- data/lib/kinetic_sdk.rb +2 -2
- data/lib/kinetic_sdk/version.rb +1 -1
- metadata +86 -73
- data/gems/mime-types-3.1/History.rdoc +0 -658
- data/gems/mime-types-3.1/lib/mime-types.rb +0 -1
- data/gems/mime-types-3.1/lib/mime/types/columnar.rb +0 -1
- data/gems/mime-types-3.1/lib/mime/types/container.rb +0 -30
- data/gems/mime-types-data-3.2016.0521/Contributing.md +0 -157
- data/gems/mime-types-data-3.2016.0521/History.md +0 -351
- data/gems/mime-types-data-3.2016.0521/README.md +0 -61
- data/gems/mime-types-data-3.2016.0521/Rakefile +0 -80
- data/gems/mime-types-data-3.2016.0521/data/mime-types.json +0 -1
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'mime/type'
|
2
4
|
|
3
5
|
# A version of MIME::Type that works hand-in-hand with a MIME::Types::Columnar
|
@@ -18,7 +20,7 @@ class MIME::Type::Columnar < MIME::Type
|
|
18
20
|
end
|
19
21
|
|
20
22
|
def self.column(*methods, file: nil) # :nodoc:
|
21
|
-
file
|
23
|
+
file ||= methods.first
|
22
24
|
|
23
25
|
file_method = :"load_#{file}"
|
24
26
|
methods.each do |m|
|
@@ -34,7 +36,7 @@ class MIME::Type::Columnar < MIME::Type
|
|
34
36
|
column :docs, :docs=
|
35
37
|
column :preferred_extension, :preferred_extension=
|
36
38
|
column :obsolete, :obsolete=, :obsolete?, :registered, :registered=,
|
37
|
-
|
39
|
+
:registered?, :signature, :signature=, :signature?, file: 'flags'
|
38
40
|
column :xrefs, :xrefs=, :xref_urls
|
39
41
|
column :use_instead, :use_instead=
|
40
42
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
##
|
2
4
|
module MIME
|
3
5
|
##
|
@@ -149,11 +151,11 @@ class MIME::Types
|
|
149
151
|
def type_for(filename)
|
150
152
|
Array(filename).flat_map { |fn|
|
151
153
|
@extension_index[fn.chomp.downcase[/\.?([^.]*?)$/, 1]]
|
152
|
-
}.compact.inject(:+).sort { |a, b|
|
154
|
+
}.compact.inject(Set.new, :+).sort { |a, b|
|
153
155
|
a.priority_compare(b)
|
154
156
|
}
|
155
157
|
end
|
156
|
-
|
158
|
+
alias of type_for
|
157
159
|
|
158
160
|
# Add one or more MIME::Type objects to the set of known types. If the
|
159
161
|
# type is already known, a warning will be displayed.
|
@@ -169,7 +171,7 @@ class MIME::Types
|
|
169
171
|
nil
|
170
172
|
when MIME::Types
|
171
173
|
variants = mime_type.instance_variable_get(:@type_variants)
|
172
|
-
add(*variants.values.inject(:+).to_a, quiet)
|
174
|
+
add(*variants.values.inject(Set.new, :+).to_a, quiet)
|
173
175
|
when Array
|
174
176
|
add(*mime_type, quiet)
|
175
177
|
else
|
@@ -183,9 +185,9 @@ class MIME::Types
|
|
183
185
|
# truthy value to suppress that warning.
|
184
186
|
def add_type(type, quiet = false)
|
185
187
|
if !quiet and @type_variants[type.simplified].include?(type)
|
186
|
-
MIME::Types.logger.warn <<-
|
188
|
+
MIME::Types.logger.warn <<-WARNING
|
187
189
|
Type #{type} is already registered as a variant of #{type.simplified}.
|
188
|
-
|
190
|
+
WARNING
|
189
191
|
end
|
190
192
|
|
191
193
|
add_type_variant!(type)
|
@@ -195,16 +197,17 @@ Type #{type} is already registered as a variant of #{type.simplified}.
|
|
195
197
|
private
|
196
198
|
|
197
199
|
def add_type_variant!(mime_type)
|
198
|
-
@type_variants
|
200
|
+
@type_variants.add(mime_type.simplified, mime_type)
|
199
201
|
end
|
200
202
|
|
201
203
|
def reindex_extensions!(mime_type)
|
202
204
|
return unless @type_variants[mime_type.simplified].include?(mime_type)
|
205
|
+
|
203
206
|
index_extensions!(mime_type)
|
204
207
|
end
|
205
208
|
|
206
209
|
def index_extensions!(mime_type)
|
207
|
-
mime_type.extensions.each { |ext| @extension_index
|
210
|
+
mime_type.extensions.each { |ext| @extension_index.add(ext, mime_type) }
|
208
211
|
end
|
209
212
|
|
210
213
|
def prune_matches(matches, complete, registered)
|
@@ -216,7 +219,7 @@ Type #{type} is already registered as a variant of #{type.simplified}.
|
|
216
219
|
def match(pattern)
|
217
220
|
@type_variants.select { |k, _|
|
218
221
|
k =~ pattern
|
219
|
-
}.values.inject(:+)
|
222
|
+
}.values.inject(Set.new, :+)
|
220
223
|
end
|
221
224
|
end
|
222
225
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'mime/type/columnar'
|
2
4
|
|
3
5
|
# MIME::Types::Columnar is used to extend a MIME::Types container to load data
|
@@ -43,7 +45,7 @@ module MIME::Types::Columnar
|
|
43
45
|
i = -1
|
44
46
|
column = File.join(@__root__, "mime.#{name}.column")
|
45
47
|
|
46
|
-
IO.readlines(column, encoding: 'UTF-8'
|
48
|
+
IO.readlines(column, encoding: 'UTF-8').each do |line|
|
47
49
|
line.chomp!
|
48
50
|
|
49
51
|
if lookup
|
@@ -61,7 +63,6 @@ module MIME::Types::Columnar
|
|
61
63
|
def load_encoding
|
62
64
|
each_file_line('encoding') do |type, line|
|
63
65
|
pool ||= {}
|
64
|
-
line.freeze
|
65
66
|
type.instance_variable_set(:@encoding, (pool[line] ||= line))
|
66
67
|
end
|
67
68
|
end
|
@@ -106,11 +107,11 @@ module MIME::Types::Columnar
|
|
106
107
|
end
|
107
108
|
|
108
109
|
def dict(line, array: false)
|
109
|
-
if line == '-'
|
110
|
+
if line == '-'
|
110
111
|
{}
|
111
112
|
else
|
112
|
-
line.split('|'
|
113
|
-
k, v = l.split('^'
|
113
|
+
line.split('|').each_with_object({}) { |l, h|
|
114
|
+
k, v = l.split('^')
|
114
115
|
v = nil if v.empty?
|
115
116
|
h[k] = array ? Array(v) : v
|
116
117
|
}
|
@@ -118,18 +119,18 @@ module MIME::Types::Columnar
|
|
118
119
|
end
|
119
120
|
|
120
121
|
def arr(line)
|
121
|
-
if line == '-'
|
122
|
+
if line == '-'
|
122
123
|
[]
|
123
124
|
else
|
124
|
-
line.split('|'
|
125
|
+
line.split('|').flatten.compact.uniq
|
125
126
|
end
|
126
127
|
end
|
127
128
|
|
128
129
|
def opt(line)
|
129
|
-
line unless line == '-'
|
130
|
+
line unless line == '-'
|
130
131
|
end
|
131
132
|
|
132
133
|
def flag(line)
|
133
|
-
line == '1'
|
134
|
+
line == '1'
|
134
135
|
end
|
135
136
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
MIME::Types::Cache = Struct.new(:version, :data) # :nodoc:
|
2
4
|
|
3
5
|
# Caching of MIME::Types registries is advisable if you will be loading
|
@@ -20,16 +22,16 @@ class << MIME::Types::Cache
|
|
20
22
|
if cache.version == MIME::Types::Data::VERSION
|
21
23
|
Marshal.load(cache.data)
|
22
24
|
else
|
23
|
-
MIME::Types.logger.warn <<-
|
25
|
+
MIME::Types.logger.warn <<-WARNING.chomp
|
24
26
|
Could not load MIME::Types cache: invalid version
|
25
|
-
|
27
|
+
WARNING
|
26
28
|
nil
|
27
29
|
end
|
28
30
|
rescue => e
|
29
|
-
MIME::Types.logger.warn <<-
|
31
|
+
MIME::Types.logger.warn <<-WARNING.chomp
|
30
32
|
Could not load MIME::Types cache: #{e}
|
31
|
-
|
32
|
-
|
33
|
+
WARNING
|
34
|
+
nil
|
33
35
|
end
|
34
36
|
|
35
37
|
# Attempts to save the types provided to the cache file provided.
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'set'
|
4
|
+
require 'forwardable'
|
5
|
+
|
6
|
+
# MIME::Types requires a serializable keyed container that returns an empty Set
|
7
|
+
# on a key miss. Hash#default_value cannot be used because, while it traverses
|
8
|
+
# the Marshal format correctly, it won't survive any other serialization
|
9
|
+
# format (plus, a default of a mutable object resuls in a shared mess).
|
10
|
+
# Hash#default_proc cannot be used without a wrapper because it prevents
|
11
|
+
# Marshal serialization (and doesn't survive the round-trip).
|
12
|
+
class MIME::Types::Container #:nodoc:
|
13
|
+
extend Forwardable
|
14
|
+
|
15
|
+
def initialize(hash = {})
|
16
|
+
@container = {}
|
17
|
+
merge!(hash)
|
18
|
+
end
|
19
|
+
|
20
|
+
def [](key)
|
21
|
+
container[key] || EMPTY_SET
|
22
|
+
end
|
23
|
+
|
24
|
+
def []=(key, value)
|
25
|
+
container[key] =
|
26
|
+
case value
|
27
|
+
when Set
|
28
|
+
value
|
29
|
+
else
|
30
|
+
Set[*value]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def merge(other)
|
35
|
+
self.class.new(other)
|
36
|
+
end
|
37
|
+
|
38
|
+
def merge!(other)
|
39
|
+
tap {
|
40
|
+
other = other.kind_of?(MIME::Types::Container) ? other.container : other
|
41
|
+
container.merge!(other)
|
42
|
+
normalize
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_hash
|
47
|
+
container
|
48
|
+
end
|
49
|
+
|
50
|
+
def_delegators :@container,
|
51
|
+
:==,
|
52
|
+
:count,
|
53
|
+
:each,
|
54
|
+
:each_value,
|
55
|
+
:empty?,
|
56
|
+
:flat_map,
|
57
|
+
:keys,
|
58
|
+
:select,
|
59
|
+
:values
|
60
|
+
|
61
|
+
def add(key, value)
|
62
|
+
(container[key] ||= Set.new).add(value)
|
63
|
+
end
|
64
|
+
|
65
|
+
def marshal_dump
|
66
|
+
{}.merge(container)
|
67
|
+
end
|
68
|
+
|
69
|
+
def marshal_load(hash)
|
70
|
+
@container = hash
|
71
|
+
end
|
72
|
+
|
73
|
+
def encode_with(coder)
|
74
|
+
container.each { |k, v| coder[k] = v.to_a }
|
75
|
+
end
|
76
|
+
|
77
|
+
def init_with(coder)
|
78
|
+
@container = {}
|
79
|
+
coder.map.each { |k, v| container[k] = Set[*v] }
|
80
|
+
end
|
81
|
+
|
82
|
+
protected
|
83
|
+
|
84
|
+
attr_accessor :container
|
85
|
+
|
86
|
+
def normalize
|
87
|
+
container.each do |k, v|
|
88
|
+
next if v.kind_of?(Set)
|
89
|
+
|
90
|
+
container[k] = Set[*v]
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
EMPTY_SET = Set.new.freeze
|
95
|
+
private_constant :EMPTY_SET
|
96
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'mime/types/logger'
|
4
4
|
|
@@ -23,9 +23,9 @@ module MIME
|
|
23
23
|
else
|
24
24
|
message
|
25
25
|
end
|
26
|
-
MIME::Types.logger.warn <<-
|
26
|
+
MIME::Types.logger.warn <<-WARNING.chomp
|
27
27
|
#{caller[1]}: #{klass}#{level}#{sym} is deprecated #{message}.
|
28
|
-
|
28
|
+
WARNING
|
29
29
|
block.call if block
|
30
30
|
end
|
31
31
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# -*- ruby encoding: utf-8 -*-
|
2
4
|
|
3
5
|
##
|
@@ -31,10 +33,6 @@ class MIME::Types::Loader
|
|
31
33
|
path = path || ENV['RUBY_MIME_TYPES_DATA'] || MIME::Types::Data::PATH
|
32
34
|
@container = container || MIME::Types.new
|
33
35
|
@path = File.expand_path(path)
|
34
|
-
# begin
|
35
|
-
# require 'mime/lazy_types'
|
36
|
-
# @container.extend(MIME::LazyTypes)
|
37
|
-
# end
|
38
36
|
end
|
39
37
|
|
40
38
|
# Loads a MIME::Types registry from YAML files (<tt>*.yml</tt> or
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# -*- ruby encoding: utf-8 -*-
|
2
4
|
|
3
5
|
require 'logger'
|
@@ -25,7 +27,7 @@ module MIME
|
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
28
|
-
def initialize(
|
30
|
+
def initialize(_one, _two = nil, _three = nil)
|
29
31
|
super nil
|
30
32
|
@logdev = WarnLogDevice.new
|
31
33
|
@formatter = ->(_s, _d, _p, m) { m }
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class << MIME::Types
|
2
4
|
include Enumerable
|
3
5
|
|
@@ -31,7 +33,7 @@ class << MIME::Types
|
|
31
33
|
def type_for(filename)
|
32
34
|
__types__.type_for(filename)
|
33
35
|
end
|
34
|
-
|
36
|
+
alias of type_for
|
35
37
|
|
36
38
|
# MIME::Types#add against the default MIME::Types registry.
|
37
39
|
def add(*types)
|
@@ -41,6 +43,12 @@ class << MIME::Types
|
|
41
43
|
private
|
42
44
|
|
43
45
|
def lazy_load?
|
46
|
+
return unless ENV.key?('RUBY_MIME_TYPES_LAZY_LOAD')
|
47
|
+
|
48
|
+
MIME::Types.logger.warn <<-WARNING.chomp
|
49
|
+
Lazy loading ($RUBY_MIME_TYPES_LAZY_LOAD) is deprecated and will be removed.
|
50
|
+
WARNING
|
51
|
+
|
44
52
|
(lazy = ENV['RUBY_MIME_TYPES_LAZY_LOAD']) && (lazy != 'false')
|
45
53
|
end
|
46
54
|
|
@@ -55,8 +63,9 @@ class << MIME::Types
|
|
55
63
|
end
|
56
64
|
|
57
65
|
def load_default_mime_types(mode = load_mode)
|
58
|
-
@__types__ = MIME::Types::Cache.load
|
59
|
-
|
66
|
+
if (@__types__ = MIME::Types::Cache.load)
|
67
|
+
__instances__.add(@__types__)
|
68
|
+
else
|
60
69
|
@__types__ = MIME::Types::Loader.load(mode)
|
61
70
|
MIME::Types::Cache.save(@__types__)
|
62
71
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,11 +1,9 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'mime/types'
|
4
4
|
require 'minitest_helper'
|
5
5
|
|
6
6
|
describe MIME::Type do
|
7
|
-
# it { fail }
|
8
|
-
|
9
7
|
def mime_type(content_type)
|
10
8
|
MIME::Type.new(content_type) { |mt| yield mt if block_given? }
|
11
9
|
end
|
@@ -48,15 +46,15 @@ describe MIME::Type do
|
|
48
46
|
|
49
47
|
it 'does not remove x- prefixes by default' do
|
50
48
|
assert_equal 'application/x-msword',
|
51
|
-
|
49
|
+
MIME::Type.simplified('application/x-msword')
|
52
50
|
assert_equal 'x-xyz/abc', MIME::Type.simplified('x-xyz/abc')
|
53
51
|
end
|
54
52
|
|
55
53
|
it 'removes x- prefixes when requested' do
|
56
54
|
assert_equal 'application/msword',
|
57
|
-
|
55
|
+
MIME::Type.simplified('application/x-msword', remove_x_prefix: true)
|
58
56
|
assert_equal 'xyz/abc',
|
59
|
-
|
57
|
+
MIME::Type.simplified('x-xyz/abc', remove_x_prefix: true)
|
60
58
|
end
|
61
59
|
|
62
60
|
it 'lowercases mixed-case types' do
|
@@ -75,7 +73,7 @@ describe MIME::Type do
|
|
75
73
|
|
76
74
|
it 'does not remove x-prefixes' do
|
77
75
|
assert_equal 'application.x-msword',
|
78
|
-
|
76
|
+
MIME::Type.i18n_key('application/x-msword')
|
79
77
|
end
|
80
78
|
|
81
79
|
it 'converts text/vCard to text.vcard' do
|
@@ -330,21 +328,32 @@ describe MIME::Type do
|
|
330
328
|
assert_priority text_1, text_1p, text_2
|
331
329
|
end
|
332
330
|
|
333
|
-
it 'sorts (2) based on
|
331
|
+
it 'sorts (2) based on extensions' do
|
332
|
+
text_1.extensions = ['foo', 'bar']
|
333
|
+
text_2.extensions = ['foo']
|
334
|
+
|
335
|
+
assert_priority_same text_1, text_2
|
336
|
+
|
337
|
+
text_2.registered = true
|
338
|
+
|
339
|
+
assert_priority_more text_1, text_2
|
340
|
+
end
|
341
|
+
|
342
|
+
it 'sorts (3) based on the registration state' do
|
334
343
|
text_1.registered = text_1p.registered = true
|
335
344
|
text_1b = mime_type(text_1) { |t| t.registered = false }
|
336
345
|
|
337
346
|
assert_priority text_1, text_1p, text_1b
|
338
347
|
end
|
339
348
|
|
340
|
-
it 'sorts (
|
349
|
+
it 'sorts (4) based on the completeness' do
|
341
350
|
text_1.extensions = text_1p.extensions = '1'
|
342
351
|
text_1b = mime_type(text_1) { |t| t.extensions = nil }
|
343
352
|
|
344
353
|
assert_priority text_1, text_1p, text_1b
|
345
354
|
end
|
346
355
|
|
347
|
-
it 'sorts (
|
356
|
+
it 'sorts (5) based on obsolete status' do
|
348
357
|
text_1.obsolete = text_1p.obsolete = false
|
349
358
|
text_1b = mime_type(text_1) { |t| t.obsolete = true }
|
350
359
|
|
@@ -427,12 +436,12 @@ describe MIME::Type do
|
|
427
436
|
|
428
437
|
it 'has the extensions key if set' do
|
429
438
|
assert_has_keys mime_type(t) { |v| v.extensions = 'a' }.to_h,
|
430
|
-
|
439
|
+
'extensions'
|
431
440
|
end
|
432
441
|
|
433
442
|
it 'has the preferred-extension key if set' do
|
434
443
|
assert_has_keys mime_type(t) { |v| v.preferred_extension = 'a' }.to_h,
|
435
|
-
|
444
|
+
'preferred-extension'
|
436
445
|
end
|
437
446
|
|
438
447
|
it 'has the obsolete key if set' do
|
@@ -463,7 +472,7 @@ describe MIME::Type do
|
|
463
472
|
|
464
473
|
describe '#to_s, #to_str' do
|
465
474
|
it 'represents itself as a string of the canonical content_type' do
|
466
|
-
assert_equal 'text/plain',
|
475
|
+
assert_equal 'text/plain', text_plain.to_s
|
467
476
|
end
|
468
477
|
|
469
478
|
it 'acts like a string of the canonical content_type for comparison' do
|
@@ -477,9 +486,7 @@ describe MIME::Type do
|
|
477
486
|
|
478
487
|
describe '#xrefs, #xrefs=' do
|
479
488
|
let(:expected) {
|
480
|
-
|
481
|
-
'rfc' => Set[*%w(rfc1234 rfc5678)]
|
482
|
-
}
|
489
|
+
MIME::Types::Container.new('rfc' => Set['rfc1234', 'rfc5678'])
|
483
490
|
}
|
484
491
|
|
485
492
|
it 'returns the expected results' do
|
@@ -507,13 +514,13 @@ describe MIME::Type do
|
|
507
514
|
let(:type) {
|
508
515
|
mime_type('a/b').tap do |t|
|
509
516
|
t.xrefs = {
|
510
|
-
'draft'
|
511
|
-
'template'
|
512
|
-
'person'
|
513
|
-
'rfc'
|
514
|
-
'rfc-errata' => [
|
515
|
-
'uri'
|
516
|
-
'text'
|
517
|
+
'draft' => ['RFC1'],
|
518
|
+
'template' => ['a/b'],
|
519
|
+
'person' => ['p-1'],
|
520
|
+
'rfc' => ['rfc-1'],
|
521
|
+
'rfc-errata' => ['err-1'],
|
522
|
+
'uri' => ['http://example.org'],
|
523
|
+
'text' => ['text']
|
517
524
|
}
|
518
525
|
end
|
519
526
|
}
|
@@ -577,10 +584,10 @@ describe MIME::Type do
|
|
577
584
|
|
578
585
|
it 'merges new values from an array parameter' do
|
579
586
|
expected = { 'en' => 'Text files' }
|
580
|
-
assert_equal expected, text_plain.friendly([
|
587
|
+
assert_equal expected, text_plain.friendly(['en', 'Text files'])
|
581
588
|
expected.update('fr' => 'des fichiers texte')
|
582
589
|
assert_equal expected,
|
583
|
-
|
590
|
+
text_plain.friendly(['fr', 'des fichiers texte'])
|
584
591
|
end
|
585
592
|
|
586
593
|
it 'merges new values from a hash parameter' do
|
@@ -597,7 +604,7 @@ describe MIME::Type do
|
|
597
604
|
end
|
598
605
|
|
599
606
|
assert_equal 'Expected a language or translation set, not 1',
|
600
|
-
|
607
|
+
exception.message
|
601
608
|
end
|
602
609
|
end
|
603
610
|
end
|