summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Ziegler <austin@zieglers.ca>2021-11-15 13:41:25 -0500
committerAustin Ziegler <austin@zieglers.ca>2023-02-16 22:06:48 -0500
commit1f40eeccc6204e4caa26f2f6d616dd33df0a309a (patch)
tree4e2233c65d935aaf883f99d3517b4de7230f0079
parent32714bc5f1ae6ba044d2710efef2ca38c2734456 (diff)
downloadmime-types-type-for-sort-stability.tar.gz
Standardrb fixuptype-for-sort-stability
-rw-r--r--lib/mime/types.rb4
-rw-r--r--test/test_mime_types.rb10
-rw-r--r--test/test_mime_types_class.rb4
3 files changed, 9 insertions, 9 deletions
diff --git a/lib/mime/types.rb b/lib/mime/types.rb
index 0227810..8bdab63 100644
--- a/lib/mime/types.rb
+++ b/lib/mime/types.rb
@@ -151,8 +151,8 @@ class MIME::Types
def type_for(filename)
results =
Array(filename).flat_map { |fn|
- @extension_index[fn.chomp.downcase[/\.?([^.]*?)$/, 1]]
- }.compact.inject(Set.new, :+)
+ @extension_index[fn.chomp.downcase[/\.?([^.]*?)$/, 1]]
+ }.compact.inject(Set.new, :+)
stable_sort(results)
end
diff --git a/test/test_mime_types.rb b/test/test_mime_types.rb
index 597f0e9..44f3736 100644
--- a/test/test_mime_types.rb
+++ b/test/test_mime_types.rb
@@ -38,7 +38,7 @@ describe MIME::Types do
assert_kind_of Enumerator::Lazy, mime_types.map.lazy
end
- it 'is countable with an enumerator' do
+ it "is countable with an enumerator" do
assert_equal 8, mime_types.each.count
assert_equal 8, mime_types.lazy.count
end
@@ -161,13 +161,13 @@ describe MIME::Types do
assert_includes mime_types.type_for("xtxt"), "text/plain"
end
- it 'returns a stable order for types with equal priority' do
- assert_equal %w(audio/webm video/webm), mime_types.type_for('foo.webm')
+ it "returns a stable order for types with equal priority" do
+ assert_equal %w[audio/webm video/webm], mime_types.type_for("foo.webm")
end
end
- describe '#count' do
- it 'can count the number of types inside' do
+ describe "#count" do
+ it "can count the number of types inside" do
assert_equal 8, mime_types.count
end
end
diff --git a/test/test_mime_types_class.rb b/test/test_mime_types_class.rb
index 84fff6f..d82bfe4 100644
--- a/test/test_mime_types_class.rb
+++ b/test/test_mime_types_class.rb
@@ -101,8 +101,8 @@ describe MIME::Types, "registry" do
assert_includes MIME::Types.type_for("xtxt"), "text/plain"
end
- it 'returns a stable order for types with equal priority' do
- assert_equal %w(audio/webm video/webm), MIME::Types.type_for('foo.webm')
+ it "returns a stable order for types with equal priority" do
+ assert_equal %w[audio/webm video/webm], MIME::Types.type_for("foo.webm")
end
end