Sha256: dfde99df94448cbb1116984d99ff37c82799d9adf01cdb1a926d85b28243d3b0
Contents?: true
Size: 649 Bytes
Versions: 3
Compression:
Stored size: 649 Bytes
Contents
# encoding: utf-8 module ActiveCleaner class TextCleaner < BaseCleaner def clean_value(old_value, record=nil) unless old_value.nil? value = old_value.dup value.strip! # clean the new lines mess among OS value.gsub!(/\r\n|\r/, "\n") # protect stuff to keep with a markup value.gsub!(/\n/, "__NEW_LINE__") value.gsub!(/\s+/, " ") value.gsub!(/ ?__NEW_LINE__ ?/, "__NEW_LINE__") value.gsub!(/(__NEW_LINE__){3,}/, "__NEW_LINE____NEW_LINE__") # reverse the safe markup value.gsub!(/__NEW_LINE__/, "\n") value end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
activecleaner-0.3.0 | lib/active_cleaner/text_cleaner.rb |
activecleaner-0.2.0 | lib/active_cleaner/text_cleaner.rb |
activecleaner-0.1.0 | lib/active_cleaner/text_cleaner.rb |