Commit e3402769 authored by Saito's avatar Saito

refator handle_file_type. add velocity jade c header and others syntax detect

parent da424d94
......@@ -40,21 +40,30 @@ module Utils
end
def handle_file_type(file_name, mime_type = nil)
if file_name =~ /(\.rb|\.ru|\.rake|Rakefile|\.gemspec|\.rbx|Gemfile)$/
case file_name
when /(\.pl|\.scala|\.java|\.haml|\.jade|\.scaml|\.html|\.sass|\.scss|\.php|\.erb)$/
$1[1..-1].to_sym
when /(\.c|\.h|\.idc)$/
:c
when /(\.cpp|\.hpp|\.c++|\.h++|\.cc|\.hh|\.cxx|\.hxx)$/
:cpp
when /(\.rb|\.ru|\.rake|Rakefile|\.gemspec|\.rbx|Gemfile)$/
:ruby
elsif file_name =~ /\.py$/
when /(\.py|\.pyw|\.sc|SConstruct|SConscript|\.tac)$/
:python
elsif file_name =~ /(\.pl|\.scala|\.c|\.cpp|\.java|\.haml|\.html|\.sass|\.scss|\.xml|\.php|\.erb)$/
$1[1..-1].to_sym
elsif file_name =~ /\.js$/
when /(\.js|\.json)$/
:javascript
elsif file_name =~ /\.sh$/
when /(\.xml|\.xsl|\.rss|\.xslt|\.xsd|\.wsdl)$/
:xml
when /(\.vm|\.fhtml)$/
:velocity
when /\.sh$/
:bash
elsif file_name =~ /\.coffee$/
when /\.coffee$/
:coffeescript
elsif file_name =~ /\.yml$/
when /(\.yml|\.yaml)$/
:yaml
elsif file_name =~ /\.md$/
when /\.md$/
:minid
else
:text
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment