Commit 7fd651421d82719075b348a5632b7540a4ede00a
1 parent
f3d20c8f
Exists in
community_hub_submodule
Code cleaned
Showing
1 changed file
with
8 additions
and
8 deletions
Show diff stats
tweeter_stream/lib/twurl/request_controller.rb
| ... | ... | @@ -4,6 +4,7 @@ require 'iconv' |
| 4 | 4 | module Twurl |
| 5 | 5 | class RequestController < AbstractCommandController |
| 6 | 6 | NO_URI_MESSAGE = "No URI specified" |
| 7 | + | |
| 7 | 8 | def dispatch |
| 8 | 9 | if client.needs_to_authorize? |
| 9 | 10 | raise Exception, "You need to authorize first." |
| ... | ... | @@ -16,7 +17,7 @@ module Twurl |
| 16 | 17 | client.perform_request_from_options(options) { |response| |
| 17 | 18 | chunk_begining = "" |
| 18 | 19 | puts "Connecting to tweeter stream : " + response.inspect |
| 19 | - response.read_body { |chunk| | |
| 20 | + response.read_body { |chunk| | |
| 20 | 21 | chunk = chunk_begining + chunk |
| 21 | 22 | chunk_complete = false |
| 22 | 23 | unless chunk.blank? |
| ... | ... | @@ -27,7 +28,6 @@ module Twurl |
| 27 | 28 | rescue JSON::ParserError => e |
| 28 | 29 | chunk_begining = chunk |
| 29 | 30 | chunk_complete = false |
| 30 | -# puts "@@@@@@@@ Erro fazendo parse do chunk #{e.inspect} @@@@@@@@\n\n" | |
| 31 | 31 | end |
| 32 | 32 | begin |
| 33 | 33 | if chunk_complete |
| ... | ... | @@ -39,20 +39,20 @@ module Twurl |
| 39 | 39 | comment.source = options.page |
| 40 | 40 | comment.body = comment_text |
| 41 | 41 | comment.author_id = options.author_id |
| 42 | - #Attention please, don't remove + ' ')[0..-2] it is used for UTF8 validation | |
| 42 | + #Attention please, don't remove + ' ')[0..-2] it is used for UTF8 validation | |
| 43 | 43 | comment.name = ic.iconv(parsed["user"]["name"] + ' ')[0..-2] |
| 44 | 44 | comment.email = 'admin@localhost.local' |
| 45 | 45 | comment.save! |
| 46 | 46 | puts "@#{comment.name} " +_('said') + ": #{comment_text}" |
| 47 | - end | |
| 47 | + end | |
| 48 | 48 | rescue => e |
| 49 | 49 | puts "Erro gravando comentário twitter #{e.inspect}" |
| 50 | 50 | end |
| 51 | 51 | end |
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | - rescue URI::InvalidURIError | |
| 55 | - Stream.puts NO_URI_MESSAGE | |
| 56 | - end | |
| 54 | + rescue URI::InvalidURIError | |
| 55 | + Stream.puts NO_URI_MESSAGE | |
| 56 | + end | |
| 57 | 57 | end |
| 58 | 58 | -end |
| 59 | +end | |
| 59 | 60 | \ No newline at end of file | ... | ... |