mime-types 3.2.2 → 3.4.1

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