Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorArthur Schreiber <schreiber.arthur@gmail.com>2012-04-21 01:21:12 +0400
committerArthur Schreiber <schreiber.arthur@gmail.com>2012-04-21 01:21:12 +0400
commit5b6019f357d01d7871068da15549d19be1a0cf4f (patch)
tree894d260eacf605e9c979c19b30bfbd10de56b78b /lib
parent9ee345750ca43f4e4b0c429ebc913caba9684dcf (diff)
Using github's linguist to better detect filetypes and to do syntax highlighting.
Diffstat (limited to 'lib')
-rw-r--r--lib/utils.rb44
1 files changed, 0 insertions, 44 deletions
diff --git a/lib/utils.rb b/lib/utils.rb
deleted file mode 100644
index 52f3ee2e195..00000000000
--- a/lib/utils.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-module Utils
- module FileHelper
- def binary?(string)
- string.each_byte do |x|
- x.nonzero? or return true
- end
- false
- end
-
- def image?
- mime_type =~ /image/
- end
-
- def text?
- mime_type =~ /application|text/ && !binary?(data)
- end
- end
-
- module Colorize
- def colorize
- system_colorize(data, name)
- end
-
- def system_colorize(data, file_name)
- options = { :encoding => 'utf-8', :linenos => 'True' }
-
- # Try detect language with pygments
- Pygments.highlight data, :filename => file_name, :options => options
- rescue
- # if it fails use manual detection
- ft = handle_file_type(file_name)
- Pygments.highlight(data, :lexer => ft, :options => options)
- end
-
- def handle_file_type(file_name)
- case file_name
- when /(\.ru|Gemfile)$/
- :ruby
- else
- :text
- end
- end
- end
-end