Separate special_mime_type method

This commit is contained in:
Joshua Peek
2011-05-16 21:03:55 -04:00
parent 8d5dc01363
commit b22263718d
2 changed files with 19 additions and 6 deletions

View File

@@ -11,11 +11,18 @@ module Linguist
end
def mime_type
@mime_type ||= Mime.lookup(pathname.extname)
@mime_type ||= begin
guesses = MIME::Types.type_for(pathname.extname)
guesses.first ? guesses.first.simplified : 'text/plain'
end
end
def special_mime_type
Mime.lookup(pathname.extname)
end
def disposition
case mime_type
case special_mime_type
when 'application/octet-stream', 'application/java-archive'
"attachment; filename=#{EscapeUtils.escape_url(pathname.basename)}"
else
@@ -36,7 +43,7 @@ module Linguist
end
def binary?
mime_type == 'octet-stream' || !(text? || image?)
special_mime_type == 'octet-stream' || !(text? || image?)
end
def file?