mime-types 3.3.1 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/Licence.md CHANGED
@@ -1,10 +1,10 @@
1
- ## Licence
1
+ # Licence
2
2
 
3
- * Copyright 2003–2019 Austin Ziegler and contributors.
3
+ - Copyright 2003–2019 Austin Ziegler and contributors.
4
4
 
5
5
  The software in this repository is made available under the MIT license.
6
6
 
7
- ### MIT License
7
+ ## MIT License
8
8
 
9
9
  Permission is hereby granted, free of charge, to any person obtaining a copy of
10
10
  this software and associated documentation files (the "Software"), to deal in
data/README.rdoc CHANGED
@@ -65,6 +65,7 @@ files). A MIME::Type stores the known information about one MIME type.
65
65
  puts text.ascii? # => true
66
66
  puts text.obsolete? # => false
67
67
  puts text.registered? # => true
68
+ puts text.provisional? # => false
68
69
  puts text.complete? # => true
69
70
 
70
71
  puts text # => 'text/plain'
data/Rakefile CHANGED
@@ -1,79 +1,108 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rubygems'
4
- require 'hoe'
5
- require 'rake/clean'
3
+ require "rubygems"
4
+ require "hoe"
5
+ require "rake/clean"
6
+
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
6
41
 
7
42
  Hoe.plugin :doofus
8
43
  Hoe.plugin :gemspec2
9
44
  Hoe.plugin :git
10
45
  Hoe.plugin :minitest
11
- Hoe.plugin :travis
12
- Hoe.plugin :email unless ENV['CI'] or ENV['TRAVIS']
46
+ Hoe.plugin :email unless ENV["CI"]
13
47
 
14
- spec = Hoe.spec 'mime-types' do
15
- developer('Austin Ziegler', 'halostatue@gmail.com')
48
+ spec = Hoe.spec "mime-types" do
49
+ developer("Austin Ziegler", "halostatue@gmail.com")
16
50
  self.need_tar = true
17
51
 
18
- require_ruby_version '>= 2.0'
19
-
20
- self.history_file = 'History.md'
21
- self.readme_file = 'README.rdoc'
22
-
23
- license 'MIT'
24
-
25
- extra_deps << ['mime-types-data', '~> 3.2015']
26
-
27
- extra_dev_deps << ['hoe-doofus', '~> 1.0']
28
- extra_dev_deps << ['hoe-gemspec2', '~> 1.1']
29
- extra_dev_deps << ['hoe-git', '~> 1.6']
30
- extra_dev_deps << ['hoe-rubygems', '~> 1.0']
31
- extra_dev_deps << ['hoe-travis', '~> 1.2']
32
- extra_dev_deps << ['minitest', '~> 5.4']
33
- extra_dev_deps << ['minitest-autotest', '~> 1.0']
34
- extra_dev_deps << ['minitest-focus', '~> 1.0']
35
- extra_dev_deps << ['minitest-bonus-assertions', '~> 3.0']
36
- extra_dev_deps << ['minitest-hooks', '~> 1.4']
37
- extra_dev_deps << ['rake', '>= 10.0', '< 13.0']
38
- extra_dev_deps << ['fivemat', '~> 1.3']
39
- extra_dev_deps << ['minitest-rg', '~> 5.2']
40
-
41
- if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.0')
42
- extra_dev_deps << ['simplecov', '~> 0.7']
43
- # if ENV['CI'] or ENV['TRAVIS']
44
- # extra_dev_deps << ['coveralls', '~> 0.8']
45
- # end
52
+ require_ruby_version ">= 2.0"
53
+
54
+ self.history_file = "History.md"
55
+ self.readme_file = "README.rdoc"
56
+
57
+ license "MIT"
58
+
59
+ extra_deps << ["mime-types-data", "~> 3.2015"]
60
+
61
+ extra_dev_deps << ["hoe-doofus", "~> 1.0"]
62
+ extra_dev_deps << ["hoe-gemspec2", "~> 1.1"]
63
+ extra_dev_deps << ["hoe-git", "~> 1.6"]
64
+ extra_dev_deps << ["hoe-rubygems", "~> 1.0"]
65
+ extra_dev_deps << ["standard", "~> 1.0"]
66
+ extra_dev_deps << ["minitest", "~> 5.4"]
67
+ extra_dev_deps << ["minitest-autotest", "~> 1.0"]
68
+ extra_dev_deps << ["minitest-focus", "~> 1.0"]
69
+ extra_dev_deps << ["minitest-bonus-assertions", "~> 3.0"]
70
+ extra_dev_deps << ["minitest-hooks", "~> 1.4"]
71
+ 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"]
46
75
  end
