genki-twitphoto 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +43 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +52 -0
- data/VERSION +1 -0
- data/lib/adaptors.rb +108 -0
- data/lib/twitphoto.rb +152 -0
- data/test/helper.rb +18 -0
- data/test/test_twitphoto.rb +95 -0
- data/twitphoto.gemspec +66 -0
- metadata +164 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "yajl-ruby"
|
10
|
+
gem "twitter"
|
11
|
+
gem "shoulda", ">= 0"
|
12
|
+
gem "bundler", "~> 1.0.0"
|
13
|
+
gem "jeweler", "~> 1.6.2"
|
14
|
+
gem "rcov", ">= 0"
|
15
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
addressable (2.2.4)
|
5
|
+
faraday (0.5.7)
|
6
|
+
addressable (~> 2.2.4)
|
7
|
+
multipart-post (~> 1.1.0)
|
8
|
+
rack (< 2, >= 1.1.0)
|
9
|
+
faraday_middleware (0.3.2)
|
10
|
+
faraday (~> 0.5.4)
|
11
|
+
git (1.2.5)
|
12
|
+
hashie (1.0.0)
|
13
|
+
jeweler (1.6.2)
|
14
|
+
bundler (~> 1.0)
|
15
|
+
git (>= 1.2.5)
|
16
|
+
rake
|
17
|
+
multi_json (0.0.5)
|
18
|
+
multi_xml (0.2.1)
|
19
|
+
multipart-post (1.1.0)
|
20
|
+
rack (1.3.0)
|
21
|
+
rake (0.9.2)
|
22
|
+
rcov (0.9.9)
|
23
|
+
shoulda (2.11.3)
|
24
|
+
simple_oauth (0.1.4)
|
25
|
+
twitter (1.1.2)
|
26
|
+
faraday (~> 0.5.4)
|
27
|
+
faraday_middleware (~> 0.3.1)
|
28
|
+
hashie (~> 1.0.0)
|
29
|
+
multi_json (~> 0.0.5)
|
30
|
+
multi_xml (~> 0.2.0)
|
31
|
+
simple_oauth (~> 0.1.3)
|
32
|
+
yajl-ruby (0.8.2)
|
33
|
+
|
34
|
+
PLATFORMS
|
35
|
+
ruby
|
36
|
+
|
37
|
+
DEPENDENCIES
|
38
|
+
bundler (~> 1.0.0)
|
39
|
+
jeweler (~> 1.6.2)
|
40
|
+
rcov
|
41
|
+
shoulda
|
42
|
+
twitter
|
43
|
+
yajl-ruby
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Steve Cosman
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= twitphoto
|
2
|
+
|
3
|
+
a gem to generate an image URL from shortened URLs from common photo sharing tools. Supports twitpic, yfrog, instagram, flickr and plixi/lockerz
|
4
|
+
|
5
|
+
== Contributing to twitphoto
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 Steve Cosman. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
gem.name = "genki-twitphoto"
|
17
|
+
gem.homepage = "http://github.com/scosman/twitphoto"
|
18
|
+
gem.license = "MIT"
|
19
|
+
gem.summary = "a gem to generate an image URL from shortened URLs from common photo sharing tools. Supports twitter/photobucket, twitpic, yfrog, instagram and twitphoto/plixi/lockerz"
|
20
|
+
gem.description = "a gem to generate an image URL from shortened URLs from common photo sharing tools. Supports twitter/photobucket, twitpic, yfrog, instagram and tweetphoto/plixi/lockerz. It also includes support for the twitter gem, which helps with expanding t.co and bit.ly shortened URLs. Flickr is not supported as it would require a service call."
|
21
|
+
gem.email = "delrox@live.com"
|
22
|
+
gem.authors = ["Steve Cosman"]
|
23
|
+
# dependencies defined in Gemfile
|
24
|
+
end
|
25
|
+
Jeweler::RubygemsDotOrgTasks.new
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
Rake::TestTask.new(:test) do |test|
|
29
|
+
test.libs << 'lib' << 'test'
|
30
|
+
test.pattern = 'test/**/test_*.rb'
|
31
|
+
test.verbose = true
|
32
|
+
end
|
33
|
+
|
34
|
+
require 'rcov/rcovtask'
|
35
|
+
Rcov::RcovTask.new do |test|
|
36
|
+
test.libs << 'test'
|
37
|
+
test.pattern = 'test/**/test_*.rb'
|
38
|
+
test.verbose = true
|
39
|
+
test.rcov_opts << '--exclude "gems/*"'
|
40
|
+
end
|
41
|
+
|
42
|
+
task :default => :test
|
43
|
+
|
44
|
+
require 'rake/rdoctask'
|
45
|
+
Rake::RDocTask.new do |rdoc|
|
46
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
47
|
+
|
48
|
+
rdoc.rdoc_dir = 'rdoc'
|
49
|
+
rdoc.title = "twitphoto #{version}"
|
50
|
+
rdoc.rdoc_files.include('README*')
|
51
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
52
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.10.0
|
data/lib/adaptors.rb
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
3
|
+
module TwitPhoto
|
4
|
+
class Adaptors
|
5
|
+
class InstagramAdaptor
|
6
|
+
def self.domains
|
7
|
+
%w(http://instagr.am)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.getImageUrl url
|
11
|
+
domain = self.domains.select { |d| url.to_s.start_with?(d) }
|
12
|
+
return nil if domain.empty?
|
13
|
+
|
14
|
+
# ensure last char is '/'
|
15
|
+
if url[url.length - 1] != "/"[0]
|
16
|
+
url = url + "/"
|
17
|
+
end
|
18
|
+
|
19
|
+
return url + "media/?size=l"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class LockerzAdaptor
|
24
|
+
|
25
|
+
# TweetPhoto was a good name, why they changed twice I don't understand
|
26
|
+
def self.domains
|
27
|
+
%w(http://tweetphoto.com http://plixi.com http://lockerz.com)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.getImageUrl url
|
31
|
+
domain = self.domains.select { |d| url.to_s.start_with?(d) }
|
32
|
+
return nil if domain.empty?
|
33
|
+
|
34
|
+
return "http://api.plixi.com/api/tpapi.svc/imagefromurl?size=large&url=" + url
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class TwitPicAdaptor
|
39
|
+
def self.domains
|
40
|
+
%w(http://twitpic.com)
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.getImageUrl url
|
44
|
+
domain = self.domains.select { |d| url.to_s.start_with?(d) }
|
45
|
+
return nil if domain.empty?
|
46
|
+
|
47
|
+
uri = URI.parse(url)
|
48
|
+
id = uri.path
|
49
|
+
|
50
|
+
return "http://twitpic.com/show/large" + id
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class YFrogAdaptor
|
55
|
+
# check for "http://yfrog." (no domain since yfrog supports many domains)
|
56
|
+
def self.domains
|
57
|
+
%w(http://yfrog.)
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.getImageUrl url
|
61
|
+
domain = self.domains.select { |d| url.to_s.start_with?(d) }
|
62
|
+
return nil if domain.empty?
|
63
|
+
|
64
|
+
uri = URI.parse(url)
|
65
|
+
id = uri.path
|
66
|
+
|
67
|
+
return "http://yfrog.com" + id + ":medium"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
class TwitGooAdaptor
|
72
|
+
def self.domains
|
73
|
+
%w(http://twitgoo.com)
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.getImageUrl url
|
77
|
+
domain = self.domains.select { |d| url.to_s.start_with?(d) }
|
78
|
+
return nil if domain.empty?
|
79
|
+
|
80
|
+
# ensure last char is '/'
|
81
|
+
if url[url.length - 1] != "/"[0]
|
82
|
+
url = url + "/"
|
83
|
+
end
|
84
|
+
|
85
|
+
return url + "img"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
class ImglyAdaptor
|
90
|
+
# check for "http://yfrog." (no domain since yfrog supports many domains)
|
91
|
+
def self.domains
|
92
|
+
%w(http://img.ly)
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.getImageUrl url
|
96
|
+
domain = self.domains.select { |d| url.to_s.start_with?(d) }
|
97
|
+
return nil if domain.empty?
|
98
|
+
|
99
|
+
uri = URI.parse(url)
|
100
|
+
id = uri.path.split('/').last
|
101
|
+
|
102
|
+
# Must end with /
|
103
|
+
return "http://img.ly/show/full/" + id + "/"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
data/lib/twitphoto.rb
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
require 'adaptors'
|
2
|
+
|
3
|
+
module TwitPhoto
|
4
|
+
class TwitPhoto
|
5
|
+
|
6
|
+
public
|
7
|
+
|
8
|
+
# gets all of the photo URLs from a blog of text
|
9
|
+
#
|
10
|
+
# == Parameters:
|
11
|
+
# text::
|
12
|
+
# the text you want to extract media from
|
13
|
+
#
|
14
|
+
# == Returns:
|
15
|
+
# return::
|
16
|
+
# an array of URLs as strings (not URI objects)
|
17
|
+
#
|
18
|
+
# == Example:
|
19
|
+
# Get photo URLs from a block of text
|
20
|
+
# TwitPhoto::TwitPhoto.getPhotoUrlsFromText "Hello http://yfrog.com/kfx6gdj http://yfrog.com/klmjxyej"
|
21
|
+
def self.getPhotoUrlsFromText(text)
|
22
|
+
urlStrings = URI.extract text
|
23
|
+
results = []
|
24
|
+
|
25
|
+
urlStrings.each do |url|
|
26
|
+
imageUrl = TwitPhoto.getPhotoUrlFromUrl url
|
27
|
+
if !imageUrl.nil?
|
28
|
+
results << imageUrl
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
return results
|
33
|
+
end
|
34
|
+
|
35
|
+
# extracts the media url from a shortened url (if possible)
|
36
|
+
#
|
37
|
+
# == Parameters:
|
38
|
+
# url::
|
39
|
+
# The URL as a string (not URI)
|
40
|
+
#
|
41
|
+
# == Returns:
|
42
|
+
# return::
|
43
|
+
# A media URL as a string, or nil
|
44
|
+
#
|
45
|
+
# == Example:
|
46
|
+
# TwitPhoto::TwitPhoto.getPhotoUrlFromUrl "http://yfrog.com/kfx6gdj"
|
47
|
+
def self.getPhotoUrlFromUrl url
|
48
|
+
self.adaptors.each do |adaptor|
|
49
|
+
imageUrl = adaptor.getImageUrl url
|
50
|
+
if !imageUrl.nil?
|
51
|
+
return imageUrl
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
return nil
|
56
|
+
end
|
57
|
+
|
58
|
+
# returns all of the photo URLs from a tweet object from the "twitter" gem (http://twitter.rubyforge.org/)
|
59
|
+
#
|
60
|
+
# IMPORTANT: this expects detailed entities from the twitter API, so request with :include_entities => 't'
|
61
|
+
#
|
62
|
+
# IMPORTANT: this will yield better results than the other methods, since Twitter now has native media support
|
63
|
+
#
|
64
|
+
# == Paramaters
|
65
|
+
# tweet::
|
66
|
+
# the tweet object from the twitter gem
|
67
|
+
#
|
68
|
+
# == Returns:
|
69
|
+
# returns::
|
70
|
+
# the array of media URLs in this tweet
|
71
|
+
def self.getPhotoUrlsFromTweet tweet
|
72
|
+
results = []
|
73
|
+
|
74
|
+
if !tweet.retweeted_status.nil?
|
75
|
+
tweet = tweet.retweeted_status
|
76
|
+
end
|
77
|
+
|
78
|
+
# ensure the user included entites
|
79
|
+
if !defined? tweet.entites || tweet.entities.nil?
|
80
|
+
raise ArgumentError, 'not a valid tweet object, make sure you :include_entities => \'t\' in the request'
|
81
|
+
end
|
82
|
+
|
83
|
+
# process URLs from third party photos
|
84
|
+
urls = tweet.entities.urls || []
|
85
|
+
urls.each do |url|
|
86
|
+
# sometimes its in expanded, sometimes URL
|
87
|
+
actualUrl = url.expanded_url
|
88
|
+
if actualUrl.nil?
|
89
|
+
actualUrl = url.url
|
90
|
+
end
|
91
|
+
if !actualUrl.nil?
|
92
|
+
photoUrl = TwitPhoto.getPhotoUrlFromUrl actualUrl
|
93
|
+
if !photoUrl.nil?
|
94
|
+
results << photoUrl
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# find any media from twitter itself (photobucket)
|
100
|
+
medias = tweet.entities.media || []
|
101
|
+
medias.each do |media|
|
102
|
+
#only photos
|
103
|
+
if 'photo'.eql? media[:type]
|
104
|
+
results << media.media_url
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
return results
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
# Expand shortened url
|
114
|
+
#
|
115
|
+
# == Parameters:
|
116
|
+
# url::
|
117
|
+
# The URL as a string (not URI)
|
118
|
+
#
|
119
|
+
# == Returns:
|
120
|
+
# return::
|
121
|
+
# A final URL as a string, or nil
|
122
|
+
#
|
123
|
+
# == Example:
|
124
|
+
# TwitPhoto::TwitPhoto.process_redirects "http://http://bit.ly/oMoqqY"
|
125
|
+
def self.expand_urls(u)
|
126
|
+
response = Net::HTTP.get_response(URI.parse(u))
|
127
|
+
return u unless response.kind_of?(Net::HTTPRedirection)
|
128
|
+
|
129
|
+
limit = 3
|
130
|
+
|
131
|
+
while limit > 0 && response.kind_of?(Net::HTTPRedirection)
|
132
|
+
|
133
|
+
u = response['location']
|
134
|
+
response = Net::HTTP.get_response(URI.parse(u))
|
135
|
+
|
136
|
+
limit -= 1
|
137
|
+
end
|
138
|
+
u
|
139
|
+
end
|
140
|
+
|
141
|
+
def self.supported_domains
|
142
|
+
self.adaptors.map{ |a| a.domains }.flatten
|
143
|
+
end
|
144
|
+
|
145
|
+
protected
|
146
|
+
|
147
|
+
def self.adaptors
|
148
|
+
[Adaptors::YFrogAdaptor, Adaptors::TwitPicAdaptor, Adaptors::LockerzAdaptor, Adaptors::InstagramAdaptor, Adaptors::TwitGooAdaptor, Adaptors::ImglyAdaptor]
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'twitphoto'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'twitphoto'
|
4
|
+
require 'adaptors'
|
5
|
+
require 'twitter'
|
6
|
+
|
7
|
+
class TestTwitphoto < Test::Unit::TestCase
|
8
|
+
|
9
|
+
should "test usage with Twitter gem" do
|
10
|
+
|
11
|
+
tweetWithTwitterMedia = Twitter.status(82472660038197249, :include_entities => 't')
|
12
|
+
results = TwitPhoto::TwitPhoto.getPhotoUrlsFromTweet(tweetWithTwitterMedia)
|
13
|
+
assert_equal 1, results.length
|
14
|
+
assert_equal "http://p.twimg.com/ASUAcoWCIAIsmIA.png", results[0]
|
15
|
+
|
16
|
+
RTtweetWithTwitterMedia = Twitter.status(82486891202621440, :include_entities => 't')
|
17
|
+
results = TwitPhoto::TwitPhoto.getPhotoUrlsFromTweet(RTtweetWithTwitterMedia)
|
18
|
+
assert_equal 1, results.length
|
19
|
+
assert_equal "http://p.twimg.com/ASUAcoWCIAIsmIA.png", results[0]
|
20
|
+
|
21
|
+
tweetWithThirdPartyMedia = Twitter.status(82480106379026433, :include_entities => 't')
|
22
|
+
results = TwitPhoto::TwitPhoto.getPhotoUrlsFromTweet tweetWithThirdPartyMedia
|
23
|
+
assert_equal 1, results.length
|
24
|
+
assert_equal "http://yfrog.com/kea33tj:medium", results[0]
|
25
|
+
|
26
|
+
tweetWithThirdPartyMediaMulti = Twitter.status(82513016645623808, :include_entities => 't')
|
27
|
+
results = TwitPhoto::TwitPhoto.getPhotoUrlsFromTweet tweetWithThirdPartyMediaMulti
|
28
|
+
assert_equal 3, results.length
|
29
|
+
|
30
|
+
tweetWithNoMedia = Twitter.status(82153561638699008, :include_entities => 't')
|
31
|
+
results = TwitPhoto::TwitPhoto.getPhotoUrlsFromTweet tweetWithNoMedia
|
32
|
+
assert_equal 0, results.length
|
33
|
+
end
|
34
|
+
|
35
|
+
should "test getPhotoFromUrl" do
|
36
|
+
assert_equal TwitPhoto::TwitPhoto.getPhotoUrlFromUrl("http://tweetphoto.com/28103398"), "http://api.plixi.com/api/tpapi.svc/imagefromurl?size=large&url=http://tweetphoto.com/28103398"
|
37
|
+
assert_equal TwitPhoto::TwitPhoto.getPhotoUrlFromUrl("http://lockerz.com/s/110826629"), "http://api.plixi.com/api/tpapi.svc/imagefromurl?size=large&url=http://lockerz.com/s/110826629"
|
38
|
+
assert_equal TwitPhoto::TwitPhoto.getPhotoUrlFromUrl("http://plixi.com/p/89511189"), "http://api.plixi.com/api/tpapi.svc/imagefromurl?size=large&url=http://plixi.com/p/89511189"
|
39
|
+
assert_equal TwitPhoto::TwitPhoto.getPhotoUrlFromUrl("http://yfrog.com/gzozrllj"), "http://yfrog.com/gzozrllj:medium"
|
40
|
+
assert_equal TwitPhoto::TwitPhoto.getPhotoUrlFromUrl("http://instagr.am/p/Fv3t0"), "http://instagr.am/p/Fv3t0/media/?size=l"
|
41
|
+
assert_equal TwitPhoto::TwitPhoto.getPhotoUrlFromUrl("http://twitpic.com/5bpgp0"), "http://twitpic.com/show/large/5bpgp0"
|
42
|
+
assert_equal TwitPhoto::TwitPhoto.getPhotoUrlFromUrl("http://twitgoo.com/2l2uq0"), "http://twitgoo.com/2l2uq0/img"
|
43
|
+
assert_equal TwitPhoto::TwitPhoto.getPhotoUrlFromUrl("http://img.ly/6IWZ"), "http://img.ly/show/full/6IWZ/"
|
44
|
+
assert TwitPhoto::TwitPhoto.getPhotoUrlFromUrl("http://google.ca").nil?
|
45
|
+
end
|
46
|
+
|
47
|
+
should "test getPhotoUrlsFromText" do
|
48
|
+
assert_equal TwitPhoto::TwitPhoto.getPhotoUrlsFromText("http:www.google.com").length, 0
|
49
|
+
assert_equal TwitPhoto::TwitPhoto.getPhotoUrlsFromText("http:www.google.com http://tweetphoto.com/28103398").length, 1
|
50
|
+
assert_equal TwitPhoto::TwitPhoto.getPhotoUrlsFromText("http:www.google.com http://tweetphoto.com/28103398 http://instagr.am/p/Fv3t0").length, 2
|
51
|
+
assert_equal TwitPhoto::TwitPhoto.getPhotoUrlsFromText("http://lockerz.com/s/110826629").length, 1
|
52
|
+
assert_equal TwitPhoto::TwitPhoto.getPhotoUrlsFromText("Content http://twitpic.com/5bpgp0 content").length, 1
|
53
|
+
assert_equal TwitPhoto::TwitPhoto.getPhotoUrlsFromText("TwitGoo AND Imgly http://twitgoo.com/2l2uq0 yay http://img.ly/6IWZ").length, 2
|
54
|
+
assert_equal TwitPhoto::TwitPhoto.getPhotoUrlsFromText("Content http://yfrog.com/gzozrllj http://plixi.com/p/89511189 content").length, 2
|
55
|
+
end
|
56
|
+
|
57
|
+
should "test TweetPhot/Lockerz/Plixi" do
|
58
|
+
assert_equal TwitPhoto::Adaptors::LockerzAdaptor.getImageUrl("http://tweetphoto.com/28103398"), "http://api.plixi.com/api/tpapi.svc/imagefromurl?size=large&url=http://tweetphoto.com/28103398"
|
59
|
+
assert_equal TwitPhoto::Adaptors::LockerzAdaptor.getImageUrl("http://lockerz.com/s/110826629"), "http://api.plixi.com/api/tpapi.svc/imagefromurl?size=large&url=http://lockerz.com/s/110826629"
|
60
|
+
assert_equal TwitPhoto::Adaptors::LockerzAdaptor.getImageUrl("http://plixi.com/p/89511189"), "http://api.plixi.com/api/tpapi.svc/imagefromurl?size=large&url=http://plixi.com/p/89511189"
|
61
|
+
assert TwitPhoto::Adaptors::YFrogAdaptor.getImageUrl("http://notyfrog.com/gzozrllj").nil?
|
62
|
+
end
|
63
|
+
|
64
|
+
should "test Yfrog" do
|
65
|
+
assert_equal TwitPhoto::Adaptors::YFrogAdaptor.getImageUrl("http://yfrog.com/gzozrllj"), "http://yfrog.com/gzozrllj:medium"
|
66
|
+
assert TwitPhoto::Adaptors::YFrogAdaptor.getImageUrl("http://notyfrog.com/gzozrllj").nil?
|
67
|
+
assert_equal TwitPhoto::Adaptors::YFrogAdaptor.getImageUrl("http://yfrog.com/gz23uqdj"), "http://yfrog.com/gz23uqdj:medium"
|
68
|
+
end
|
69
|
+
|
70
|
+
should "test Instagram" do
|
71
|
+
assert_equal TwitPhoto::Adaptors::InstagramAdaptor.getImageUrl("http://instagr.am/p/Fv3t0"), "http://instagr.am/p/Fv3t0/media/?size=l"
|
72
|
+
assert TwitPhoto::Adaptors::InstagramAdaptor.getImageUrl("http://instagr.aam/p/Fv3t0").nil?
|
73
|
+
assert_equal TwitPhoto::Adaptors::InstagramAdaptor.getImageUrl("http://instagr.am/p/Fv3t0/"), "http://instagr.am/p/Fv3t0/media/?size=l"
|
74
|
+
end
|
75
|
+
|
76
|
+
should "test TwitPic" do
|
77
|
+
assert_equal TwitPhoto::Adaptors::TwitPicAdaptor.getImageUrl("http://twitpic.com/5bpgp0"), "http://twitpic.com/show/large/5bpgp0"
|
78
|
+
assert TwitPhoto::Adaptors::TwitPicAdaptor.getImageUrl("http://nottwitpic.com/5bpgp0").nil?
|
79
|
+
assert_equal TwitPhoto::Adaptors::TwitPicAdaptor.getImageUrl("http://twitpic.com/5b3rhe"), "http://twitpic.com/show/large/5b3rhe"
|
80
|
+
end
|
81
|
+
|
82
|
+
should "test TwitGoo" do
|
83
|
+
assert_equal TwitPhoto::Adaptors::TwitGooAdaptor.getImageUrl("http://twitgoo.com/2l2uq0"), "http://twitgoo.com/2l2uq0/img"
|
84
|
+
assert TwitPhoto::Adaptors::TwitGooAdaptor.getImageUrl("http://nottwitgoo.com/2l2uq0").nil?
|
85
|
+
assert_equal TwitPhoto::Adaptors::TwitGooAdaptor.getImageUrl("http://twitgoo.com/2l2uq0/"), "http://twitgoo.com/2l2uq0/img"
|
86
|
+
end
|
87
|
+
|
88
|
+
should "test Imgly" do
|
89
|
+
assert_equal TwitPhoto::Adaptors::ImglyAdaptor.getImageUrl("http://img.ly/6IWZ"), "http://img.ly/show/full/6IWZ/"
|
90
|
+
assert TwitPhoto::Adaptors::ImglyAdaptor.getImageUrl("http://imgxlily.com/2l2uq0").nil?
|
91
|
+
assert_equal TwitPhoto::Adaptors::ImglyAdaptor.getImageUrl("http://img.ly/6IWZ/"), "http://img.ly/show/full/6IWZ/"
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
end
|
data/twitphoto.gemspec
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{twitphoto}
|
8
|
+
s.version = "0.10.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = [%q{Steve Cosman}]
|
12
|
+
s.date = %q{2011-09-15}
|
13
|
+
s.description = %q{a gem to generate an image URL from shortened URLs from common photo sharing tools. Supports twitter/photobucket, twitpic, yfrog, instagram and tweetphoto/plixi/lockerz. It also includes support for the twitter gem, which helps with expanding t.co and bit.ly shortened URLs. Flickr is not supported as it would require a service call.}
|
14
|
+
s.email = %q{delrox@live.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"lib/adaptors.rb",
|
28
|
+
"lib/twitphoto.rb",
|
29
|
+
"test/helper.rb",
|
30
|
+
"test/test_twitphoto.rb",
|
31
|
+
"twitphoto.gemspec"
|
32
|
+
]
|
33
|
+
s.homepage = %q{http://github.com/scosman/twitphoto}
|
34
|
+
s.licenses = [%q{MIT}]
|
35
|
+
s.require_paths = [%q{lib}]
|
36
|
+
s.rubygems_version = %q{1.8.6}
|
37
|
+
s.summary = %q{a gem to generate an image URL from shortened URLs from common photo sharing tools. Supports twitter/photobucket, twitpic, yfrog, instagram and twitphoto/plixi/lockerz}
|
38
|
+
|
39
|
+
if s.respond_to? :specification_version then
|
40
|
+
s.specification_version = 3
|
41
|
+
|
42
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
43
|
+
s.add_development_dependency(%q<yajl-ruby>, [">= 0"])
|
44
|
+
s.add_development_dependency(%q<twitter>, [">= 0"])
|
45
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
46
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
47
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
|
48
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
49
|
+
else
|
50
|
+
s.add_dependency(%q<yajl-ruby>, [">= 0"])
|
51
|
+
s.add_dependency(%q<twitter>, [">= 0"])
|
52
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
53
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
54
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
55
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
56
|
+
end
|
57
|
+
else
|
58
|
+
s.add_dependency(%q<yajl-ruby>, [">= 0"])
|
59
|
+
s.add_dependency(%q<twitter>, [">= 0"])
|
60
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
61
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
62
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
63
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
metadata
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: genki-twitphoto
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 55
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 10
|
9
|
+
- 0
|
10
|
+
version: 0.10.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Steve Cosman
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-09-15 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
type: :development
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 3
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
version_requirements: *id001
|
32
|
+
name: yajl-ruby
|
33
|
+
prerelease: false
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
type: :development
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
hash: 3
|
42
|
+
segments:
|
43
|
+
- 0
|
44
|
+
version: "0"
|
45
|
+
version_requirements: *id002
|
46
|
+
name: twitter
|
47
|
+
prerelease: false
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
type: :development
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
hash: 3
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
version: "0"
|
59
|
+
version_requirements: *id003
|
60
|
+
name: shoulda
|
61
|
+
prerelease: false
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
type: :development
|
64
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
hash: 23
|
70
|
+
segments:
|
71
|
+
- 1
|
72
|
+
- 0
|
73
|
+
- 0
|
74
|
+
version: 1.0.0
|
75
|
+
version_requirements: *id004
|
76
|
+
name: bundler
|
77
|
+
prerelease: false
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
type: :development
|
80
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: 11
|
86
|
+
segments:
|
87
|
+
- 1
|
88
|
+
- 6
|
89
|
+
- 2
|
90
|
+
version: 1.6.2
|
91
|
+
version_requirements: *id005
|
92
|
+
name: jeweler
|
93
|
+
prerelease: false
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
type: :development
|
96
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
hash: 3
|
102
|
+
segments:
|
103
|
+
- 0
|
104
|
+
version: "0"
|
105
|
+
version_requirements: *id006
|
106
|
+
name: rcov
|
107
|
+
prerelease: false
|
108
|
+
description: a gem to generate an image URL from shortened URLs from common photo sharing tools. Supports twitter/photobucket, twitpic, yfrog, instagram and tweetphoto/plixi/lockerz. It also includes support for the twitter gem, which helps with expanding t.co and bit.ly shortened URLs. Flickr is not supported as it would require a service call.
|
109
|
+
email: delrox@live.com
|
110
|
+
executables: []
|
111
|
+
|
112
|
+
extensions: []
|
113
|
+
|
114
|
+
extra_rdoc_files:
|
115
|
+
- LICENSE.txt
|
116
|
+
- README.rdoc
|
117
|
+
files:
|
118
|
+
- .document
|
119
|
+
- Gemfile
|
120
|
+
- Gemfile.lock
|
121
|
+
- LICENSE.txt
|
122
|
+
- README.rdoc
|
123
|
+
- Rakefile
|
124
|
+
- VERSION
|
125
|
+
- lib/adaptors.rb
|
126
|
+
- lib/twitphoto.rb
|
127
|
+
- test/helper.rb
|
128
|
+
- test/test_twitphoto.rb
|
129
|
+
- twitphoto.gemspec
|
130
|
+
homepage: http://github.com/scosman/twitphoto
|
131
|
+
licenses:
|
132
|
+
- MIT
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
|
136
|
+
require_paths:
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
hash: 3
|
144
|
+
segments:
|
145
|
+
- 0
|
146
|
+
version: "0"
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
none: false
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
hash: 3
|
153
|
+
segments:
|
154
|
+
- 0
|
155
|
+
version: "0"
|
156
|
+
requirements: []
|
157
|
+
|
158
|
+
rubyforge_project:
|
159
|
+
rubygems_version: 1.8.6
|
160
|
+
signing_key:
|
161
|
+
specification_version: 3
|
162
|
+
summary: a gem to generate an image URL from shortened URLs from common photo sharing tools. Supports twitter/photobucket, twitpic, yfrog, instagram and twitphoto/plixi/lockerz
|
163
|
+
test_files: []
|
164
|
+
|