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

[Issue No #352] Fix --csv option doesn't escape newlines #361

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
12 changes: 10 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
Lint/EndAlignment:
AlignWith: variable
EnforcedStyleAlignWith: variable

Metrics/ModuleLength:
Exclude:
- "**/*_spec.rb"

Metrics/BlockLength:
Exclude:
- "**/*_spec.rb"

Metrics/AbcSize:
Enabled: false
Expand Down Expand Up @@ -38,7 +46,7 @@ Style/CollectionMethods:
find_all: 'select'

Style/CaseIndentation:
IndentWhenRelativeTo: end
EnforcedStyle: end

Style/Documentation:
Enabled: false
Expand Down
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ language: ruby

sudo: false

before_install:
- gem update --remote bundler
- gem update --system
- rvm @global do gem uninstall bundler -a -x
- rvm @global do gem install bundler -v 1.13.7

rvm:
- 2.0.0
- 2.1
Expand Down
2 changes: 1 addition & 1 deletion lib/t/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def decode_full_text(message, decode_full_uris = false)
require 'htmlentities'
text = HTMLEntities.new.decode(message.full_text)
text = decode_uris(text, message.uris) if decode_full_uris
text
text.gsub(/\n+/, ' ')
end

def decode_uris(full_text, uri_entities)
Expand Down
8 changes: 2 additions & 6 deletions spec/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,9 @@
415600159486005248,2013-12-24 21:49:34 +0000,_KAIRYALS,My birthday cake was bomb http://t.co/LquXc7JXj4
415600159456632832,2013-12-24 21:49:34 +0000,frozenharryx,RT @LouisTexts: whos tessa? http://t.co/7DJQlmCfuu
415600159452438528,2013-12-24 21:49:34 +0000,MIKEFANTASMA,"Pues nada, aquí armando mi regalo de navidad solo me falta la cara y ya hago mi pedido con santa!.. http://t.co/iDC7bE9o4M"
415600159444439040,2013-12-24 21:49:34 +0000,EleManera,"RT @xmyband: La gente che si arrabbia perché Harry non ha fatto gli auguri a Lou su Twitter.
Non vorrei smontarvi, ma esistono i cellulari e i messaggi."
415600159444439040,2013-12-24 21:49:34 +0000,EleManera,"RT @xmyband: La gente che si arrabbia perché Harry non ha fatto gli auguri a Lou su Twitter. Non vorrei smontarvi, ma esistono i cellulari e i messaggi."
415600159444434944,2013-12-24 21:49:34 +0000,BigAlFerguson,“@IrishRace; Merry Christmas to all our friends and followers from all @IrishRaceRally have a good one! http://t.co/rXFsC2ncFo” @Danloi1
415600159436066816,2013-12-24 21:49:34 +0000,goksantezgel,"RT @nederlandline: Tayyip bey evladımızı severiz Biz ona dua ediyoruz.Fitnelere SAKIN HA!
Mahmud Efndi (ks)
#BedduayaLanetDuayaDavet
http://t.co/h6MUyHxr9x"""
415600159436066816,2013-12-24 21:49:34 +0000,goksantezgel,"RT @nederlandline: Tayyip bey evladımızı severiz Biz ona dua ediyoruz.Fitnelere SAKIN HA! Mahmud Efndi (ks) #BedduayaLanetDuayaDavet http://t.co/h6MUyHxr9x"""
415600159427670016,2013-12-24 21:49:34 +0000,MaimounaLvb,RT @sissokodiaro: Miss mali pa pour les moche mon ga http://t.co/4WnwzoLgAD
415600159423483904,2013-12-24 21:49:34 +0000,MrSilpy,@MrKATANI http://t.co/psk7K8rcND
415600159423094784,2013-12-24 21:49:34 +0000,hunterdl19,RT @MadisonBertini: Jakes turnt http://t.co/P60gYZNL8z
Expand Down
17 changes: 17 additions & 0 deletions spec/utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,23 @@ class Test; end
end
end

describe '#decode_full_text' do
encoded_text = 'RT @person_1: #tag1 test tweet with url. https://test.com/testurl'
tweet1 = Twitter::Tweet.new(id: 1, text: encoded_text)
it 'returns decoded string' do
expect(@test.send(:decode_full_text, tweet1, true)).to eq(encoded_text)
end
context 'with new line character in text' do
encoded_text_with_new_line = 'RT @person_1: #tag1 test tweet with
url.
https://test.com/testurl'
tweet2 = Twitter::Tweet.new(id: 1, text: encoded_text_with_new_line)
it 'returns decoded string with out new line character' do
expect(@test.send(:decode_full_text, tweet2, true)).to eq(encoded_text)
end
end
end

describe '#strip_tags' do
it 'returns string sans tags' do
expect(@test.send(:strip_tags, '<a href="http://twitter.com/#!/download/iphone" rel="nofollow">Twitter for iPhone</a>')).to eq 'Twitter for iPhone'
Expand Down