47
76
  end
48
77
 
49
78
  namespace :benchmark do
50
79
  task :support do
51
- %w(lib support).each { |path|
80
+ %w[lib support].each { |path|
52
81
  $LOAD_PATH.unshift(File.join(Rake.application.original_dir, path))
53
82
  }
54
83
  end
55
84
 
56
- desc 'Benchmark Load Times'
57
- task :load, [:repeats] => 'benchmark:support' do |_, args|
58
- require 'benchmarks/load'
85
+ desc "Benchmark Load Times"
86
+ task :load, [:repeats] => "benchmark:support" do |_, args|
87
+ require "benchmarks/load"
59
88
  Benchmarks::Load.report(
60
- File.join(Rake.application.original_dir, 'lib'),
89
+ File.join(Rake.application.original_dir, "lib"),
61
90
  args.repeats
62
91
  )
63
92
  end
64
93
 
65
- desc 'Allocation counts'
66
- task :allocations, [:top_x, :mime_types_only] => 'benchmark:support' do |_, args|
67
- require 'benchmarks/load_allocations'
94
+ desc "Allocation counts"
95
+ task :allocations, [:top_x, :mime_types_only] => "benchmark:support" do |_, args|
96
+ require "benchmarks/load_allocations"
68
97
  Benchmarks::LoadAllocations.report(
69
98
  top_x: args.top_x,
70
99
  mime_types_only: args.mime_types_only
71
100
  )
72
101
  end
73
102
 
74
- desc 'Columnar allocation counts'
75
- task 'allocations:columnar', [:top_x, :mime_types_only] => 'benchmark:support' do |_, args|
76
- require 'benchmarks/load_allocations'
103
+ desc "Columnar allocation counts"
104
+ task "allocations:columnar", [:top_x, :mime_types_only] => "benchmark:support" do |_, args|
105
+ require "benchmarks/load_allocations"
77
106
  Benchmarks::LoadAllocations.report(
78
107
  columnar: true,
79
108
  top_x: args.top_x,
@@ -81,9 +110,9 @@ namespace :benchmark do
81
110
  )
82
111
  end
83
112
 
84
- desc 'Columnar allocation counts (full load)'
85
- task 'allocations:columnar:full', [:top_x, :mime_types_only] => 'benchmark:support' do |_, args|
86
- require 'benchmarks/load_allocations'
113
+ desc "Columnar allocation counts (full load)"
114
+ task "allocations:columnar:full", [:top_x, :mime_types_only] => "benchmark:support" do |_, args|
115
+ require "benchmarks/load_allocations"
87
116
  Benchmarks::LoadAllocations.report(
88
117
  columnar: true,
89
118
  top_x: args.top_x,
@@ -92,18 +121,18 @@ namespace :benchmark do
92
121
  )
93
122
  end
94
123
 
95
- desc 'Memory profiler'
96
- task :memory, [:top_x, :mime_types_only] => 'benchmark:support' do |_, args|
97
- require 'benchmarks/memory_profiler'
124
+ desc "Memory profiler"
125
+ task :memory, [:top_x, :mime_types_only] => "benchmark:support" do |_, args|
126
+ require "benchmarks/memory_profiler"
98
127
  Benchmarks::ProfileMemory.report(
99
128
  mime_types_only: args.mime_types_only,
100
129
  top_x: args.top_x
101
130
  )
102
131
  end
103
132
 
104
- desc 'Columnar memory profiler'
105
- task 'memory:columnar', [:top_x, :mime_types_only] => 'benchmark:support' do |_, args|
106
- require 'benchmarks/memory_profiler'
133
+ desc "Columnar memory profiler"
134
+ task "memory:columnar", [:top_x, :mime_types_only] => "benchmark:support" do |_, args|
135
+ require "benchmarks/memory_profiler"
107
136
  Benchmarks::ProfileMemory.report(
108
137
  columnar: true,
109
138
  mime_types_only: args.mime_types_only,
@@ -111,9 +140,9 @@ namespace :benchmark do
111
140
  )
112
141
  end
113
142
 
114
- desc 'Columnar allocation counts (full load)'
115
- task 'memory:columnar:full', [:top_x, :mime_types_only] => 'benchmark:support' do |_, args|
116
- require 'benchmarks/memory_profiler'
143
+ desc "Columnar allocation counts (full load)"
144
+ task "memory:columnar:full", [:top_x, :mime_types_only] => "benchmark:support" do |_, args|
145
+ require "benchmarks/memory_profiler"
117
146
  Benchmarks::ProfileMemory.report(
118
147
  columnar: true,
119
148
  full: true,
@@ -122,90 +151,72 @@ namespace :benchmark do
122
151
  )
123
152
  end
124
153
 
125
- desc 'Object counts'
126
- task objects: 'benchmark:support' do
127
- require 'benchmarks/object_counts'
154
+ desc "Object counts"
155
+ task objects: "benchmark:support" do
156
+ require "benchmarks/object_counts"
128
157
  Benchmarks::ObjectCounts.report
129
158
  end
130
159
 
131
- desc 'Columnar object counts'
132
- task 'objects:columnar' => 'benchmark:support' do
133
- require 'benchmarks/object_counts'
160
+ desc "Columnar object counts"
161
+ task "objects:columnar" => "benchmark:support" do
162
+ require "benchmarks/object_counts"
134
163
  Benchmarks::ObjectCounts.report(columnar: true)
135
164
  end
136
165
 
137
- desc 'Columnar object counts (full load)'
138
- task 'objects:columnar:full' => 'benchmark:support' do
139
- require 'benchmarks/object_counts'
166
+ desc "Columnar object counts (full load)"
167
+ task "objects:columnar:full" => "benchmark:support" do
168
+ require "benchmarks/object_counts"
140
169
  Benchmarks::ObjectCounts.report(columnar: true, full: true)
141
170
  end
142
171
  end
143
172
 
144
173
  namespace :profile do
145
- directory 'tmp/profile'
174
+ directory "tmp/profile"
146
175
 
147
- CLEAN.add 'tmp'
176
+ CLEAN.add "tmp"
148
177
 
149
178
  def ruby_prof(script)
150
- require 'pathname'
151
- output = Pathname('tmp/profile').join(script)
179
+ require "pathname"
180
+ output = Pathname("tmp/profile").join(script)
152
181
  output.mkpath
153
- script = Pathname('support/profile').join("#{script}.rb")
182
+ script = Pathname("support/profile").join("#{script}.rb")
154
183
 
155
184
  args = [
156
- '-W0',
157
- '-Ilib',
158
- '-S', 'ruby-prof',
159
- '-R', 'mime/types',
160
- '-s', 'self',
161
- '-p', 'multi',
162
- '-f', output.to_s,
185
+ "-W0",
186
+ "-Ilib",
187
+ "-S", "ruby-prof",
188
+ "-R", "mime/types",
189
+ "-s", "self",
190
+ "-p", "multi",
191
+ "-f", output.to_s,
163
192
  script.to_s
164
193
  ]
165
- ruby args.join(' ')
194
+ ruby args.join(" ")
166
195
  end
167
196
 
168
- task full: 'tmp/profile' do
169
- ruby_prof 'full'
197
+ task full: "tmp/profile" do
198
+ ruby_prof "full"
170
199
  end
171
200
 
172
201
  task columnar: :support do
173
- ruby_prof 'columnar'
202
+ ruby_prof "columnar"
174
203
  end
175
204
 
176
- task 'columnar:full' => :support do
177
- ruby_prof 'columnar_full'
205
+ task "columnar:full" => :support do
206
+ ruby_prof "columnar_full"
178
207
  end
179
208
  end
180
209
 
181
- if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.0')
210
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.0")
182
211
  namespace :test do
183
- # Coveralls needs to be disabled for now because it transitively depends on
184
- # an earlier version of mime-types.
185
- # if ENV['CI'] or ENV['TRAVIS']
186
- # task :coveralls do
187
- # spec.test_prelude = [
188
- # 'require "psych"',
189
- # 'require "simplecov"',
190
- # 'require "coveralls"',
191
- # 'SimpleCov.formatter = Coveralls::SimpleCov::Formatter',
192
- # 'SimpleCov.start("test_frameworks") { command_name "Minitest" }',
193
- # 'gem "minitest"'
194
- # ].join('; ')
195
- # Rake::Task['test'].execute
196
- # end
197
-
198
- # Rake::Task['travis'].prerequisites.replace(%w(test:coveralls))
199
- # end
200
-
201
- desc 'Run test coverage'
212
+ desc "Run test coverage"
202
213
  task :coverage do
203
214
  spec.test_prelude = [
204
215
  'require "simplecov"',
205
216
  'SimpleCov.start("test_frameworks") { command_name "Minitest" }',
206
217
  'gem "minitest"'
207
- ].join('; ')
208
- Rake::Task['test'].execute
218
+ ].join("; ")
219
+ Rake::Task["test"].execute
209
220
  end
