refator handle_file_type. add velocity jade c header and others syntax detect
This commit is contained in:
parent
da424d9406
commit
e3402769f3
1 changed files with 19 additions and 10 deletions
29
lib/utils.rb
29
lib/utils.rb
|
@ -40,21 +40,30 @@ module Utils
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_file_type(file_name, mime_type = nil)
|
def handle_file_type(file_name, mime_type = nil)
|
||||||
if file_name =~ /(\.rb|\.ru|\.rake|Rakefile|\.gemspec|\.rbx|Gemfile)$/
|
case file_name
|
||||||
:ruby
|
when /(\.pl|\.scala|\.java|\.haml|\.jade|\.scaml|\.html|\.sass|\.scss|\.php|\.erb)$/
|
||||||
elsif file_name =~ /\.py$/
|
|
||||||
:python
|
|
||||||
elsif file_name =~ /(\.pl|\.scala|\.c|\.cpp|\.java|\.haml|\.html|\.sass|\.scss|\.xml|\.php|\.erb)$/
|
|
||||||
$1[1..-1].to_sym
|
$1[1..-1].to_sym
|
||||||
elsif file_name =~ /\.js$/
|
when /(\.c|\.h|\.idc)$/
|
||||||
|
:c
|
||||||
|
when /(\.cpp|\.hpp|\.c++|\.h++|\.cc|\.hh|\.cxx|\.hxx)$/
|
||||||
|
:cpp
|
||||||
|
when /(\.rb|\.ru|\.rake|Rakefile|\.gemspec|\.rbx|Gemfile)$/
|
||||||
|
:ruby
|
||||||
|
when /(\.py|\.pyw|\.sc|SConstruct|SConscript|\.tac)$/
|
||||||
|
:python
|
||||||
|
when /(\.js|\.json)$/
|
||||||
:javascript
|
:javascript
|
||||||
elsif file_name =~ /\.sh$/
|
when /(\.xml|\.xsl|\.rss|\.xslt|\.xsd|\.wsdl)$/
|
||||||
|
:xml
|
||||||
|
when /(\.vm|\.fhtml)$/
|
||||||
|
:velocity
|
||||||
|
when /\.sh$/
|
||||||
:bash
|
:bash
|
||||||
elsif file_name =~ /\.coffee$/
|
when /\.coffee$/
|
||||||
:coffeescript
|
:coffeescript
|
||||||
elsif file_name =~ /\.yml$/
|
when /(\.yml|\.yaml)$/
|
||||||
:yaml
|
:yaml
|
||||||
elsif file_name =~ /\.md$/
|
when /\.md$/
|
||||||
:minid
|
:minid
|
||||||
else
|
else
|
||||||
:text
|
:text
|
||||||
|
|
Loading…
Reference in a new issue