Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

45 lines (44 sloc) 1.394 kb
class AlbinoFiletype
EXTENSION_TO_FILETYPE = {
".as" => :actionscript,
".c" => :c,
".cc" => :cpp,
".clj" => :clojure,
".coffee" => :coffeescript,
".cpp" => :cpp,
".css" => :css,
".erb" => :rhtml,
".go" => :go,
".god" => :ruby,
".h" => :cpp,
".hpp" => :cpp,
".inl" => :cpp,
".java" => :java,
".js" => :javascript,
".json" => :json,
".jsp" => :jsp,
".less" => :scss,
".py" => :python,
".rake" => :ruby,
".rb" => :ruby,
".sbt" => :scala,
".scala" => :scala,
".scss" => :scss,
".sh" => :bash,
".xml" => :xml,
"Cakefile" => :coffeescript,
"Capfile" => :ruby,
"Gemfile" => :ruby,
"Makefile" => :make,
"Rakefile" => :ruby,
"Vagrantfile" => :ruby
}
def self.detect_filetype(filename)
# if path, separate file from path
filename = filename.include?("/") ? filename[(filename.index(%r{/[^/]+$}) + 1)..-1] : filename
extension_index = filename.index(/\.[^\.]+$/)
extension = extension_index ? filename[extension_index..-1] : nil
filetype = extension ? EXTENSION_TO_FILETYPE[extension] : EXTENSION_TO_FILETYPE[filename]
filetype || :text
end
end
Jump to Line
Something went wrong with that request. Please try again.