Permalink
Browse files

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.
  • Loading branch information...
1 parent 4ce4b99 commit 84720bb8fee6bac0666c89d0f4c1fdbe5904a961 @bronson bronson committed with Aug 27, 2010
Showing with 9 additions and 0 deletions.
  1. +9 −0 lib/mimemagic.rb
View
@@ -32,6 +32,15 @@ def self.add(type, options)
MAGIC.unshift [type, options[:magic]] if options[:magic]
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
def text?
child_of? 'text/plain'

0 comments on commit 84720bb

Please sign in to comment.