lib/ refactoring. Module Gitlabhq renamed to Gitlab

This commit is contained in:
randx 2012-05-26 13:37:49 +03:00
parent 8ceb94081a
commit 3272620f72
20 changed files with 87 additions and 85 deletions

20
lib/gitlab/encode.rb Normal file
View file

@ -0,0 +1,20 @@
module Gitlab
module Encode
extend self
def utf8 message
return nil unless message
hash = CharlockHolmes::EncodingDetector.detect(message) rescue {}
if hash[:encoding]
CharlockHolmes::Converter.convert(message, hash[:encoding], 'UTF-8')
else
message
end.force_encoding("utf-8")
# Prevent app from crash cause of
# encoding errors
rescue
""
end
end
end