mime-types 2.0 → 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.
@@ -199,6 +199,12 @@ class TestMIMEType < Minitest::Test
199
199
  yaml = make_yaml_mime_type
200
200
  yaml.extensions = 'yaml'
201
201
  assert_equal(%w(yaml), yaml.extensions)
202
+
203
+ yaml.extensions = %w(yaml yaml)
204
+ assert_equal(%w(yaml), yaml.extensions)
205
+
206
+ yaml.extensions = %w(yz yaml yz yml)
207
+ assert_equal(%w(yaml yml yz), yaml.extensions)
202
208
  end
203
209
 
204
210
  def test_like_eh
@@ -450,6 +456,9 @@ class TestMIMEType < Minitest::Test
450
456
  yaml = make_yaml_mime_type
451
457
  yaml.references = "IANA"
452
458
  assert_equal(%W(IANA), yaml.references)
459
+
460
+ yaml.references = %w(IANA IANA)
461
+ assert_equal(%W(IANA), yaml.references)
453
462
  end
454
463
 
455
464
  def test_url
@@ -460,7 +469,7 @@ class TestMIMEType < Minitest::Test
460
469
 
461
470
  def test_url_equals
462
471
  yaml = make_yaml_mime_type
463
- assert_deprecated("MIME::Type#url=", "and has been renamed to #references=") do
472
+ assert_deprecated("MIME::Type#url=") do
464
473
  yaml.url = "IANA"
465
474
  end
466
475
  assert_equal(%W(IANA), yaml.url)
@@ -469,11 +478,10 @@ class TestMIMEType < Minitest::Test
469
478
  def test_urls
470
479
  yaml = make_yaml_mime_type
471
480
  assert_empty(yaml.urls)
