tweetlr 0.1.4pre2 → 0.1.4pre4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +36 -0
- data/README.md +4 -1
- data/lib/tweetlr.rb +18 -5
- data/spec/spec_helper.rb +118 -0
- data/spec/tweetlr_spec.rb +16 -4
- data/tweetlr.gemspec +7 -9
- metadata +30 -51
data/.travis.yml
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Passes arguments to bundle install (http://gembundler.com/man/bundle-install.1.html)
|
2
|
+
bundler_args: --binstubs
|
3
|
+
|
4
|
+
# Specify which ruby versions you wish to run your tests on, each version will be used
|
5
|
+
rvm:
|
6
|
+
- 1.9.2
|
7
|
+
- 1.8.7 # (current default)
|
8
|
+
|
9
|
+
# Define how to run your tests (defaults to `bundle exec rake` or `rake` depending on whether you have a `Gemfile`)
|
10
|
+
script: "bundle exec rake test"
|
11
|
+
|
12
|
+
# Define tasks to be completed before and after tests run . Will allow folding of content on frontend
|
13
|
+
# before_script:
|
14
|
+
# - command_1
|
15
|
+
# - command_2
|
16
|
+
#
|
17
|
+
# after_script:
|
18
|
+
# - command_1
|
19
|
+
# - command_2
|
20
|
+
|
21
|
+
# Specify an ENV variable to run before: 'bundle install' and 'rake' (or your defined 'script')
|
22
|
+
env: "RACK_ENV='test' "
|
23
|
+
|
24
|
+
# Specify the recipients for email notification
|
25
|
+
notifications:
|
26
|
+
recipients:
|
27
|
+
- github@svenkraeuter.com
|
28
|
+
#disabled: true # Disable email notifications
|
29
|
+
|
30
|
+
# Specify branches to build
|
31
|
+
# You can either specify only or except. If you specify both, except will be ignored.
|
32
|
+
branches:
|
33
|
+
only:
|
34
|
+
- master
|
35
|
+
# except:
|
36
|
+
# - legacy
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
tweetlr crawls twitter for a given term, extracts photos out of the collected tweets' short urls and posts the images to tumblr.
|
4
4
|
|
5
|
+
<a href="http://travis-ci.org/#!/5v3n/tweetlr"></a>
|
6
|
+
|
5
7
|
## Supported image sharing services
|
6
8
|
|
7
9
|
tweetlr supports
|
@@ -14,6 +16,7 @@ tweetlr supports
|
|
14
16
|
- lockerz / the service formerly known as plixi
|
15
17
|
- foursquare
|
16
18
|
- t.co shortened links to pictures
|
19
|
+
- every service accessible via embed.ly (see [photo providers](http://embed.ly/providers))
|
17
20
|
|
18
21
|
## Installation
|
19
22
|
|
@@ -34,7 +37,7 @@ tumblr_username: YOUR_TUMBLR_EMAIL
|
|
34
37
|
tumblr_password: YOUR_TUMBLR_PW
|
35
38
|
update_period: 300 #check for updates every 300 secs = 5 minutes
|
36
39
|
shouts: 'says' # will be concatenated after the username, before the message: @mr_x says: awesome things on a photo!
|
37
|
-
loglevel:
|
40
|
+
loglevel: 1 # 0: debug, 1: info (default), 2: warn, 3: error, 5: fatal
|
38
41
|
whitelist: #twitter accounts in that list will have their tweets published immediately. post from others will be saved as drafts
|
39
42
|
- whitey_mc_whitelist
|
40
43
|
- sven_kr
|
data/lib/tweetlr.rb
CHANGED
@@ -6,13 +6,13 @@ require 'json'
|
|
6
6
|
|
7
7
|
class Tweetlr
|
8
8
|
|
9
|
-
VERSION = '0.1.
|
9
|
+
VERSION = '0.1.4pre3'
|
10
10
|
GENERATOR = %{tweetlr - http://github.com/5v3n/tweetlr}
|
11
11
|
USER_AGENT = %{Mozilla/5.0 (compatible; tweetlr/#{VERSION}; +http://github.com/5v3n/tweetlr/wiki)}
|
12
12
|
LOCATION_START_INDICATOR = 'Location: '
|
13
13
|
LOCATION_STOP_INDICATOR = "\r\n"
|
14
14
|
|
15
|
-
def initialize(email, password, config_file, args={:cookie => nil, :since_id=>nil, :terms=>nil, :loglevel=>Logger::INFO})
|
15
|
+
def initialize(email, password, config_file, args={:cookie => nil, :since_id=>nil, :results_per_page => nil, :terms=>nil, :loglevel=>Logger::INFO})
|
16
16
|
@log = Logger.new(STDOUT)
|
17
17
|
@log.level = args[:loglevel] if (Logger::DEBUG..Logger::UNKNOWN).to_a.index(args[:loglevel])
|
18
18
|
@log.debug "log level set to #{@log.level}"
|
@@ -22,7 +22,7 @@ class Tweetlr
|
|
22
22
|
@since_id = args[:since_id]
|
23
23
|
@search_term = args[:terms]
|
24
24
|
@cookie = args[:cookie]
|
25
|
-
@results_per_page = config['results_per_page']
|
25
|
+
@results_per_page = args[:results_per_page] || config['results_per_page'] #TODO decide how to trade args vs config file
|
26
26
|
@result_type = config['result_type']
|
27
27
|
@api_endpoint_twitter = config['api_endpoint_twitter']
|
28
28
|
@api_endpoint_tumblr = config['api_endpoint_tumblr']
|
@@ -210,7 +210,19 @@ class Tweetlr
|
|
210
210
|
end
|
211
211
|
|
212
212
|
def link_url_redirect(short_url, stop_indicator = LOCATION_STOP_INDICATOR)
|
213
|
-
|
213
|
+
tries = 3
|
214
|
+
begin
|
215
|
+
resp = Curl::Easy.http_get(short_url) { |res| res.follow_location = true }
|
216
|
+
rescue => err
|
217
|
+
@log.error "Curl::Easy.http_get failed: #{err}"
|
218
|
+
tries -= 1
|
219
|
+
sleep 3
|
220
|
+
if tries > 0
|
221
|
+
retry
|
222
|
+
else
|
223
|
+
return nil
|
224
|
+
end
|
225
|
+
end
|
214
226
|
if(resp && resp.header_str.index(LOCATION_START_INDICATOR) && resp.header_str.index(stop_indicator))
|
215
227
|
start = resp.header_str.index(LOCATION_START_INDICATOR) + LOCATION_START_INDICATOR.size
|
216
228
|
stop = resp.header_str.index(stop_indicator, start)
|
@@ -253,7 +265,8 @@ class Tweetlr
|
|
253
265
|
@log.warn "#{err}: Could not parse response for #{request} - this is probably not a json response: #{curl.body_str}"
|
254
266
|
return nil
|
255
267
|
rescue Encoding::CompatibilityError => err
|
256
|
-
@log.error "Trying to rescue a JSON::ParserError for '#{
|
268
|
+
@log.error "Trying to rescue a JSON::ParserError for '#{request}' we got stuck in a Encoding::CompatibilityError."
|
269
|
+
return nil
|
257
270
|
end
|
258
271
|
end
|
259
272
|
rescue Curl::Err::ConnectionFailedError => err
|
data/spec/spec_helper.rb
CHANGED
@@ -1,2 +1,120 @@
|
|
1
|
+
#encoding: utf-8
|
1
2
|
require "bundler"
|
2
3
|
Bundler.require :default, :development
|
4
|
+
|
5
|
+
module Curl
|
6
|
+
class Easy
|
7
|
+
attr_accessor :body_str, :header_str
|
8
|
+
@@mocked_response = Curl::Easy.new
|
9
|
+
def perform
|
10
|
+
return @@mocked_response
|
11
|
+
end
|
12
|
+
def self.http_get(url)
|
13
|
+
return @@mocked_response
|
14
|
+
end
|
15
|
+
def self.mock_body_str=(str)
|
16
|
+
@@mock_body_str = str
|
17
|
+
end
|
18
|
+
def self.mock_header_str=(str)
|
19
|
+
@@mock_header_str = str
|
20
|
+
end
|
21
|
+
def body_str
|
22
|
+
@@mock_body_str
|
23
|
+
end
|
24
|
+
def header_str
|
25
|
+
@@mock_header_str
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def mock_reset
|
31
|
+
Curl::Easy.mock_body_str = nil
|
32
|
+
Curl::Easy.mock_header_str = nil
|
33
|
+
end
|
34
|
+
|
35
|
+
def mock_bad_request
|
36
|
+
Curl::Easy.mock_body_str = %|<html><title>400: Bad Request - Invalid URL format http://mopskopf</title><body>400: Bad Request - Invalid URL format http://mopskopf</body></html>|
|
37
|
+
end
|
38
|
+
|
39
|
+
def mock_utf8_response
|
40
|
+
Curl::Easy.mock_body_str = %|√∫ƒ® are inhabitnts of utf-8 wonderländ.|
|
41
|
+
end
|
42
|
+
|
43
|
+
def mock_twitter
|
44
|
+
Curl::Easy.mock_body_str = %|{"results":[{"from_user_id_str":"220650275","profile_image_url":"http://a2.twimg.com/profile_images/668619338/9729_148876458070_505518070_2628895_7160219_n_normal.jpg","created_at":"Sat, 16 Jul 2011 23:20:01 +0000","from_user":"LoMuma","id_str":"92372947855093760","metadata":{"result_type":"recent"},"to_user_id":null,"text":"Need to stop procrastinating! 5 quizzes and personal responses due tomorrow... #fail","id":92372947855093760,"from_user_id":220650275,"geo":null,"iso_language_code":"en","to_user_id_str":null,"source":"<a href="http://twitter.com/">web</a>"},{"from_user_id_str":"129718556","profile_image_url":"http://a2.twimg.com/profile_images/1428268221/twitter_normal.png","created_at":"Sat, 16 Jul 2011 23:20:01 +0000","from_user":"priiislopes","id_str":"92372947846692865","metadata":{"result_type":"recent"},"to_user_id":null,"text":"Esse jogo do Flu foi uma vergonha. Se ele fez o melhor dele no brasileiro semana passada, hj fez o pior de todos os tempos. #Fail","id":92372947846692865,"from_user_id":129718556,"geo":null,"iso_language_code":"pt","to_user_id_str":null,"source":"<a href="http://twitter.com/">web</a>"},{"from_user_id_str":"259930166","profile_image_url":"http://a3.twimg.com/profile_images/1425221519/foto_normal.jpg","created_at":"Sat, 16 Jul 2011 23:20:00 +0000","from_user":"YamiiG4","id_str":"92372943132303360","metadata":{"result_type":"recent"},"to_user_id":null,"text":"vaya que eran 2 minutos..#FAIL!","id":92372943132303360,"from_user_id":259930166,"geo":null,"iso_language_code":"es","to_user_id_str":null,"source":"<a href="http://www.tweetdeck.com" rel="nofollow">TweetDeck</a>"},{"from_user_id_str":"321557905","profile_image_url":"http://a0.twimg.com/profile_images/1445672626/profile_normal.png","created_at":"Sat, 16 Jul 2011 23:20:00 +0000","from_user":"JasWafer_FFOE","id_str":"92372941379088384","metadata":{"result_type":"recent"},"to_user_id":null,"text":"RT @eye_OFBEHOLDER: RT @JasWafer_FFOE #Oomf said that he'll NEVER eat pussy! O.o --#FAIL","id":92372941379088384,"from_user_id":321557905,"geo":null,"iso_language_code":"en","to_user_id_str":null,"source":"<a href="http://twidroyd.com" rel="nofollow">Twidroyd for Android</a>"},{"from_user_id_str":"279395613","profile_image_url":"http://a0.twimg.com/profile_images/1334871419/lnnsquare_normal.jpg","created_at":"Sat, 16 Jul 2011 23:19:59 +0000","from_user":"LanguageNewsNet","id_str":"92372940640890881","metadata":{"result_type":"recent"},"to_user_id":null,"text":"Questioning the Inca Paradox: Did the civilization behind Machu Picchu really fail to develop a written la... http://tinyurl.com/5sfos23","id":92372940640890881,"from_user_id":279395613,"geo":null,"iso_language_code":"en","to_user_id_str":null,"source":"<a href="http://twitterfeed.com" rel="nofollow">twitterfeed</a>"}],"max_id":92372947855093760,"since_id":0,"refresh_url":"?since_id=92372947855093760&q=+fail","next_page":"?page=2&max_id=92372947855093760&rpp=5&q=+fail","results_per_page":5,"page":1,"completed_in":0.022152,"since_id_str":"0","max_id_str":"92372947855093760","query":"+fail"}|
|
45
|
+
end
|
46
|
+
|
47
|
+
def mock_instagram
|
48
|
+
Curl::Easy.mock_body_str = %|{"provider_url": "http://instagram.com/", "title": "Curse you tweets. See what you have done to me?!!!", "url": "http://distillery.s3.amazonaws.com/media/2011/05/02/d25df62b9cec4a138967a3ad027d055b_7.jpg", "author_name": "loswhit", "height": 612, "width": 612, "version": "1.0", "author_url": "http://instagram.com/", "provider_name": "Instagram", "type": "photo"}|
|
49
|
+
end
|
50
|
+
|
51
|
+
def mock_yfrog
|
52
|
+
Curl::Easy.mock_body_str = %|{"version":"1.0","provider_name":"yFrog","provider_url":"http:\/\/yfrog.com","thumbnail_url":"http:\/\/yfrog.com\/h4vlfp:small","width":1210,"height":894,"type":"image","url":"http:\/\/img616.yfrog.com\/img616\/16\/vlf.png"}|
|
53
|
+
end
|
54
|
+
|
55
|
+
def mock_picplz
|
56
|
+
Curl::Easy.mock_body_str = %|{"result":"ok","value":{"pics":[{"city":{"url":"/city/los-angeles-ca/","id":27,"name":"Los Angeles, CA"},"creator":{"username":"lakers","display_name":"Los Angeles Lakers","following_count":8,"follower_count":2364,"id":216541,"icon":{"url":"http://s1.ui1.picplzthumbs.com/usericons/c7/46/be/c746bee5eb6926e71f46176fddbd3fc16fc9b198_meds.jpg","width":75,"height":75}},"url":"/user/lakers/pic/6rlcc/","pic_files":{"640r":{"width":640,"img_url":"http://s1.i1.picplzthumbs.com/upload/img/7c/54/a0/7c54a0a10d3e97bef7ac570e14f461b1836e9168_wmeg.jpg","height":478},"100sh":{"width":100,"img_url":"http://s1.i1.picplzthumbs.com/upload/img/7c/54/a0/7c54a0a10d3e97bef7ac570e14f461b1836e9168_t200s.jpg","height":100},"320rh":{"width":320,"img_url":"http://s1.i1.picplzthumbs.com/upload/img/7c/54/a0/7c54a0a10d3e97bef7ac570e14f461b1836e9168_mmed.jpg","height":239}},"view_count":10873,"caption":"The playoff logo down on the floor.","comment_count":2,"like_count":24,"place":{"url":"/pics/staples-center-los-angeles-ca/","id":17357,"name":"STAPLES Center"},"date":1303059128,"id":1662796}]}}|
|
57
|
+
end
|
58
|
+
|
59
|
+
def mock_lockerz
|
60
|
+
Curl::Easy.mock_body_str = %|{"BigImageUrl":"http:\/\/c0013763.cdn1.cloudfiles.rackspacecloud.com\/x2_5f9fc67","CommentCount":1,"DetailsUrl":"http:\/\/api.plixi.com\/api\/tpapi.svc\/json\/photos\/100269159","GdAlias":"100269159","Id":100269159,"LargeImageUrl":"http:\/\/c0013763.cdn1.cloudfiles.rackspacecloud.com\/x2_5f9fc67","LikedVotes":0,"Location":{"Latitude":0,"Longitude":0},"MediumImageUrl":"http:\/\/c0013764.cdn1.cloudfiles.rackspacecloud.com\/x2_5f9fc67","Message":"Her name is Tofoi Al Nasr , she Reps the future of Qatar. @ the Doha Forum, technology is the new Revolution! ","MobileImageUrl":"http:\/\/c0013765.cdn1.cloudfiles.rackspacecloud.com\/x2_5f9fc67","Name":"x2_5f9fc67","SmallImageUrl":"http:\/\/c0013766.cdn1.cloudfiles.rackspacecloud.com\/x2_5f9fc67","ThumbnailUrl":"http:\/\/c0013767.cdn1.cloudfiles.rackspacecloud.com\/x2_5f9fc67","TinyAlias":"100269159","TwitterStatusId":67672440125394944,"UnLikedVotes":0,"UploadDate":1304969336,"UploadDateString":"2011-05-09T19:28:56Z","UserId":1067006,"Views":9319,"Vote":null}|
|
61
|
+
end
|
62
|
+
|
63
|
+
#follow redirect lookups
|
64
|
+
|
65
|
+
def mock_imgly
|
66
|
+
Curl::Easy.mock_header_str = %|HTTP/1.1 302 Found
|
67
|
+
Content-Type: text/html; charset=utf-8
|
68
|
+
Connection: keep-alive
|
69
|
+
Status: 302
|
70
|
+
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.7
|
71
|
+
Location: http://s3.amazonaws.com/imgly_production/899582/full.jpg\r\nX-Runtime: 5
|
72
|
+
Content-Length: 122
|
73
|
+
Set-Cookie: _imgly_session=BAh7BjoPc2Vzc2lvbl9pZCIlZTk3ZDI2ZmNhNWJjNGVjOTVjNDdiNThjOWFkYjliNTY%3D--83345d9317715d664bcb5de63b0529488a17a351; domain=.img.ly; path=/; expires=Sun, 31-Jul-2011 00:59:06 GMT; HttpOnly
|
74
|
+
Cache-Control: no-cache
|
75
|
+
Server: nginx/1.0.0 + Phusion Passenger 3.0.7 (mod_rails/mod_rack)
|
76
|
+
|
77
|
+
|
|
78
|
+
end
|
79
|
+
|
80
|
+
def mock_twitpic
|
81
|
+
Curl::Easy.mock_header_str = %|HTTP/1.1 302 Moved Temporarily
|
82
|
+
Server: nginx
|
83
|
+
Date: Sun, 17 Jul 2011 01:03:43 GMT
|
84
|
+
Content-Type: image/jpeg
|
85
|
+
Transfer-Encoding: chunked
|
86
|
+
Connection: keep-alive
|
87
|
+
X-Powered-By: PHP/5.3.5-1ubuntu7.2
|
88
|
+
Last-Modified: Sat, 16 Jul 2011 22:17:03 GMT
|
89
|
+
Etag: 0fe3c085839afa6e42ce28973192704a
|
90
|
+
Cache-Control: maxage=10000
|
91
|
+
Expires: Sun, 17 Jul 2011 03:50:23 GMT
|
92
|
+
Pragma: public
|
93
|
+
Location: http://s3.amazonaws.com/twitpic/photos/full/249034281.jpg?AWSAccessKeyId=AKIAJF3XCCKACR3QDMOA&Expires=1310865623&Signature=KNFdFAK%2Bu0u3maMaguUjsm2MbaM%3D\r\n
|
94
|
+
|
|
95
|
+
end
|
96
|
+
|
97
|
+
def mock_tco
|
98
|
+
Curl::Easy.mock_header_str = %|HTTP/1.1 301 Moved Permanently
|
99
|
+
Date: Sun, 17 Jul 2011 01:03:51 GMT
|
100
|
+
Server: hi
|
101
|
+
Location: http://yfrog.com/h0m3vpj
|
102
|
+
Cache-Control: private,max-age=300
|
103
|
+
Expires: Sun, 17 Jul 2011 01:08:51 GMT
|
104
|
+
Content-Length: 0
|
105
|
+
Connection: close
|
106
|
+
Content-Type: text/html; charset=UTF-8
|
107
|
+
|
108
|
+
|
|
109
|
+
mock_yfrog
|
110
|
+
end
|
111
|
+
|
112
|
+
#embedly powered lookups
|
113
|
+
|
114
|
+
def mock_foursquare
|
115
|
+
Curl::Easy.mock_body_str = %|{"provider_url": "http://foursquare.com", "description": "See where your friends are, learn about the places they frequent, and unlock rewards as you travel. 8555 Fletcher PkwyLa Mesa, CA 91942(619) 589-0071", "title": "Matt S. checked in at Banbu Sushi Bar And Grill", "url": "https://playfoursquare.s3.amazonaws.com/pix/PNIBDBIPP5G2XGROCZXVCOHABOZP4MICHZVPJWZXZWAN3SEQ.jpg", "author_name": "Matt S.", "height": 345, "width": 460, "thumbnail_url": "https://playfoursquare.s3.amazonaws.com/pix/PNIBDBIPP5G2XGROCZXVCOHABOZP4MICHZVPJWZXZWAN3SEQ.jpg", "thumbnail_width": 460, "version": "1.0", "provider_name": "Foursquare", "type": "photo", "thumbnail_height": 345, "author_url": "https://foursquare.com/mjstraus"}|
|
116
|
+
end
|
117
|
+
|
118
|
+
def mock_embedly
|
119
|
+
Curl::Easy.mock_body_str = %|{"provider_url": "http://www.flickr.com/", "description": "Lady GaGa", "title": "Lady GaGa", "url": "http://farm6.static.flickr.com/5204/5319200155_c966f67dc3.jpg", "author_name": "mjcom18", "height": 468, "width": 307, "thumbnail_url": "http://farm6.static.flickr.com/5204/5319200155_c966f67dc3_t.jpg", "thumbnail_width": 66, "version": "1.0", "provider_name": "Flickr", "cache_age": 3600, "type": "photo", "thumbnail_height": 100, "author_url": "http://www.flickr.com/photos/57795463@N05/"}|
|
120
|
+
end
|
data/spec/tweetlr_spec.rb
CHANGED
@@ -25,11 +25,12 @@ describe Tweetlr do
|
|
25
25
|
:tco => 'http://t.co/MUGNayA',
|
26
26
|
:lockerz => 'http://lockerz.com/s/100269159',
|
27
27
|
:foursquare => 'http://4sq.com/mLKDdF',
|
28
|
-
:embedly => 'http://flic.kr/p/973hTv'
|
28
|
+
:embedly => 'http://flic.kr/p/973hTv'
|
29
29
|
}
|
30
30
|
@pic_regexp = /(.*?)\.(jpg|jpeg|png|gif)$/i
|
31
31
|
@config_file = File.join( Dir.pwd, 'config', 'tweetlr.yml')
|
32
|
-
@tweetlr = Tweetlr.new(USER, PW, @config_file, {:since_id => TIMESTAMP, :terms => @searchterm, :loglevel => 4, :cookie => @cookie})
|
32
|
+
@tweetlr = Tweetlr.new(USER, PW, @config_file, {:results_per_page => 5, :since_id => TIMESTAMP, :terms => @searchterm, :loglevel => 4, :cookie => @cookie})
|
33
|
+
mock_reset
|
33
34
|
end
|
34
35
|
# it "should post to tumblr" do
|
35
36
|
# tweetlr = Tweetlr.new @credentials[:email], @credentials[:password], @cookie, nil, @searchterm, @config_file
|
@@ -40,6 +41,7 @@ describe Tweetlr do
|
|
40
41
|
# response.response_code.should be 201
|
41
42
|
# end
|
42
43
|
it "should search twitter for a given term" do
|
44
|
+
mock_twitter
|
43
45
|
tweetlr = @tweetlr
|
44
46
|
response = tweetlr.search_twitter
|
45
47
|
tweets = response['results']
|
@@ -47,10 +49,12 @@ describe Tweetlr do
|
|
47
49
|
tweets.should_not be_empty
|
48
50
|
end
|
49
51
|
it "should mark whitelist users' tweets as published" do
|
52
|
+
mock_instagram
|
50
53
|
post = @tweetlr.generate_tumblr_photo_post @twitter_response
|
51
54
|
post[:state].should == 'published'
|
52
55
|
end
|
53
56
|
it "should mark non whitelist users' tweets as drafts" do
|
57
|
+
mock_instagram
|
54
58
|
post = @tweetlr.generate_tumblr_photo_post @non_whitelist_tweet
|
55
59
|
post[:state].should == 'draft'
|
56
60
|
end
|
@@ -65,15 +69,18 @@ describe Tweetlr do
|
|
65
69
|
describe "image url processing" do
|
66
70
|
it "should find a picture's url from the supported services" do
|
67
71
|
@links.each do |key,value|
|
72
|
+
send "mock_#{key}"
|
68
73
|
url = @tweetlr.find_image_url value
|
69
74
|
url.should be, "service #{key} not working!"
|
70
|
-
check_pic_url_extraction key if [:instagram,:picplz,:yfrog,:
|
75
|
+
check_pic_url_extraction key if [:instagram,:picplz,:yfrog,:imgly,:foursquare,:not_listed].index key
|
71
76
|
end
|
72
77
|
end
|
73
78
|
it "should not crash if embedly fallback won't find a link" do
|
79
|
+
mock_bad_request
|
74
80
|
url = @tweetlr.find_image_url "http://mopskopf"
|
75
81
|
end
|
76
|
-
it "should not crash with an encoding error when
|
82
|
+
it "should not crash with an encoding error when response is non-us-ascii" do
|
83
|
+
mock_utf8_response
|
77
84
|
url = @tweetlr.find_image_url "http://api.instagram.com/oembed?url=http://instagr.am/p/Gx%E2%80%946/"
|
78
85
|
end
|
79
86
|
end
|
@@ -84,6 +91,11 @@ describe Tweetlr do
|
|
84
91
|
link.should == @links[:instagram]
|
85
92
|
link = tweetlr.extract_link @twitter_response.merge 'text' => @links[:instagram].chop #check if it works w/o the trailing slash
|
86
93
|
link.should == @links[:instagram].chop
|
94
|
+
end
|
95
|
+
it "follows redirects" do
|
96
|
+
mock_imgly
|
97
|
+
link = @tweetlr.link_url_redirect 'im mocked anyways'
|
98
|
+
link.should == 'http://s3.amazonaws.com/imgly_production/899582/full.jpg'
|
87
99
|
end
|
88
100
|
end
|
89
101
|
|
data/tweetlr.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "tweetlr"
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.4pre4"
|
4
4
|
s.author = "Sven Kraeuter"
|
5
5
|
s.email = "mail@svenkraeuter.com"
|
6
6
|
s.homepage = "http://github.com/5v3n/#{s.name}"
|
@@ -10,15 +10,13 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.rubyforge_project = s.name
|
11
11
|
s.extra_rdoc_files = %w(README.md LICENSE)
|
12
12
|
|
13
|
-
s.add_dependency "daemons"
|
14
|
-
s.add_dependency "eventmachine"
|
15
|
-
s.add_dependency "curb"
|
16
|
-
s.add_dependency "json"
|
13
|
+
s.add_dependency "daemons"
|
14
|
+
s.add_dependency "eventmachine"
|
15
|
+
s.add_dependency "curb"
|
16
|
+
s.add_dependency "json"
|
17
17
|
|
18
|
-
s.add_development_dependency "
|
19
|
-
s.add_development_dependency "
|
20
|
-
s.add_development_dependency "autotest-growl", "~> 0.2.9"
|
21
|
-
s.add_development_dependency "autotest-fsevent", "~> 0.2.5"
|
18
|
+
s.add_development_dependency "rake", "~> 0.8.7"
|
19
|
+
s.add_development_dependency "rspec"
|
22
20
|
s.add_development_dependency "rdoc"
|
23
21
|
|
24
22
|
s.files = `git ls-files`.split("\n")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tweetlr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4pre4
|
5
5
|
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,100 +9,78 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-08-18 00:00:00.000000000 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: daemons
|
17
|
-
requirement: &
|
17
|
+
requirement: &2157352460 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
|
-
- -
|
20
|
+
- - ! '>='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2157352460
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: eventmachine
|
28
|
-
requirement: &
|
28
|
+
requirement: &2157352040 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2157352040
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: curb
|
39
|
-
requirement: &
|
39
|
+
requirement: &2157351620 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
|
-
- -
|
42
|
+
- - ! '>='
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: 0
|
44
|
+
version: '0'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2157351620
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: json
|
50
|
-
requirement: &
|
50
|
+
requirement: &2157351200 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ! '>='
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
55
|
+
version: '0'
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *2157351200
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
|
-
name:
|
61
|
-
requirement: &
|
60
|
+
name: rake
|
61
|
+
requirement: &2157350700 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ~>
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version:
|
66
|
+
version: 0.8.7
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *2157350700
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
72
|
-
requirement: &
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: 4.4.6
|
78
|
-
type: :development
|
79
|
-
prerelease: false
|
80
|
-
version_requirements: *2153674160
|
81
|
-
- !ruby/object:Gem::Dependency
|
82
|
-
name: autotest-growl
|
83
|
-
requirement: &2153673700 !ruby/object:Gem::Requirement
|
84
|
-
none: false
|
85
|
-
requirements:
|
86
|
-
- - ~>
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: 0.2.9
|
89
|
-
type: :development
|
90
|
-
prerelease: false
|
91
|
-
version_requirements: *2153673700
|
92
|
-
- !ruby/object:Gem::Dependency
|
93
|
-
name: autotest-fsevent
|
94
|
-
requirement: &2153673240 !ruby/object:Gem::Requirement
|
71
|
+
name: rspec
|
72
|
+
requirement: &2157350280 !ruby/object:Gem::Requirement
|
95
73
|
none: false
|
96
74
|
requirements:
|
97
|
-
- -
|
75
|
+
- - ! '>='
|
98
76
|
- !ruby/object:Gem::Version
|
99
|
-
version: 0
|
77
|
+
version: '0'
|
100
78
|
type: :development
|
101
79
|
prerelease: false
|
102
|
-
version_requirements: *
|
80
|
+
version_requirements: *2157350280
|
103
81
|
- !ruby/object:Gem::Dependency
|
104
82
|
name: rdoc
|
105
|
-
requirement: &
|
83
|
+
requirement: &2157349820 !ruby/object:Gem::Requirement
|
106
84
|
none: false
|
107
85
|
requirements:
|
108
86
|
- - ! '>='
|
@@ -110,7 +88,7 @@ dependencies:
|
|
110
88
|
version: '0'
|
111
89
|
type: :development
|
112
90
|
prerelease: false
|
113
|
-
version_requirements: *
|
91
|
+
version_requirements: *2157349820
|
114
92
|
description: tweetlr crawls twitter for a given term, extracts photos out of the collected
|
115
93
|
tweets' short urls and posts the images to tumblr.
|
116
94
|
email: mail@svenkraeuter.com
|
@@ -124,6 +102,7 @@ files:
|
|
124
102
|
- .autotest
|
125
103
|
- .gitignore
|
126
104
|
- .rspec
|
105
|
+
- .travis.yml
|
127
106
|
- Gemfile
|
128
107
|
- LICENSE
|
129
108
|
- README.md
|