Merge branch 'origin/master'

Conflicts:
	lib/text_sentinel.rb
This commit is contained in:
Jeremy Banks
2013-02-18 21:41:20 -05:00
54 changed files with 1688 additions and 872 deletions

View File

@ -1,5 +1,3 @@
require 'iconv'
#
# Given a string, tell us whether or not is acceptable. Also, remove stuff we don't like
# such as leading / trailing space.
@ -13,13 +11,10 @@ class TextSentinel
end
def initialize(text, opts=nil)
if text.present?
@text = Iconv.new('UTF-8//IGNORE', 'UTF-8').iconv(text.dup)
end
@opts = opts || {}
if @text.present?
if text.present?
@text = text.encode('UTF-8', invalid: :replace, undef: :replace, replace: '')
@text.gsub!(/ +/m, ' ') if @opts[:remove_interior_spaces]
@text.strip! if @opts[:strip]
end