Commit 84720bb8 by Scott Bronson Committed by minad

add the remove function

It's possible for vague magic to cause the wrong filetype to be
detected.  For instance, application/x-gmc-link is seriously
vague (tons of files have "URL:" in the first 32 bytes!).  This
allows you to remove the conflicting filetypes that you're sure
you'll never see.
parent 4ce4b998
...@@ -32,6 +32,15 @@ class MimeMagic ...@@ -32,6 +32,15 @@ class MimeMagic
MAGIC.unshift [type, options[:magic]] if options[:magic] MAGIC.unshift [type, options[:magic]] if options[:magic]
end end
# Removes a mime type from the dictionary. You might want to do this if
# you're seeing impossible conflicts (for instance, application/x-gmc-link).
# * <i>type</i>: The mime type to remove. All associated extensions and magic are removed too.
def self.remove(type)
EXTENSIONS.delete_if {|ext, t| t == type }
MAGIC.delete_if { |t, m| t == type }
TYPES.delete(type)
end
# Returns true if type is a text format # Returns true if type is a text format
def text? def text?
child_of? 'text/plain' child_of? 'text/plain'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment