From 2dfadb1ca36111430f29cb6107f28ef326b5bf9a Mon Sep 17 00:00:00 2001 From: vishnu chilamakuru Date: Sat, 4 Feb 2017 23:30:07 +0530 Subject: [PATCH 1/5] [Issue No #352] Fix --csv option doesn't escape newlines --- lib/t/utils.rb | 2 +- spec/search_spec.rb | 8 ++------ spec/utils_spec.rb | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/lib/t/utils.rb b/lib/t/utils.rb index e60a782f..2b89eedb 100644 --- a/lib/t/utils.rb +++ b/lib/t/utils.rb @@ -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) diff --git a/spec/search_spec.rb b/spec/search_spec.rb index 9c4e04a8..811748c1 100644 --- a/spec/search_spec.rb +++ b/spec/search_spec.rb @@ -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 diff --git a/spec/utils_spec.rb b/spec/utils_spec.rb index c15d9069..ac06a8ac 100644 --- a/spec/utils_spec.rb +++ b/spec/utils_spec.rb @@ -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, 'Twitter for iPhone')).to eq 'Twitter for iPhone' From 3996b6fe6ac1591f28d4dfd6850380a2cf7346e3 Mon Sep 17 00:00:00 2001 From: vishnu chilamakuru Date: Sat, 4 Feb 2017 23:45:55 +0530 Subject: [PATCH 2/5] Fix rubocop issue --- .rubocop.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 6efec4fc..ce8bb7f4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,5 @@ Lint/EndAlignment: - AlignWith: variable + EnforcedStyleAlignWith: variable Metrics/AbcSize: Enabled: false @@ -38,7 +38,7 @@ Style/CollectionMethods: find_all: 'select' Style/CaseIndentation: - IndentWhenRelativeTo: end + EnforcedStyle: end Style/Documentation: Enabled: false From b349111c3813065f73ffc9f8cbfbaed398062211 Mon Sep 17 00:00:00 2001 From: vishnu chilamakuru Date: Sun, 5 Feb 2017 00:11:09 +0530 Subject: [PATCH 3/5] Fix rubycop config acording to --- .rubocop.yml | 8 ++++++++ lib/t/utils.rb | 2 +- spec/utils_spec.rb | 6 +++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index ce8bb7f4..938ad98f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,14 @@ Lint/EndAlignment: EnforcedStyleAlignWith: variable +Metrics/ModuleLength: + Exclude: + - "**/*_spec.rb" + +Metrics/BlockLength: + Exclude: + - "**/*_spec.rb" + Metrics/AbcSize: Enabled: false diff --git a/lib/t/utils.rb b/lib/t/utils.rb index 2b89eedb..e31285aa 100644 --- a/lib/t/utils.rb +++ b/lib/t/utils.rb @@ -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.gsub(/\n+/,' ') + text.gsub(/\n+/, ' ') end def decode_uris(full_text, uri_entities) diff --git a/spec/utils_spec.rb b/spec/utils_spec.rb index ac06a8ac..8857a133 100644 --- a/spec/utils_spec.rb +++ b/spec/utils_spec.rb @@ -76,15 +76,15 @@ class Test; end end describe '#decode_full_text' do - encoded_text = "RT @person_1: #tag1 test tweet with url. https://test.com/testurl" + 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 + encoded_text_with_new_line = 'RT @person_1: #tag1 test tweet with url. -https://test.com/testurl" +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) From ed6b49a3fe6fc047a7036c1869d3dde9fcd7b4f2 Mon Sep 17 00:00:00 2001 From: vishnu chilamakuru Date: Sun, 5 Feb 2017 00:32:09 +0530 Subject: [PATCH 4/5] Fix rainbow gem issue for ruby-2.3.3 as mentioned in [https://github.com/sickill/rainbow/issues/44] --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index bc8c89a8..93241bbb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,9 @@ language: ruby sudo: false +before_install: + - gem update --system + rvm: - 2.0.0 - 2.1 From 09aa2a5d7f36862ac2e8b30ce2418308267d8c5b Mon Sep 17 00:00:00 2001 From: vishnu chilamakuru Date: Mon, 13 Feb 2017 22:41:24 +0530 Subject: [PATCH 5/5] Fix travis failures --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 93241bbb..cc7c3f70 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,10 @@ 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