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