Skip to content

Commit

Permalink
Inline mime type lookup into blob helper
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Aug 20, 2012
1 parent 64f3509 commit b85aeaa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 67 deletions.
5 changes: 4 additions & 1 deletion lib/linguist/blob_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ def extname
#
# Returns a mime type String.
def mime_type
@mime_type ||= Mime.mime_for(extname.to_s)
@mime_type ||= begin
mime_type = Mime.lookup_mime_type_for(extname.to_s)
mime_type ? mime_type.to_s : 'text/plain'
end
end

# Public: Get the Content-Type header value
Expand Down
18 changes: 0 additions & 18 deletions lib/linguist/mime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,6 @@

module Linguist
module Mime
# Internal: Look up mime type for extension.
#
# ext - The extension String. May include leading "."
#
# Examples
#
# Mime.mime_for('.html')
# # => 'text/html'
#
# Mime.mime_for('txt')
# # => 'text/plain'
#
# Return mime type String otherwise falls back to 'text/plain'.
def self.mime_for(ext)
mime_type = lookup_mime_type_for(ext)
mime_type ? mime_type.to_s : 'text/plain'
end

# Internal: Lookup mime type for extension or mime type
#
# ext_or_mime_type - A file extension ".txt" or mime type "text/plain".
Expand Down
48 changes: 0 additions & 48 deletions test/test_mime.rb

This file was deleted.

0 comments on commit b85aeaa

Please sign in to comment.