Module: StepUp::NotesUtil
Instance Method Summary collapse
Instance Method Details
#parse_message(message) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/step-up/notes_util.rb', line 3 def () = safe_gsub(.rstrip.force_encoding("UTF-8")){ |m| m.gsub(/^((?: )*)( )?([^ \-\n])/){ "%s %s %s" % [$1, $2 || '-', $3] } } begin changed = .sub!(/^(\s*-\s.*?\n)(?:\s*\n)+(\s*-\s)/, '\1\2') end until changed.nil? end |
#safe_gsub(message) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/step-up/notes_util.rb', line 11 def safe_gsub() begin yield rescue Exception => e if e..start_with?('invalid byte') yield(.force_encoding('ISO-8859-1').encode('UTF-8')) else raise e end end end |