summaryrefslogtreecommitdiff
path: root/lib/mime/type/columnar.rb
diff options
context:
space:
mode:
authorAustin Ziegler <austin@zieglers.ca>2022-01-06 23:06:12 -0500
committerAustin Ziegler <austin@zieglers.ca>2023-02-16 22:06:37 -0500
commit2b8ae866c21c309805460e90973bf6ce6820a72b (patch)
treed436642aa9056ce65ba9e30e1c3f76f208d15f6b /lib/mime/type/columnar.rb
parent8748d86a175eaa3df0e42f61e1556c235a1f5aaf (diff)
downloadmime-types-2b8ae866c21c309805460e90973bf6ce6820a72b.tar.gz
Ensure priority sort over alpha sort
- Added extension priority map. This is an imperfect solution, and is not used by default with default configuration (column-based data). - We may want to consider a revised columnar format for a future version that has a bit more information than is present in the base file. - Adding the sort priority and extension priority helped, but because the alphanumeric sort was first in `MIME::Type#priority_compare`, the results weren't as good as they should have been. We now sort by the sort priority values _first_ and the alphanumeric values _second_. - Stored sort priority was not respected because it depends on flags not kept in the base file. Added support for a binary file with this to ensure it is loaded.
Diffstat (limited to 'lib/mime/type/columnar.rb')
-rw-r--r--lib/mime/type/columnar.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/mime/type/columnar.rb b/lib/mime/type/columnar.rb
index ec4dec2..a51f9d9 100644
--- a/lib/mime/type/columnar.rb
+++ b/lib/mime/type/columnar.rb
@@ -53,6 +53,17 @@ class MIME::Type::Columnar < MIME::Type
super
end
+ def update_sort_priority
+ if @container.__fully_loaded?
+ super
+ else
+ obsolete = (@__sort_priority & (1 << 7)) != 0
+ registered = (@__sort_priority & (1 << 5)) == 0
+
+ @__priority_penalty = (@obsolete ? 3 : 0) + (@registered ? 0 : 2)
+ end
+ end
+
class << self
undef column
end