tweetlr 0.1.22 → 0.1.23
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/README.md +4 -1
- data/lib/tweetlr/combinators/twitter_tumblr.rb +25 -19
- data/lib/tweetlr/processors/photo_service.rb +16 -11
- data/lib/tweetlr.rb +1 -1
- data/spec/processors/photo_services_processor_spec.rb +12 -6
- data/spec/spec_helper.rb +13 -2
- data/tweetlr.gemspec +2 -1
- metadata +18 -2
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# tweetlr
|
2
2
|
|
3
|
-
<a href="http://travis-ci.org/#!/5v3n/tweetlr"></a> 
|
3
|
+
<a href="http://travis-ci.org/#!/5v3n/tweetlr"></a>
|
4
|
+
<a href="https://codeclimate.com/github/5v3n/tweetlr"><img src="https://codeclimate.com/github/5v3n/tweetlr.png" /></a>
|
5
|
+
<a href='https://coveralls.io/r/5v3n/tweetlr'><img src='https://coveralls.io/repos/5v3n/tweetlr/badge.png?branch=master' alt='Coverage Status' /></a>
|
6
|
+
|
4
7
|
|
5
8
|
|
6
9
|
|
@@ -25,30 +25,36 @@ module Tweetlr::Combinators
|
|
25
25
|
#generate the data for a tumblr photo entry by parsing a tweet
|
26
26
|
def self.generate_photo_post_from_tweet(tweet, options = {})
|
27
27
|
log.debug "#{self}.generate_photo_post_from_tweet with options: #{options.inspect}"
|
28
|
-
|
28
|
+
process_options_and_tweet options, tweet
|
29
|
+
end
|
30
|
+
private
|
31
|
+
def self.process_options_and_tweet(options, tweet)
|
29
32
|
whitelist = options[:whitelist]
|
30
33
|
whitelist.each {|entry| entry.downcase!} if (whitelist && whitelist.size != 0)
|
31
34
|
if !Tweetlr::Processors::Twitter::retweet? tweet['text']
|
32
35
|
log.debug "tweet: #{tweet}"
|
33
|
-
tumblr_post =
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
#TODO make the caption a bigger matter of yml/ general configuration
|
36
|
+
tumblr_post = prepare_tumblr_post options, tweet, whitelist
|
37
|
+
end
|
38
|
+
end
|
39
|
+
def self.prepare_tumblr_post(options, tweet, whitelist)
|
40
|
+
tumblr_post = {}
|
41
|
+
tumblr_post[:tumblr_blog_hostname] = options[:tumblr_blog_hostname] || options[:group]
|
42
|
+
tumblr_post[:type] = 'photo'
|
43
|
+
tumblr_post[:date] = tweet['created_at']
|
44
|
+
tumblr_post[:source] = extract_image_url tweet, options[:embedly_key]
|
45
|
+
user = tweet['from_user']
|
46
|
+
tumblr_post[:tags] = user
|
47
|
+
tweet_id = tweet['id']
|
48
|
+
if !whitelist || whitelist.size == 0 || whitelist.member?(user.downcase)
|
49
|
+
state = 'published'
|
50
|
+
else
|
51
|
+
state = 'draft'
|
50
52
|
end
|
51
|
-
tumblr_post
|
53
|
+
tumblr_post[:state] = state
|
54
|
+
shouts = " #{@shouts}" if @shouts
|
55
|
+
tumblr_post[:caption] = %?<a href="http://twitter.com/#{user}/statuses/#{tweet_id}" alt="tweet">@#{user}</a>#{shouts}: #{tweet['text']}?
|
56
|
+
#TODO make the caption a bigger matter of yml/ general configuration
|
57
|
+
tumblr_post
|
52
58
|
end
|
53
59
|
end
|
54
60
|
end
|
@@ -20,16 +20,7 @@ module Tweetlr::Processors
|
|
20
20
|
def self.find_image_url(link, embedly_key=nil)
|
21
21
|
url = nil
|
22
22
|
if link && !(photo? link)
|
23
|
-
url =
|
24
|
-
url = image_url_instagram link if (link.index('instagr.am') || link.index('instagram.com'))
|
25
|
-
url = image_url_twitpic link if link.index 'twitpic'
|
26
|
-
url = image_url_yfrog link if link.index 'yfrog'
|
27
|
-
url = image_url_imgly link, embedly_key if link.index 'img.ly'
|
28
|
-
url = image_url_tco link, embedly_key if link.index 't.co'
|
29
|
-
url = image_url_twimg link if link.index 'twitter.com'
|
30
|
-
url = image_url_path link if link.index 'path.com'
|
31
|
-
url = image_url_foursqaure link if (link.index('4sq.com') || link.index('foursquare.com'))
|
32
|
-
url = image_url_embedly link, embedly_key if url.nil? #just try embed.ly for anything else. could do all image url processing w/ embedly, but there's probably some kind of rate limit invovled.
|
23
|
+
url = process_link link, embedly_key
|
33
24
|
elsif photo? link
|
34
25
|
url = link
|
35
26
|
end
|
@@ -50,7 +41,7 @@ module Tweetlr::Processors
|
|
50
41
|
def self.image_url_foursqaure(link_url)
|
51
42
|
link_url = follow_redirect(link_url)
|
52
43
|
image_url = retrieve_image_url_by_css link_url, 'meta[property="og:image"]', 'content'
|
53
|
-
image_url
|
44
|
+
image_url unless image_url.include? "foursquare.com/img/categories"
|
54
45
|
end
|
55
46
|
#extract the image of a path.com pic
|
56
47
|
def self.image_url_path(link_url)
|
@@ -131,6 +122,20 @@ module Tweetlr::Processors
|
|
131
122
|
return image_url
|
132
123
|
end
|
133
124
|
private
|
125
|
+
def self.process_link(link, embedly_key)
|
126
|
+
url = nil
|
127
|
+
url = image_url_eyeem link if link.index 'eyeem.com'
|
128
|
+
url = image_url_instagram link if (link.index('instagr.am') || link.index('instagram.com'))
|
129
|
+
url = image_url_twitpic link if link.index 'twitpic'
|
130
|
+
url = image_url_yfrog link if link.index 'yfrog'
|
131
|
+
url = image_url_imgly link, embedly_key if link.index 'img.ly'
|
132
|
+
url = image_url_tco link, embedly_key if link.index 't.co'
|
133
|
+
url = image_url_twimg link if link.index 'twitter.com'
|
134
|
+
url = image_url_path link if link.index 'path.com'
|
135
|
+
url = image_url_foursqaure link if (link.index('4sq.com') || link.index('foursquare.com'))
|
136
|
+
url = image_url_embedly link, embedly_key if url.nil? #just try embed.ly for anything else. could do all image url processing w/ embedly, but there's probably some kind of rate limit invovled.
|
137
|
+
url
|
138
|
+
end
|
134
139
|
def self.process_reponse_header(resp, stop_indicator)
|
135
140
|
if(resp && resp.header_str && resp.header_str.index(LOCATION_START_INDICATOR) && resp.header_str.index(stop_indicator))
|
136
141
|
start = resp.header_str.index(LOCATION_START_INDICATOR) + LOCATION_START_INDICATOR.size
|
data/lib/tweetlr.rb
CHANGED
@@ -19,7 +19,6 @@ describe Tweetlr::Processors::PhotoService do
|
|
19
19
|
it "finds a picture's url from the supported services" do
|
20
20
|
@links.each do |service,link|
|
21
21
|
send "stub_#{service}"
|
22
|
-
#puts "checking #{service}"
|
23
22
|
url = Tweetlr::Processors::PhotoService::find_image_url link
|
24
23
|
url.should be, "service #{service} not working!"
|
25
24
|
check_pic_url_extraction service if [:twimg, :instagram,:yfrog,:imgly,:foursqaure,:not_listed].index service
|
@@ -36,11 +35,18 @@ describe Tweetlr::Processors::PhotoService do
|
|
36
35
|
link = Tweetlr::Processors::PhotoService::find_image_url 'http://makersand.co/'
|
37
36
|
link.should be_nil
|
38
37
|
end
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
38
|
+
describe "for foursqaure" do
|
39
|
+
it "does find an image that is not he profile pic" do
|
40
|
+
stub_foursquare
|
41
|
+
link = Tweetlr::Processors::PhotoService::find_image_url @links[:foursquare]
|
42
|
+
link.should be
|
43
|
+
link.index('userpix_thumbs').should_not be
|
44
|
+
end
|
45
|
+
it "does not extract symbols from tweeted links that contain no images" do
|
46
|
+
stub_foursquare_no_photo
|
47
|
+
link = Tweetlr::Processors::PhotoService::find_image_url @links[:foursquare]
|
48
|
+
link.should_not be
|
49
|
+
end
|
44
50
|
end
|
45
51
|
it "finds path images for redirected moments as well" do
|
46
52
|
stub_path_redirected
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
#encoding: utf-8
|
2
|
-
|
3
|
-
|
2
|
+
|
3
|
+
if ENV['RACK_ENV']=='test'
|
4
|
+
require 'coveralls'
|
5
|
+
Coveralls.wear!
|
6
|
+
elsif ENV['RACK_ENV']=='development'
|
7
|
+
require 'simplecov'
|
8
|
+
SimpleCov.start
|
9
|
+
end
|
4
10
|
|
5
11
|
require "bundler"
|
6
12
|
require "logger"
|
@@ -514,6 +520,11 @@ def stub_foursquare
|
|
514
520
|
^
|
515
521
|
end
|
516
522
|
|
523
|
+
def stub_foursquare_no_photo
|
524
|
+
Curl::Easy.any_instance.stub(:perform).and_return Curl::Easy.new
|
525
|
+
Curl::Easy.any_instance.stub(:body_str).and_return %^<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><meta name="application-name" content="Foursquare"/><meta name="msapplication-TileColor" content="#0ca9c9"/><meta name="msapplication-TileImage" content="https://playfoursquare.s3.amazonaws.com/misc/foursquare-144-logo.png"/><meta name="msapplication-tooltip" content="Start the foursquare App" /><meta name="msapplication-starturl" content="/" /><meta name="msapplication-window" content="width=1024;height=768" /><meta name="msapplication-task" content="name=Recent Check-ins; action-uri=/; icon-uri=/favicon.ico" /><meta name="msapplication-task" content="name=Profile;action-uri=/user;icon-uri=/favicon.ico" /><meta name="msapplication-task" content="name=History;action-uri=/user/history;icon-uri=/favicon.ico" /><meta name="msapplication-task" content="name=Badges;action-uri=/user/badges;icon-uri=/favicon.ico" /><meta name="msapplication-task" content="name=Stats;action-uri=/user/stats;icon-uri=/favicon.ico" /><link rel="icon" href="/favicon.ico" type="image/x-icon"/><link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/><link rel="apple-touch-icon-precomposed" sizes="72x72" href="/img/touch-icon-ipad.png" /><link rel="apple-touch-icon-precomposed" sizes="144x144" href="/img/touch-icon-ipad-retina.png" /><link rel="logo" href="https://playfoursquare.s3.amazonaws.com/press/logo/foursquare-logo.svg" type="image/svg" /><link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="foursquare" /><title>Sven @ Le Lion</title><meta content="de" http-equiv="Content-Language" /><meta content="https://foursquare.com/sven_kr/checkin/5180436ae4b098ea8af76e3a?ref=fb&source=openGraph&s=9aAHdtIEpzZ-t1yziwX8ASs_81c" property="og:url" /><meta content="Ein Check-in bei Le Lion" property="og:title" /><meta content="Ein Check-in" property="og:description" /><meta content="playfoursquare:checkin" property="og:type" /><meta content="https://foursquare.com/img/categories_map/nightlife/cocktails.png" property="og:image" /><meta content="2013-04-30T22:19:22.000Z" property="playfoursquare:date" /><meta content="https://foursquare.com/v/le-lion/4b0f0baaf964a520895e23e3" property="playfoursquare:place" /><meta content="Foursquare" property="og:site_name" /><meta content="86734274142" property="fb:app_id" /><meta content="@foursquare" name="twitter:site" /><meta content="summary" name="twitter:card" /><meta content="Foursquare" name="twitter:app:name:iphone" /><meta content="Foursquare" name="twitter:app:name:ipad" /><meta content="Foursquare" name="twitter:app:name:googleplay" /><meta content="foursquare://checkins/5180436ae4b098ea8af76e3a?s=9aAHdtIEpzZ-t1yziwX8ASs_81c" name="twitter:app:url:iphone" /><meta content="foursquare://checkins/5180436ae4b098ea8af76e3a?s=9aAHdtIEpzZ-t1yziwX8ASs_81c" name="twitter:app:url:ipad" /><meta content="foursquare://checkins/5180436ae4b098ea8af76e3a?s=9aAHdtIEpzZ-t1yziwX8ASs_81c" name="twitter:app:url:googleplay" /><meta content="306934924" name="twitter:app:id:iphone" /><meta content="306934924" name="twitter:app:id:ipad" /><meta content="com.joelapenna.foursquared" name="twitter:app:id:googleplay" /><link href="https://ss1.4sqi.net/styles/third_party/hfjfonts-5a7f8781ee1be1bb12433f1d74f0948c.css" type="text/css" rel="stylesheet"/><link href="https://ss1.4sqi.net/styles/master-d343426b4dbbd81a7e427d6f8c032b5a.css" type="text/css" rel="stylesheet"/><link href="https://ss0.4sqi.net/styles/standalone-pages/checkin-detail-1aabc265046d80b7c1e392c47dd3f8c9.css" type="text/css" rel="stylesheet"/><link rel="alternate" href="https://it.foursquare.com/sven_kr/checkin/5180436ae4b098ea8af76e3a?s=9aAHdtIEpzZ-t1yziwX8ASs_81c&ref=tw" hreflang="it"/><link rel="alternate" href="https://de.foursquare.com/sven_kr/checkin/5180436ae4b098ea8af76e3a?s=9aAHdtIEpzZ-t1yziwX8ASs_81c&ref=tw" hreflang="de"/><link rel="alternate" href="https://es.foursquare.com/sven_kr/checkin/5180436ae4b098ea8af76e3a?s=9aAHdtIEpzZ-t1yziwX8ASs_81c&ref=tw" hreflang="es"/><link rel="alternate" href="https://fr.foursquare.com/sven_kr/checkin/5180436ae4b098ea8af76e3a?s=9aAHdtIEpzZ-t1yziwX8ASs_81c&ref=tw" hreflang="fr"/><link rel="alternate" href="https://ja.foursquare.com/sven_kr/checkin/5180436ae4b098ea8af76e3a?s=9aAHdtIEpzZ-t1yziwX8ASs_81c&ref=tw" hreflang="ja"/><link rel="alternate" href="https://th.foursquare.com/sven_kr/checkin/5180436ae4b098ea8af76e3a?s=9aAHdtIEpzZ-t1yziwX8ASs_81c&ref=tw" hreflang="th"/><link rel="alternate" href="https://ko.foursquare.com/sven_kr/checkin/5180436ae4b098ea8af76e3a?s=9aAHdtIEpzZ-t1yziwX8ASs_81c&ref=tw" hreflang="ko"/><link rel="alternate" href="https://ru.foursquare.com/sven_kr/checkin/5180436ae4b098ea8af76e3a?s=9aAHdtIEpzZ-t1yziwX8ASs_81c&ref=tw" hreflang="ru"/><link rel="alternate" href="https://pt.foursquare.com/sven_kr/checkin/5180436ae4b098ea8af76e3a?s=9aAHdtIEpzZ-t1yziwX8ASs_81c&ref=tw" hreflang="pt"/><link rel="alternate" href="https://id.foursquare.com/sven_kr/checkin/5180436ae4b098ea8af76e3a?s=9aAHdtIEpzZ-t1yziwX8ASs_81c&ref=tw" hreflang="id"/><link rel="alternate" href="https://tr.foursquare.com/sven_kr/checkin/5180436ae4b098ea8af76e3a?s=9aAHdtIEpzZ-t1yziwX8ASs_81c&ref=tw" hreflang="tr"/>^
|
526
|
+
end
|
527
|
+
|
517
528
|
def stub_eyeem
|
518
529
|
Curl::Easy.any_instance.stub(:perform).and_return Curl::Easy.new
|
519
530
|
Curl::Easy.any_instance.stub(:header_str).and_return "HTTP/1.1 200 OK\r\nServer: nginx/1.0.5\r\nDate: Sun, 15 Apr 2012 09:16:58 GMT\r\nContent-Type: text/html; charset=utf-8\r\nTransfer-Encoding: chunked\r\nConnection: keep-alive\r\nX-Powered-By: PHP/5.3.6-13ubuntu3.6\r\nSet-Cookie: symfony=bv8mdicp6ucb8jr9qt0o0r7qk2; path=/\r\nExpires: Thu, 19 Nov 1981 08:52:00 GMT\r\nCache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\nPragma: no-cache\r\n\r\n"
|
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.23"
|
4
4
|
s.author = "Sven Kraeuter"
|
5
5
|
s.email = "sven.kraeuter@gmail.com"
|
6
6
|
s.homepage = "http://tweetlr.5v3n.com"
|
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_development_dependency "rspec"
|
22
22
|
s.add_development_dependency "rdoc"
|
23
23
|
s.add_development_dependency "simplecov"
|
24
|
+
s.add_development_dependency "coveralls"
|
24
25
|
|
25
26
|
s.files = `git ls-files`.split("\n")
|
26
27
|
s.test_files = `git ls-files -- {test,spec,features}/*`.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.23
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: daemons
|
@@ -171,6 +171,22 @@ dependencies:
|
|
171
171
|
- - ! '>='
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: '0'
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: coveralls
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ! '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
type: :development
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ! '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
174
190
|
description: tweetlr crawls twitter for a given term, extracts photos out of the collected
|
175
191
|
tweets' short urls and posts the images to tumblr.
|
176
192
|
email: sven.kraeuter@gmail.com
|