summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Ziegler <austin@zieglers.ca>2014-05-20 21:29:37 -0400
committerAustin Ziegler <austin@zieglers.ca>2014-05-20 21:29:37 -0400
commit07362bbf9ceb184e4c89c37831934423eafb1011 (patch)
treec166e2f94fa4a21dbea6fa3bbef6f1c031c69433
parent96413d7f939bba45b1d98f5216040d37c987fead (diff)
downloadgit-07362bbf9ceb184e4c89c37831934423eafb1011.tar.gz
Fix a bug with MIME::Types#type_for.
* MIME::Types.type_for('unknown') should return [], not [nil].
-rw-r--r--History.rdoc8
-rw-r--r--lib/mime/type.rb2
-rw-r--r--lib/mime/types.rb2
-rw-r--r--mime-types.gemspec29
-rw-r--r--test/test_mime_types.rb1
5 files changed, 25 insertions, 17 deletions
diff --git a/History.rdoc b/History.rdoc
index 8d4ba65faa..1874f6094a 100644
--- a/History.rdoc
+++ b/History.rdoc
@@ -1,3 +1,11 @@
+== 2.3 / 2014-05-DD
+
+* Bugs:
+ * Fixed a bug in <tt>MIME::Types#type_for</tt> where type specifications that
+ did not match a MIME::Type would be returned as +nil+ inside the returned
+ array. This was incorrect behaviour as those values should not have been
+ returned, resulting in an empty array.
+
== 2.2 / 2014-03-14
* Clarified contribution guidelines for MIME types. Resolves
diff --git a/lib/mime/type.rb b/lib/mime/type.rb
index 79a644c45e..11409d2ae7 100644
--- a/lib/mime/type.rb
+++ b/lib/mime/type.rb
@@ -57,7 +57,7 @@ class MIME::Type
end
# The released version of the mime-types library.
- VERSION = '2.2'
+ VERSION = '2.3'
include Comparable
diff --git a/lib/mime/types.rb b/lib/mime/types.rb
index cd3c69fb73..01a7c34a0f 100644
--- a/lib/mime/types.rb
+++ b/lib/mime/types.rb
@@ -166,7 +166,7 @@ class MIME::Types
def type_for(filename, platform = false)
types = Array(filename).flat_map { |fn|
@extension_index[File.basename(fn.chomp.downcase).gsub(/.*\./o, '')]
- }.sort { |a, b| a.priority_compare(b) }.uniq
+ }.compact.sort { |a, b| a.priority_compare(b) }.uniq
if platform
MIME.deprecated(self, __method__,
diff --git a/mime-types.gemspec b/mime-types.gemspec
index c621793c83..25b597df69 100644
--- a/mime-types.gemspec
+++ b/mime-types.gemspec
@@ -1,15 +1,15 @@
# -*- encoding: utf-8 -*-
-# stub: mime-types 2.2 ruby lib
+# stub: mime-types 2.3 ruby lib
Gem::Specification.new do |s|
s.name = "mime-types"
- s.version = "2.2"
+ s.version = "2.3"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib"]
s.authors = ["Austin Ziegler"]
- s.date = "2014-03-14"
- s.description = "The mime-types library provides a library and registry for information about\nMIME content type definitions. It can be used to determine defined filename\nextensions for MIME types, or to use filename extensions to look up the likely\nMIME type definitions.\n\nMIME content types are used in MIME-compliant communications, as in e-mail or\nHTTP traffic, to indicate the type of content which is transmitted. The\nmime-types library provides the ability for detailed information about MIME\nentities (provided as an enumerable collection of MIME::Type objects) to be\ndetermined and used programmatically. There are many types defined by RFCs and\nvendors, so the list is long but by definition incomplete; don't hesitate to to\nadd additional type definitions (see Contributing.rdoc). The primary sources\nfor MIME type definitions found in mime-types is the IANA collection of\nregistrations (see below for the link), RFCs, and W3C recommendations.\n\nThis is release 2.2, \nmostly changing how the MIME type registry is updated from\nthe IANA registry (the format of which was incompatibly changed shortly before\nthis release) and taking advantage of the extra data available from IANA\nregistry in the form of MIME::Type#xrefs. In addition, the {LTSW\nlist}[http://www.ltsw.se/knbase/internet/mime.htp] has been dropped as a\nsupported list.\n\nAs a reminder, mime-types 2.x is no longer compatible with Ruby 1.8 and\nmime-types 1.x is only being maintained for security issues. No new MIME types\nor features will be added.\n\nmime-types (previously called MIME::Types for Ruby) was originally based on\nMIME::Types for Perl by Mark Overmeer, copyright 2001 - 2009. It is built to\nconform to the MIME types of RFCs 2045 and 2231. It tracks the {IANA Media\nTypes registry}[https://www.iana.org/assignments/media-types/media-types.xhtml]\nwith some types added by the users of mime-types."
+ s.date = "2014-05-21"
+ s.description = "The mime-types library provides a library and registry for information about\nMIME content type definitions. It can be used to determine defined filename\nextensions for MIME types, or to use filename extensions to look up the likely\nMIME type definitions.\n\nMIME content types are used in MIME-compliant communications, as in e-mail or\nHTTP traffic, to indicate the type of content which is transmitted. The\nmime-types library provides the ability for detailed information about MIME\nentities (provided as an enumerable collection of MIME::Type objects) to be\ndetermined and used programmatically. There are many types defined by RFCs and\nvendors, so the list is long but by definition incomplete; don't hesitate to to\nadd additional type definitions (see Contributing.rdoc). The primary sources\nfor MIME type definitions found in mime-types is the IANA collection of\nregistrations (see below for the link), RFCs, and W3C recommendations.\n\nThis is release 2.2, mostly changing how the MIME type registry is updated from\nthe IANA registry (the format of which was incompatibly changed shortly before\nthis release) and taking advantage of the extra data available from IANA\nregistry in the form of MIME::Type#xrefs. In addition, the {LTSW\nlist}[http://www.ltsw.se/knbase/internet/mime.htp] has been dropped as a\nsupported list.\n\nAs a reminder, mime-types 2.x is no longer compatible with Ruby 1.8 and\nmime-types 1.x is only being maintained for security issues. No new MIME types\nor features will be added.\n\nmime-types (previously called MIME::Types for Ruby) was originally based on\nMIME::Types for Perl by Mark Overmeer, copyright 2001 - 2009. It is built to\nconform to the MIME types of RFCs 2045 and 2231. It tracks the {IANA Media\nTypes registry}[https://www.iana.org/assignments/media-types/media-types.xhtml]\nwith some types added by the users of mime-types."
s.email = ["halostatue@gmail.com"]
s.extra_rdoc_files = ["Contributing.rdoc", "History-Types.rdoc", "History.rdoc", "Licence.rdoc", "Manifest.txt", "README.rdoc", "docs/COPYING.txt", "docs/artistic.txt", "Contributing.rdoc", "History-Types.rdoc", "History.rdoc", "Licence.rdoc", "README.rdoc"]
s.files = [".autotest", ".coveralls.yml", ".gemtest", ".hoerc", ".minitest.rb", ".travis.yml", "Contributing.rdoc", "Gemfile", "History-Types.rdoc", "History.rdoc", "Licence.rdoc", "Manifest.txt", "README.rdoc", "Rakefile", "data/mime-types.json", "docs/COPYING.txt", "docs/artistic.txt", "lib/mime-types.rb", "lib/mime.rb", "lib/mime/type.rb", "lib/mime/types.rb", "lib/mime/types/cache.rb", "lib/mime/types/loader.rb", "lib/mime/types/loader_path.rb", "support/apache_mime_types.rb", "support/benchmarker.rb", "support/convert.rb", "support/iana_registry.rb", "test/fixture/json.json", "test/fixture/old-data", "test/fixture/yaml.yaml", "test/minitest_helper.rb", "test/test_mime_type.rb", "test/test_mime_types.rb", "test/test_mime_types_cache.rb", "test/test_mime_types_class.rb", "test/test_mime_types_lazy.rb", "test/test_mime_types_loader.rb"]
@@ -17,8 +17,7 @@ Gem::Specification.new do |s|
s.licenses = ["MIT", "Artistic 2.0", "GPL-2"]
s.rdoc_options = ["--main", "README.rdoc"]
s.required_ruby_version = Gem::Requirement.new(">= 1.9.2")
- s.rubyforge_project = "mime-types"
- s.rubygems_version = "2.2.1"
+ s.rubygems_version = "2.2.2"
s.summary = "The mime-types library provides a library and registry for information about MIME content type definitions"
s.test_files = ["test/test_mime_type.rb", "test/test_mime_types.rb", "test/test_mime_types_cache.rb", "test/test_mime_types_class.rb", "test/test_mime_types_lazy.rb", "test/test_mime_types_loader.rb"]
@@ -26,41 +25,41 @@ Gem::Specification.new do |s|
s.specification_version = 4
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_development_dependency(%q<minitest>, ["~> 5.2"])
+ s.add_development_dependency(%q<minitest>, ["~> 5.3"])
s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
s.add_development_dependency(%q<hoe-doofus>, ["~> 1.0"])
s.add_development_dependency(%q<hoe-gemspec2>, ["~> 1.1"])
- s.add_development_dependency(%q<hoe-git>, ["~> 1.5"])
+ s.add_development_dependency(%q<hoe-git>, ["~> 1.6"])
s.add_development_dependency(%q<hoe-rubygems>, ["~> 1.0"])
s.add_development_dependency(%q<hoe-travis>, ["~> 1.2"])
s.add_development_dependency(%q<rake>, ["~> 10.0"])
s.add_development_dependency(%q<simplecov>, ["~> 0.7"])
s.add_development_dependency(%q<coveralls>, ["~> 0.7"])
- s.add_development_dependency(%q<hoe>, ["~> 3.9"])
+ s.add_development_dependency(%q<hoe>, ["~> 3.12"])
else
- s.add_dependency(%q<minitest>, ["~> 5.2"])
+ s.add_dependency(%q<minitest>, ["~> 5.3"])
s.add_dependency(%q<rdoc>, ["~> 4.0"])
s.add_dependency(%q<hoe-doofus>, ["~> 1.0"])
s.add_dependency(%q<hoe-gemspec2>, ["~> 1.1"])
- s.add_dependency(%q<hoe-git>, ["~> 1.5"])
+ s.add_dependency(%q<hoe-git>, ["~> 1.6"])
s.add_dependency(%q<hoe-rubygems>, ["~> 1.0"])
s.add_dependency(%q<hoe-travis>, ["~> 1.2"])
s.add_dependency(%q<rake>, ["~> 10.0"])
s.add_dependency(%q<simplecov>, ["~> 0.7"])
s.add_dependency(%q<coveralls>, ["~> 0.7"])
- s.add_dependency(%q<hoe>, ["~> 3.9"])
+ s.add_dependency(%q<hoe>, ["~> 3.12"])
end
else
- s.add_dependency(%q<minitest>, ["~> 5.2"])
+ s.add_dependency(%q<minitest>, ["~> 5.3"])
s.add_dependency(%q<rdoc>, ["~> 4.0"])
s.add_dependency(%q<hoe-doofus>, ["~> 1.0"])
s.add_dependency(%q<hoe-gemspec2>, ["~> 1.1"])
- s.add_dependency(%q<hoe-git>, ["~> 1.5"])
+ s.add_dependency(%q<hoe-git>, ["~> 1.6"])
s.add_dependency(%q<hoe-rubygems>, ["~> 1.0"])
s.add_dependency(%q<hoe-travis>, ["~> 1.2"])
s.add_dependency(%q<rake>, ["~> 10.0"])
s.add_dependency(%q<simplecov>, ["~> 0.7"])
s.add_dependency(%q<coveralls>, ["~> 0.7"])
- s.add_dependency(%q<hoe>, ["~> 3.9"])
+ s.add_dependency(%q<hoe>, ["~> 3.12"])
end
end
diff --git a/test/test_mime_types.rb b/test/test_mime_types.rb
index 3ffe9d5352..fe7ea324d3 100644
--- a/test/test_mime_types.rb
+++ b/test/test_mime_types.rb
@@ -72,6 +72,7 @@ class TestMIMETypes < Minitest::Test
assert_equal(%w(image/jpeg text/plain),
MIME::Types.type_for(%w(foo.txt foo.jpeg)))
assert_equal(@mime_types.of('gif', true), @mime_types['image/gif'])
+ assert_empty(MIME::Types.type_for('coverallsjson'))
assert_deprecated("MIME::Types#type_for", "using the platform parameter") do
assert_empty(MIME::Types.type_for('jpeg', true))
end