twitter-photos 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/twitter-photos.rb +40 -29
  3. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.6
1
+ 0.1.7
@@ -36,27 +36,8 @@ class TwitterPhoto
36
36
  ObjectSpace.each_object(TwitterPhoto) {|o| o = nil}
37
37
  end
38
38
 
39
- # Fetch photos from Twitpic, yFrog, Twitgoo, and TweetPhoto.
40
- #
41
- # @example Find photos by @bookis only from yfrog and twitpic
42
- # TwitterPhoto.get_photos_by('bookis', :page => 2, :tweetphoto => false, :yfrog => true, :twitpic => true, :twitgoo => false)
43
- #
44
- # @option options [true, false] :tweetphoto
45
- # @option options [true, false] :twitpic
46
- # @option options [true, false] :yfrog
47
- # @option options [true, false] :twitgoo
48
- # @option options [Integer] :page
49
- #
50
- # @return [TwitterPhoto] collection.
51
- # @param [String] username
52
- # Accepts any twitter username
53
- # @param [Hash] options
54
- # exclude photo services (optional)
55
- # select number of pages to collect, defaults to 1
56
- def self.get_photos_by(username, options={:twitpic => true, :yfrog => true, :tweetphoto => true, :twitgoo => true, :page => 1})
57
- TwitterPhoto.delete_all
58
- hydra = Typhoeus::Hydra.new
59
- 1.upto(options[:page]).each do |page_num|
39
+ def self.twitpic(username, hydra, options, page=1)
40
+ 1.upto(page).each do |page_num|
60
41
  twitpic_request = Typhoeus::Request.new("#{TWITPIC_URL}/photos/#{username}", :params => {:page => page_num}, :timeout => 5000)
61
42
  twitpic_request.on_complete do |response|
62
43
  twitpics = Nokogiri.parse(response.body)
@@ -82,7 +63,10 @@ class TwitterPhoto
82
63
  end
83
64
  hydra.queue twitpic_request unless options[:twitpic] == false
84
65
  end
85
- 1.upto(options[:page]).each do |page_num|
66
+ end
67
+
68
+ def self.yfrog(username, hydra, options, page=1)
69
+ 1.upto(page).each do |page_num|
86
70
  yfrog_request = Typhoeus::Request.new(YFROG_URL, :params => {:page => page_num, :username => username}, :timeout => 5000)
87
71
  yfrog_request.on_complete do |response|
88
72
  yfrogs = Nokogiri.parse(response.body)
@@ -107,7 +91,9 @@ class TwitterPhoto
107
91
  end
108
92
  hydra.queue yfrog_request unless options[:yfrog] == false
109
93
  end
110
-
94
+ end
95
+
96
+ def self.tweetphoto(username, hydra, options, page=1)
111
97
  tweetphoto_request = Typhoeus::Request.new("#{TWEETPHOTO_URL}#{username}", :timeout => 5000)
112
98
  tweetphoto_request.on_complete do |response|
113
99
  if response.code == 200
@@ -128,8 +114,11 @@ class TwitterPhoto
128
114
  hydra.queue tweetphoto_username_request
129
115
  end
130
116
  end
131
-
132
- 1.upto(options[:page]).each do |page_num|
117
+ hydra.queue tweetphoto_request unless options[:tweetphoto] == false
118
+ end
119
+
120
+ def self.twitgoo(username, hydra, options, page=1)
121
+ 1.upto(page).each do |page_num|
133
122
  twitgoo_request = Typhoeus::Request.new("#{TWITGOO_URL}#{username}", :params => {:page => page_num, :format => 'json'}, :timeout => 5000)
134
123
  twitgoo_request.on_complete do |response|
135
124
  if response.code == 200
@@ -147,12 +136,34 @@ class TwitterPhoto
147
136
  end
148
137
  hydra.queue twitgoo_request unless options[:twitgoo] == false
149
138
  end
150
-
151
- hydra.queue tweetphoto_request unless options[:tweetphoto] == false
139
+ end
140
+
141
+ # Fetch photos from Twitpic, yFrog, Twitgoo, and TweetPhoto.
142
+ #
143
+ # @example Find photos by @bookis only from yfrog and twitpic
144
+ # TwitterPhoto.get_photos_by('bookis', :page => 2, :tweetphoto => false, :yfrog => true, :twitpic => true, :twitgoo => false)
145
+ #
146
+ # @option options [true, false] :tweetphoto
147
+ # @option options [true, false] :twitpic
148
+ # @option options [true, false] :yfrog
149
+ # @option options [true, false] :twitgoo
150
+ # @option options [Integer] :page
151
+ #
152
+ # @return [TwitterPhoto] collection.
153
+ # @param [String] username
154
+ # Accepts any twitter username
155
+ # @param [Hash] options
156
+ # exclude photo services (optional)
157
+ # select number of pages to collect, defaults to 1
158
+ def self.get_photos_by(username, options={:twitpic => true, :yfrog => true, :tweetphoto => true, :twitgoo => true, :page => 1})
159
+ TwitterPhoto.delete_all
160
+ hydra = Typhoeus::Hydra.new
161
+ TwitterPhoto.twitpic(username, hydra, options) unless options[:twitpic => false]
162
+ TwitterPhoto.yfrog(username, hydra, options) unless options[:yfrog => false]
163
+ TwitterPhoto.tweetphoto(username, hydra, options) unless options[:tweetphoto => false]
164
+ TwitterPhoto.twitgoo(username, hydra, options) unless options[:twitgoo => false]
152
165
  hydra.run
153
-
154
166
  TwitterPhoto.find_by_username(username)
155
-
156
167
  end
157
168
  end
158
169
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 6
9
- version: 0.1.6
8
+ - 7
9
+ version: 0.1.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - bookis
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-02 00:00:00 -06:00
17
+ date: 2010-06-08 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency