module Onebox::FileTypeFinder
Public Class Methods
from_file_name(file_name)
click to toggle source
# File lib/onebox/file_type_finder.rb, line 51 def self.from_file_name(file_name) lower_name = file_name.downcase # First check against the known lists of "special" files and extensions. return @extensionless_files[lower_name] if @extensionless_files.has_key?(lower_name) @long_file_types.each { |extension, type| return type if lower_name.end_with?(extension) } # Otherwise, just split on the last ".", # but add one so we don't return the "." itself. dot_spot = lower_name.rindex(".") return lower_name[(dot_spot + 1)..-1] if dot_spot # If we couldn't figure it out from the name, # let the highlighter figure it out from the content. "" end