Created
November 22, 2011 14:51
-
-
Save jaspertandy/1385833 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'uri' | |
Earthquake.init do | |
output_filter do |item| | |
next unless item['text'] | |
text = item["text"] | |
text.scan( /http:\/\/t\.co\/[a-zA-Z0-9\-]+/ ).each do |url| | |
uri = URI.parse url | |
Net::HTTP::start( uri.host , uri.port ) do |connection| | |
connection.request_get uri.path do |response| | |
text.gsub! url , response['Location'] | |
end | |
end | |
end | |
text | |
end | |
end |
Hi,
Thx for this plugin, it's working great. However I encounter the same erroneous behavior with the latest version of your script.
You said you modified the core, that would be interesting to know what you modified.
Here's the stacktrace that appear in the console for reference:
earthquake: [ERROR] can't convert nil into String
/Users/brice/.earthquake/plugin/expand_tco.rb:11:in `gsub!'
/Users/brice/.earthquake/plugin/expand_tco.rb:11:in `block (5 levels) in <top (required)>'
/usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/1.9.1/net/http.rb:1322:in `block (2 levels) in transport_request'
/usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/1.9.1/net/http.rb:2671:in `reading_body'
/usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/1.9.1/net/http.rb:1321:in `block in transport_request'
/usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/1.9.1/net/http.rb:1316:in `catch'
/usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/1.9.1/net/http.rb:1316:in `transport_request'
/usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/1.9.1/net/http.rb:1293:in `request'
/usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/1.9.1/net/http.rb:1195:in `request_get'
/Users/brice/.earthquake/plugin/expand_tco.rb:10:in `block (4 levels) in <top (required)>'
/usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/1.9.1/net/http.rb:745:in `start'
/usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/1.9.1/net/http.rb:557:in `start'
/Users/brice/.earthquake/plugin/expand_tco.rb:9:in `block (3 levels) in <top (required)>'
/Users/brice/.earthquake/plugin/expand_tco.rb:7:in `each'
/Users/brice/.earthquake/plugin/expand_tco.rb:7:in `block (2 levels) in <top (required)>'
/usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/gems/1.9.1/gems/earthquake-0.8.4/lib/earthquake/output.rb:36:in `call'
/usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/gems/1.9.1/gems/earthquake-0.8.4/lib/earthquake/output.rb:36:in `block (2 levels) in puts_items'
/usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/gems/1.9.1/gems/earthquake-0.8.4/lib/earthquake/output.rb:36:in `each'
/usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/gems/1.9.1/gems/earthquake-0.8.4/lib/earthquake/output.rb:36:in `any?'
https://gist.github.com/3187216
Fixed problem I was getting with empty String with some links.
@adamtomecek Thank's a lot for this!
This solved the issue :)
https://gist.github.com/Kjwon15/9657129
I fixed it doesn't applied for item object.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah, I actually came across a similar issue using this previously. The problem actually stems from the core code of earthquake, in that the tweet body of a retweet is stored in a different variable to a regular tweet, which is quite annoying! I ended up (probably foolishly) making a modification to the core of earthquake to fix the issue for myself, but the modification I've made to the existing gist should skirt the issue (though you may still see t.co in retweets).