Commit e3402769f341b9787d738aaf03e41d27315cd2ac
1 parent
da424d94
Exists in
master
and in
4 other branches
refator handle_file_type. add velocity jade c header and others syntax detect
Showing
1 changed file
with
18 additions
and
9 deletions
Show diff stats
lib/utils.rb
| ... | ... | @@ -40,21 +40,30 @@ module Utils |
| 40 | 40 | end |
| 41 | 41 | |
| 42 | 42 | def handle_file_type(file_name, mime_type = nil) |
| 43 | - if file_name =~ /(\.rb|\.ru|\.rake|Rakefile|\.gemspec|\.rbx|Gemfile)$/ | |
| 43 | + case file_name | |
| 44 | + when /(\.pl|\.scala|\.java|\.haml|\.jade|\.scaml|\.html|\.sass|\.scss|\.php|\.erb)$/ | |
| 45 | + $1[1..-1].to_sym | |
| 46 | + when /(\.c|\.h|\.idc)$/ | |
| 47 | + :c | |
| 48 | + when /(\.cpp|\.hpp|\.c++|\.h++|\.cc|\.hh|\.cxx|\.hxx)$/ | |
| 49 | + :cpp | |
| 50 | + when /(\.rb|\.ru|\.rake|Rakefile|\.gemspec|\.rbx|Gemfile)$/ | |
| 44 | 51 | :ruby |
| 45 | - elsif file_name =~ /\.py$/ | |
| 52 | + when /(\.py|\.pyw|\.sc|SConstruct|SConscript|\.tac)$/ | |
| 46 | 53 | :python |
| 47 | - elsif file_name =~ /(\.pl|\.scala|\.c|\.cpp|\.java|\.haml|\.html|\.sass|\.scss|\.xml|\.php|\.erb)$/ | |
| 48 | - $1[1..-1].to_sym | |
| 49 | - elsif file_name =~ /\.js$/ | |
| 54 | + when /(\.js|\.json)$/ | |
| 50 | 55 | :javascript |
| 51 | - elsif file_name =~ /\.sh$/ | |
| 56 | + when /(\.xml|\.xsl|\.rss|\.xslt|\.xsd|\.wsdl)$/ | |
| 57 | + :xml | |
| 58 | + when /(\.vm|\.fhtml)$/ | |
| 59 | + :velocity | |
| 60 | + when /\.sh$/ | |
| 52 | 61 | :bash |
| 53 | - elsif file_name =~ /\.coffee$/ | |
| 62 | + when /\.coffee$/ | |
| 54 | 63 | :coffeescript |
| 55 | - elsif file_name =~ /\.yml$/ | |
| 64 | + when /(\.yml|\.yaml)$/ | |
| 56 | 65 | :yaml |
| 57 | - elsif file_name =~ /\.md$/ | |
| 66 | + when /\.md$/ | |
| 58 | 67 | :minid |
| 59 | 68 | else |
| 60 | 69 | :text | ... | ... |