210
221
  end
211
222
  end
@@ -213,18 +224,18 @@ end
213
224
  namespace :convert do
214
225
  namespace :docs do
215
226
  task :setup do
216
- gem 'rdoc'
217
- require 'rdoc/rdoc'
227
+ gem "rdoc"
228
+ require "rdoc/rdoc"
218
229
  @doc_converter ||= RDoc::Markup::ToMarkdown.new
219
230
  end
220
231
 
221
- FileList['*.rdoc'].each do |name|
232
+ FileList["*.rdoc"].each do |name|
222
233
  rdoc = name
223
- mark = "#{File.basename(name, '.rdoc')}.md"
234
+ mark = "#{File.basename(name, ".rdoc")}.md"
224
235
 
225
236
  file mark => [rdoc, :setup] do |t|
226
237
  puts "#{rdoc} => #{mark}"
227
- File.open(t.name, 'wb') { |target|
238
+ File.open(t.name, "wb") { |target|
228
239
  target.write @doc_converter.convert(IO.read(t.prerequisites.first))
229
240
  }
230
241
  end
@@ -235,46 +246,21 @@ namespace :convert do
235
246
  end
236
247
  end
237
248
 
238
- desc 'Convert documentation from RDoc to Markdown'
239
- task docs: 'convert:docs:run'
249
+ desc "Convert documentation from RDoc to Markdown"
250
+ task docs: "convert:docs:run"
240
251
  end
241
252
 
242
- task 'deps:top', [:number] do |_, args|
243
- require 'net/http'
244
- require 'json'
245
-
246
- def rubygems_get(gem_name: '', endpoint: '')
247
- path = File.join('/api/v1/gems/', gem_name, endpoint).chomp('/') + '.json'
248
- Net::HTTP.start('rubygems.org', use_ssl: true) do |http|
249
- JSON.parse(http.get(path).body)
250
- end
251
- end
252
-
253
- results = rubygems_get(
254
- gem_name: 'mime-types',
255
- endpoint: 'reverse_dependencies'
256
- )
257
-
258
- weighted_results = {}
259
- results.each do |name|
260
- begin
261
- weighted_results[name] = rubygems_get(gem_name: name)['downloads']
262
- rescue => e
263
- puts "#{name} #{e.message}"
264
- end
265
- end
266
-
267
- weighted_results.sort { |(_k1, v1), (_k2, v2)|
268
- v2 <=> v1
269
- }.first(args.number || 50).each_with_index do |(k, v), i|
270
- puts "#{i}) #{k}: #{v}"
253
+ namespace :deps do
254
+ task :top, [:number] => "benchmark:support" do |_, args|
255
+ require "deps"
256
+ Deps.run(args)
271
257
  end
272
258
  end
273
259
 
274
260
  task :console do
275
- arguments = %w(pry)
261
+ arguments = %w[irb]
276
262
  arguments.push(*spec.spec.require_paths.map { |dir| "-I#{dir}" })
277
- arguments.push("-r#{spec.spec.name.gsub('-', File::SEPARATOR)}")
263
+ arguments.push("-r#{spec.spec.name.gsub("-", File::SEPARATOR)}")
278
264
  unless system(*arguments)
279
265
  error "Command failed: #{show_command}"
280
266
  abort
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mime/type'
3
+ require "mime/type"
4
4
 
5
5
  # A version of MIME::Type that works hand-in-hand with a MIME::Types::Columnar
6
6
  # container to load data by columns.
@@ -35,8 +35,8 @@ class MIME::Type::Columnar < MIME::Type
35
35
  column :encoding, :encoding=
36
36
  column :docs, :docs=
37
37
  column :preferred_extension, :preferred_extension=
38
- column :obsolete, :obsolete=, :obsolete?, :registered, :registered=,
39
- :registered?, :signature, :signature=, :signature?, file: 'flags'
38
+ column :obsolete, :obsolete=, :obsolete?, :registered, :registered=, :registered?, :signature, :signature=,
39
+ :signature?, :provisional, :provisional=, :provisional?, file: "flags"
40
40
  column :xrefs, :xrefs=, :xref_urls
41
41
  column :use_instead, :use_instead=
42
42