diff --git a/tweeter_stream/lib/twurl/request_controller.rb b/tweeter_stream/lib/twurl/request_controller.rb index 99ea38c..368a9d8 100755 --- a/tweeter_stream/lib/twurl/request_controller.rb +++ b/tweeter_stream/lib/twurl/request_controller.rb @@ -4,6 +4,7 @@ require 'iconv' module Twurl class RequestController < AbstractCommandController NO_URI_MESSAGE = "No URI specified" + def dispatch if client.needs_to_authorize? raise Exception, "You need to authorize first." @@ -16,7 +17,7 @@ module Twurl client.perform_request_from_options(options) { |response| chunk_begining = "" puts "Connecting to tweeter stream : " + response.inspect - response.read_body { |chunk| + response.read_body { |chunk| chunk = chunk_begining + chunk chunk_complete = false unless chunk.blank? @@ -27,7 +28,6 @@ module Twurl rescue JSON::ParserError => e chunk_begining = chunk chunk_complete = false -# puts "@@@@@@@@ Erro fazendo parse do chunk #{e.inspect} @@@@@@@@\n\n" end begin if chunk_complete @@ -39,20 +39,20 @@ module Twurl comment.source = options.page comment.body = comment_text comment.author_id = options.author_id - #Attention please, don't remove + ' ')[0..-2] it is used for UTF8 validation + #Attention please, don't remove + ' ')[0..-2] it is used for UTF8 validation comment.name = ic.iconv(parsed["user"]["name"] + ' ')[0..-2] comment.email = 'admin@localhost.local' comment.save! puts "@#{comment.name} " +_('said') + ": #{comment_text}" - end + end rescue => e puts "Erro gravando comentário twitter #{e.inspect}" end end } } - rescue URI::InvalidURIError - Stream.puts NO_URI_MESSAGE - end + rescue URI::InvalidURIError + Stream.puts NO_URI_MESSAGE + end end -end +end \ No newline at end of file -- libgit2 0.21.2