Skip to content

Commit

Permalink
feat: add clearing deprecated unicode characters
Browse files Browse the repository at this point in the history
  • Loading branch information
Korotaev Danil committed Jun 3, 2016
1 parent b3cbd16 commit 697be2c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/string_tools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ def clear_control_characters(string)
string.tr("\u0000-\u001f", '')
end

# Public: вычищает устаревшие Unicode символы из строки
#
# string - String строка, из которой удаляем символы
#
# Returns String
def clear_deprecated_unicode_characters(string)
string.tr("\u2028-\u2029", '')
end

# Public: вычищает все html тэги и пробельные символы
#
# string - String строка для очистки
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/lsps.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
indi
ssoluble

stri
ng
10 changes: 10 additions & 0 deletions spec/string_tools_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@
end
end

describe '#clear_deprecated_unicode_characters' do
subject(:clear_deprecated_unicode_characters) { described_class.clear_deprecated_unicode_characters(string) }

context 'string with \u2029\u2029 symbols' do
let(:string) { File.open('spec/fixtures/lsps.txt', &:readline) }

it { expect(clear_deprecated_unicode_characters).to eq('indissolublestring') }
end
end

describe '#strip_all_tags_and_entities' do
subject(:strip_all_tags_and_entities) { described_class.strip_all_tags_and_entities(string) }

Expand Down

0 comments on commit 697be2c

Please sign in to comment.