Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes iconv dependency #170

Merged
merged 1 commit into from
Feb 16, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions lib/text_sentinel.rb
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -13,14 +11,11 @@ def self.non_symbols_regexp
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?
@text.strip!
if text.present?
@text = text.encode('UTF-8', invalid: :replace, undef: :replace, replace: '')
@text.strip!
@text.gsub!(/ +/m, ' ') if @opts[:remove_interior_spaces]
end
end
Expand Down
3 changes: 1 addition & 2 deletions spec/components/text_sentinel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

require 'spec_helper'
require 'text_sentinel'
require 'iconv'

describe TextSentinel do

Expand Down Expand Up @@ -100,4 +99,4 @@
end


end
end