aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2012-08-20 11:33:16 -0500
committerJoshua Peek <josh@joshpeek.com>2012-08-20 11:33:16 -0500
commitb85aeaad3e8cbbc8e910911166f78394c24bf8a5 (patch)
tree64b84f93895dbbec4cc26dd86d83fa25d4af619e /lib
parent64f350922255b3572b9062200bc6be326b609315 (diff)
Inline mime type lookup into blob helper
Diffstat (limited to 'lib')
-rw-r--r--lib/linguist/blob_helper.rb5
-rw-r--r--lib/linguist/mime.rb18
2 files changed, 4 insertions, 19 deletions
diff --git a/lib/linguist/blob_helper.rb b/lib/linguist/blob_helper.rb
index 09d1bf3..75bee67 100644
--- a/lib/linguist/blob_helper.rb
+++ b/lib/linguist/blob_helper.rb
@@ -32,7 +32,10 @@ module Linguist
#
# 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
diff --git a/lib/linguist/mime.rb b/lib/linguist/mime.rb
index 59f30ad..a1e5555 100644
--- a/lib/linguist/mime.rb
+++ b/lib/linguist/mime.rb
@@ -3,24 +3,6 @@ require 'yaml'
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".