472
- yaml.references = %w(IANA RFC123 DRAFT:xyz LTSW [abc])
481
+ yaml.references = %w(IANA RFC123 DRAFT:xyz [abc])
473
482
  assert_equal(%w(http://www.iana.org/assignments/media-types/text/yaml
474
483
  http://rfc-editor.org/rfc/rfc123.txt
475
484
  http://datatracker.ietf.org/public/idindex.cgi?command=id_details&filename=xyz
476
- http://www.ltsw.se/knbase/internet/text.htp
477
485
  http://www.iana.org/assignments/contact-people.htm#abc),
478
486
  yaml.urls)
479
487
  yaml.references = '[def=lax]'
@@ -22,21 +22,21 @@ class TestMIMETypesQueryClassMethods < Minitest::Test
22
22
  def test_index_with_mime_type
23
23
  xtxp = MIME::Type.new('x-text/x-plain')
24
24
  assert_includes(MIME::Types[xtxp], 'text/plain')
25
- assert_equal(2, MIME::Types[xtxp].size)
25
+ assert_equal(1, MIME::Types[xtxp].size)
26
26
  end
27
27
 
28
28
  def test_index_with_regex
29
29
  assert_includes(MIME::Types[/plain/], 'text/plain')
30
- assert_equal(2, MIME::Types[/plain/].size)
30
+ assert_equal(1, MIME::Types[/plain/].size)
31
31
  end
32
32
 
33
33
  def test_index_with_string
34
34
  assert_includes(MIME::Types['text/plain'], 'text/plain')
35
- assert_equal(2, MIME::Types['text/plain'].size)
35
+ assert_equal(1, MIME::Types['text/plain'].size)
36
36
  end
37
37
 
38
38
  def test_index_with_complete_flag
39
- assert_empty(MIME::Types['text/vnd.fly', complete: true])
39
+ assert_empty(MIME::Types['application/1d-interleaved-parityfec', complete: true])
40
40
  refute_empty(MIME::Types['text/plain', complete: true])
41
41
  end
42
42
 
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: '2.0'
4
+ version: '2.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austin Ziegler
@@ -36,7 +36,7 @@ cert_chain:
36
36
  SlF1Y3hPVG1URjFOYkxGcGlSd1FVWjF6b1piTmcyZTdtU2hjL2VleG5WTFdL
37
37
  Rkt4Um9QNgpLUGozV29EK3NwQjhmQT09Ci0tLS0tRU5EIENFUlRJRklDQVRF
38
38
  LS0tLS0K
39
- date: 2013-10-28 00:00:00.000000000 Z
39
+ date: 2014-01-26 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rubyforge
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '5.0'
61
+ version: '5.2'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: '5.0'
68
+ version: '5.2'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rdoc
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: '4.0'
83
- - !ruby/object:Gem::Dependency
84
- name: hoe-bundler
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ~>
88
- - !ruby/object:Gem::Version
89
- version: '1.2'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ~>
95
- - !ruby/object:Gem::Version
96
- version: '1.2'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: hoe-doofus
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -198,14 +184,14 @@ dependencies:
198
184
  requirements:
199
185
  - - ~>
200
186
  - !ruby/object:Gem::Version
201
- version: '3.7'
187
+ version: '3.8'
202
188
  type: :development
203
189
  prerelease: false
204
190
  version_requirements: !ruby/object:Gem::Requirement
205
191
  requirements:
206
192
  - - ~>
207
193
  - !ruby/object:Gem::Version
208
- version: '3.7'
194
+ version: '3.8'
209
195
  description: ! 'The mime-types library provides a library and registry for information
210
196
  about
211
197
 
@@ -235,34 +221,42 @@ description: ! 'The mime-types library provides a library and registry for infor
235
221
  registrations (see below for the link), RFCs, and W3C recommendations.
236
222
 
237
223
 
238
- The mime-types library uses semantic versioning. This is release 2.0; there are
224
+ This is release 2.1, mostly changing how the MIME type registry is updated from
239
225
 
240
- incompatible changes in the API provided by mime-types, mostly around registry
226
+ the IANA registry (the format of which was incompatibly changed shortly before
241
227
 
242
- initialization (see History.rdoc for full details), and the removal of support
228
+ this release) and taking advantage of the extra data available from IANA
243
229
 
244
- for Ruby 1.8 interpreters.
230
+ registry in the form of MIME::Type#xrefs. In addition, the {LTSW
245
231
 
232
+ list}[http://www.ltsw.se/knbase/internet/mime.htp] has been dropped as a
246
233
 
247
- mime-types (previously called MIME::Types for Ruby) was originally based on
234
+ supported list.
248
235
 
249
- MIME::Types for Perl by Mark Overmeer, copyright 2001 - 2009. It is built to
250
236
 
251
- conform to the MIME types of RFCs 2045 and 2231. It tracks the {IANA
237
+ As a reminder, mime-types 2.x is no longer compatible with Ruby 1.8 and
238
+
239
+ mime-types 1.x is only being maintained for security issues. No new MIME types
252
240
 
253
- registry}[http://www.iana.org/assignments/media-types/]
241
+ or features will be added.
242
+
243
+
244
+ mime-types (previously called MIME::Types for Ruby) was originally based on
245
+
246
+ MIME::Types for Perl by Mark Overmeer, copyright 2001 - 2009. It is built to
254
247
 
255
- ({ftp}[ftp://ftp.iana.org/assignments/media-types]) with some unofficial types
248
+ conform to the MIME types of RFCs 2045 and 2231. It tracks the {IANA Media
256
249
 
257
- added from the {LTSW collection}[http://www.ltsw.se/knbase/internet/mime.htp]
250
+ Types registry}[https://www.iana.org/assignments/media-types/media-types.xhtml]
258
251
 
259
- and added by the users of mime-types.'
252
+ with some types added by the users of mime-types.'
260
253
  email:
261
254
  - austin@rubyforge.org
262
255
  executables: []
263
256
  extensions: []
264
257
  extra_rdoc_files:
265
258
  - Contributing.rdoc
259
+ - History-Types.rdoc
266
260
  - History.rdoc
267
261
  - Licence.rdoc
268
262
  - Manifest.txt
@@ -277,6 +271,7 @@ files:
277
271
  - .travis.yml
278
272
  - Contributing.rdoc
279
273
  - Gemfile
274
+ - History-Types.rdoc
280
275
  - History.rdoc
281
276
  - Licence.rdoc
282
277
  - Manifest.txt
@@ -292,9 +287,10 @@ files:
292
287
  - lib/mime/types/cache.rb
293
288
  - lib/mime/types/loader.rb
294
289
  - lib/mime/types/loader_path.rb
290
+ - support/apache_mime_types.rb
295
291
  - support/benchmarker.rb
296
292
  - support/convert.rb
297
- - support/iana_downloader.rb
293
+ - support/iana_registry.rb
298
294
  - test/fixture/json.json
299
295
  - test/fixture/old-data
300
296
  - test/fixture/yaml.yaml
@@ -329,7 +325,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
329
325
  version: '0'
330
326
  requirements: []
331
327
  rubyforge_project: mime-types
332
- rubygems_version: 2.0.7
328
+ rubygems_version: 2.2.1
333
329
  signing_key:
334
330
  specification_version: 4
335
331
  summary: The mime-types library provides a library and registry for information about
metadata.gz.sig CHANGED
Binary file
@@ -1,201 +0,0 @@
1
- # -*- ruby encoding: utf-8 -*-
2
-
3
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
4
-
5
- require 'open-uri'
6
- require 'nokogiri'
7
- require 'cgi'
8
- require 'fileutils'
9
- require 'yaml'
10
-
11
- ENV['RUBY_MIME_TYPES_LAZY_LOAD'] = 'yes'
12
- require 'mime/types'
13
-
14
- class IANADownloader
15
- INDEX_URL = %q(https://www.iana.org/assignments/media-types/)
16
- MIME_HREF = %r{/assignments/media-types/(.+)/?$}
17
-
18
- def self.download_to(destination)
19
- new(destination).download_all
20
- end
21
-
22
- attr_reader :destination
23
-
24
- def initialize(destination = nil)
25
- @destination =
26
- File.expand_path(destination ||
27
- File.expand_path('../../type-lists', __FILE__))
28
- end
29
-
30
- def download_all
31
- puts "Downloading index of MIME types from #{INDEX_URL}."
32
- index = Nokogiri::HTML(open(INDEX_URL) { |f| f.read })
33
- index.xpath('//a').each do |tag|
34
- next unless tag['href']
35
- href_match = MIME_HREF.match(tag['href'])
36
- next unless href_match
37
- href = href_match.captures.first
38
- next if tag.content == 'example'
39
- download_one(href, tag.content, href)
40
- end
41
- end
42
-
43
- def download_one(url, name = url, type = nil)
44
- if url =~ %r{^https?://}
45
- name = File.basename(url) if name == url
46
- else
47
- url = File.join(INDEX_URL, url)
48
- end
49
-
50
- Parser.download(name, from: url, to: @destination, type: type)
51
- end
52
- end
53
-
54
- class IANADownloader::Parser
55
- def self.download(name, options = {})
56
- new(name, options) do |parser|
57
- parser.parse(parser.download)
58
- parser.save
59
- end
60
- end
61
-
62
- def initialize(name, options = {})
63
- raise ArgumentError, ":from not specified" unless options[:from]
64
- raise ArgumentError, ":to not specified" unless options[:to]
65
-
66
- @name = "#{File.basename(name, '.yml')}.yml"
67
- @from = options[:from]
68
- @to = File.expand_path(options[:to])
69
- @type = File.basename(options[:type] || name, '.yml')
70
- @file = File.join(@to, @name)
71
- @types = load_mime_types || MIME::Types.new
72
-
73
- yield self if block_given?
74
- end
75
-
76
- def download
77
- puts "Downloading #{@name} from #{@from}"
78
- Nokogiri::HTML(open(@from) { |f| f.read })
79
- end
80
-
81
- def parse(html)
82
- nodes = html.xpath('//table//table//tr')
83
-
84
- # How many <td> children does the first node have?
85
- node_count = child_elems(nodes.first).size
86
-
87
- if node_count == 1
88
- # The title node doesn't have what we expect. Let's try it based on
89
- # the first real node.
90
- node_count = child_elems(nodes.first.next).size
91
- end
92
-
93
- nodes.each do |node|
94
- next if node == nodes.first
95
-
96
- elems = child_elems(node)
97
- next if elems.size.zero?
98
-
99
- if elems.size != node_count
100
- warn "size mismatch (#{elems.size} != #{node_count}) in node: #{node}"
101
- next
102
- end
103
-
104
- sub_ix, ref_ix = case elems.size
105
- when 3
106
- [ 1, 2 ]
107
- when 4
108
- [ 1, 3 ]
109
- else
110
- warn "size error (#{elems.size} != {3,4}) in node: #{node}"
111
- raise
112
- end
113
- subtype = elems[sub_ix].content.chomp.strip
114
- refs = child_elems(elems[ref_ix]).map { |ref|
115
- ref = ref.xpath('a') unless ref.name == 'a'
116
- [ ref ].flatten.map { |r| href_to_ref(r) }
117
-
118
- }.flatten
119
-
120
- content_type = [ @type, subtype].join('/')
121
- use_instead = nil
122
- obsolete = false
123
-
124
- if content_type =~ OBSOLETE
125
- content_type = $1
126
- obsolete = true
127
- elsif content_type =~ DEPRECATED
128
- content_type = $1
129
- use_instead = [ $2 ]
130
- obsolete = true
131
- end
132
-
133
- types = @types.select { |t|
134
- (t.content_type == content_type)
135
- }
136
-
137
- if types.empty?
138
- MIME::Type.new(content_type) do |mt|
139
- mt.references = %w(IANA) + refs
140
- mt.registered = true
141
- mt.obsolete = obsolete if obsolete
142
- mt.use_instead = use_instead if use_instead
143
- @types << mt
144
- end
145
- else
146
- types.each { |mt|
147
- mt.references = %w(IANA) + refs
148
- mt.registered = true
149
- mt.obsolete = obsolete if obsolete
150
- mt.use_instead = use_instead if use_instead
151
- }
152
- end
153
- end
154
- end
155
-
156
- def save
157
- FileUtils.mkdir_p(@to)
158
- File.open(@file, 'wb') { |f|
159
- f.puts @types.map.to_a.sort.to_yaml
160
- }
161
- end
162
-
163
- private
164
- def child_elems(node)
165
- node.children.select { |n| n.elem? }
166
- end
167
-
168
- def load_mime_types
169
- if File.exist?(@file)
170
- MIME::Types::Loader.load_from_yaml(@file)
171
- end
172
- end
173
-
174
- def href_to_ref(ref)
175
- case ref['href']
176
- when CONTACT_PEOPLE
177
- tag = CGI::unescape($1).chomp.strip
178
- if tag == ref.content
179
- "[#{ref.content}]"
180
- else
181
- "[#{ref.content}=#{tag}]"
182
- end
183
- when RFC_EDITOR, IETF_RFC, IETF_RFC_TOOLS
184
- "RFC#$1"
185
- when RFC_BAD_EDITOR
186
- ref.content
187
- when %r{(https?://.*)}
188
- "{#{ref.content}=#$1}"
189
- else
190
- ref
191
- end
192
- end
193
-
194
- CONTACT_PEOPLE = %r{https?://www.iana.org/assignments/contact-people.html?l?#(.*)}
195
- RFC_EDITOR = %r{https?://www.rfc-editor.org/rfc/rfc(\d+).txt}
196
- RFC_BAD_EDITOR = %r{https?://www.rfc-editor.org/rfc/rfcxxxx.txt}
197
- IETF_RFC = %r{https?://www.ietf.org/rfc/rfc(\d+).txt}
198
- IETF_RFC_TOOLS = %r{https?://tools.ietf.org/html/rfc(\d+)}
199
- OBSOLETE = %r{(.+)\s+\((?:obsolete|deprecated)\)}i
200
- DEPRECATED = %r{(.+)\s+-\s+DEPRECATED\s+-\s+Please\s+use\s+(.+)}
201
- end