diff options
author | Saito <saitowu@gmail.com> | 2011-12-05 18:21:44 +0800 |
---|---|---|
committer | Saito <saitowu@gmail.com> | 2011-12-05 18:21:44 +0800 |
commit | e3402769f341b9787d738aaf03e41d27315cd2ac (patch) | |
tree | 7679057f1cce894f570715fc802b2c8762322e55 /lib | |
parent | da424d9406c1f69394cbaf051841208127e18e00 (diff) | |
download | gitlab-ce-e3402769f341b9787d738aaf03e41d27315cd2ac.tar.gz |
refator handle_file_type. add velocity jade c header and others syntax detect
Diffstat (limited to 'lib')
-rw-r--r-- | lib/utils.rb | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/lib/utils.rb b/lib/utils.rb index 411abef2f69..17c9dfe3dd2 100644 --- a/lib/utils.rb +++ b/lib/utils.rb @@ -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 |