pupil 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/Gemfile.lock +5 -3
- data/VERSION +1 -1
- data/lib/pupil.rb +18 -660
- data/lib/pupil/account.rb +51 -0
- data/lib/pupil/base.rb +83 -0
- data/lib/pupil/blocks.rb +45 -0
- data/lib/pupil/direct_messages.rb +57 -0
- data/lib/pupil/friendships.rb +70 -0
- data/lib/pupil/{keygen.rb → keygen/keygen.rb} +0 -0
- data/lib/pupil/lists.rb +34 -0
- data/lib/pupil/schemes.rb +220 -0
- data/lib/pupil/statuses.rb +84 -0
- data/lib/pupil/stream.rb +94 -0
- data/lib/pupil/users.rb +13 -0
- data/pupil.gemspec +16 -4
- data/samples/generate-key.rb +1 -2
- data/spec/pupil_spec.rb +123 -2
- metadata +37 -17
- data/samples/ff-dumper.rb +0 -19
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
diff-lcs (1.1.
|
4
|
+
diff-lcs (1.1.3)
|
5
5
|
git (1.2.5)
|
6
6
|
jeweler (1.6.4)
|
7
7
|
bundler (~> 1.0)
|
8
8
|
git (>= 1.2.5)
|
9
9
|
rake
|
10
|
+
json (1.6.3)
|
10
11
|
oauth (0.4.5)
|
11
|
-
rake (0.9.2)
|
12
|
-
rcov (0.9.
|
12
|
+
rake (0.9.2.2)
|
13
|
+
rcov (0.9.11)
|
13
14
|
rspec (2.3.0)
|
14
15
|
rspec-core (~> 2.3.0)
|
15
16
|
rspec-expectations (~> 2.3.0)
|
@@ -26,6 +27,7 @@ PLATFORMS
|
|
26
27
|
DEPENDENCIES
|
27
28
|
bundler (~> 1.0.0)
|
28
29
|
jeweler (~> 1.6.4)
|
30
|
+
json
|
29
31
|
oauth
|
30
32
|
rcov
|
31
33
|
rspec (~> 2.3.0)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/lib/pupil.rb
CHANGED
@@ -1,662 +1,20 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
|
9
|
-
|
10
|
-
$LOAD_PATH << File.dirname(File.expand_path(__FILE__)) if RUBY_VERSION >=
|
11
|
-
require
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
@config = nil
|
22
|
-
consumer = OAuth::Consumer.new(
|
23
|
-
pupil_key[:consumer_key],
|
24
|
-
pupil_key[:consumer_secret],
|
25
|
-
:site => 'http://api.twitter.com'
|
26
|
-
)
|
27
|
-
@access_token = OAuth::AccessToken.new(
|
28
|
-
consumer,
|
29
|
-
pupil_key[:access_token],
|
30
|
-
pupil_key[:access_token_secret]
|
31
|
-
)
|
32
|
-
end
|
33
|
-
|
34
|
-
# @param [Hash] parameter
|
35
|
-
# @return [String] URL Serialized parameters
|
36
|
-
def param_serializer parameter
|
37
|
-
ant = Hash.new
|
38
|
-
parameter.each do |key, value|
|
39
|
-
case key.to_sym
|
40
|
-
when :include
|
41
|
-
if value.class == String || Symbol
|
42
|
-
ant[:"include_#{value}"] = :true
|
43
|
-
break
|
44
|
-
end
|
45
|
-
|
46
|
-
value.each do |element|
|
47
|
-
raise UnsupportedParameter, 'include_entities is not supported.' if element.to_sym == :entities
|
48
|
-
ant[:"include_#{element}"] = :true
|
49
|
-
end
|
50
|
-
when :exclude
|
51
|
-
if value.class == String || Symbol
|
52
|
-
ant[:"exclude_#{value}"] = :true
|
53
|
-
break
|
54
|
-
end
|
55
|
-
|
56
|
-
value.each do |element|
|
57
|
-
ant[:"exclude_#{element}"] = :true
|
58
|
-
end
|
59
|
-
else
|
60
|
-
ant[key.to_sym] = value
|
61
|
-
end
|
62
|
-
end
|
63
|
-
param = ant.inject(""){|k,v|k+"&#{v[0]}=#{v[1]}"}.sub!(/^&/,"?")
|
64
|
-
return param ? param : ""
|
65
|
-
end
|
66
|
-
|
67
|
-
class REXML::Document
|
68
|
-
def is_error?
|
69
|
-
if self.root.get_text("error") then
|
70
|
-
return true
|
71
|
-
else
|
72
|
-
return false
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def get_error_message
|
77
|
-
return self.root.get_text("error")
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
public
|
82
|
-
|
83
|
-
# @return [Hash] User credentials
|
84
|
-
def verify_credentials
|
85
|
-
response = @access_token.get('/account/verify_credentials.xml')
|
86
|
-
doc = REXML::Document.new(response.body)
|
87
|
-
return false if doc.is_error?
|
88
|
-
user = User.new(doc.elements['/user'])
|
89
|
-
return user
|
90
|
-
end
|
91
|
-
|
92
|
-
# Alias to Pupil#home_timeline
|
93
|
-
# @param [Hash] param
|
94
|
-
# @return [Array] Timeline
|
95
|
-
# @deprecated Use {#home_timeline} instead of this method because
|
96
|
-
# is was obsoleted.
|
97
|
-
def friends_timeline(param = {})
|
98
|
-
param_s = param_serializer(param)
|
99
|
-
begin
|
100
|
-
response = @access_token.get("http://api.twitter.com/1/statuses/friends_timeline.xml"+param_s)
|
101
|
-
rescue
|
102
|
-
return false
|
103
|
-
end
|
104
|
-
doc = REXML::Document.new(response.body)
|
105
|
-
return false if doc.is_error?
|
106
|
-
statuses = Array.new
|
107
|
-
|
108
|
-
doc.get_elements('/statuses/status').each do |element|
|
109
|
-
status = Status.new(element)
|
110
|
-
statuses << status
|
111
|
-
end
|
112
|
-
|
113
|
-
return statuses
|
114
|
-
end
|
115
|
-
|
116
|
-
# @param [Hash] param
|
117
|
-
# @return [Array] Timeline
|
118
|
-
def home_timeline(param = {})
|
119
|
-
param_s = param_serializer(param)
|
120
|
-
begin
|
121
|
-
response = @access_token.get("http://api.twitter.com/1/statuses/home_timeline.xml"+param_s)
|
122
|
-
rescue
|
123
|
-
return false
|
124
|
-
end
|
125
|
-
doc = REXML::Document.new(response.body)
|
126
|
-
return false if doc.is_error?
|
127
|
-
statuses = Array.new
|
128
|
-
doc.get_elements('/statuses/status').each{|element|
|
129
|
-
status = Status.new(element)
|
130
|
-
statuses << status
|
131
|
-
}
|
132
|
-
return statuses
|
133
|
-
end
|
134
|
-
|
135
|
-
# Returning user timeline
|
136
|
-
# @param [Hash] param
|
137
|
-
# @return [Hash] timeline
|
138
|
-
# @option param [Fixnum] :user_id The ID of user
|
139
|
-
# @option param [String] :screen_name The Screen name of user
|
140
|
-
# @option param [Fixnum] :since_id
|
141
|
-
# @option param [Fixnum] :max_id
|
142
|
-
# @option param [Fixnum] :count
|
143
|
-
# @option param [Fixnum] :page Specifies
|
144
|
-
# @option param [Symbol] :trim_user
|
145
|
-
# @option param [Symbol] :include #=> [:rts]
|
146
|
-
# @option param [Symbol] :exclude #=> [:replies]
|
147
|
-
# @option param [Symbol] :contributor_details
|
148
|
-
# @example
|
149
|
-
# twitter = Pupil.new PUPIL_KEY
|
150
|
-
# twitter.user_timeline(:screen_name => 'o_ame', :exclude => :replies).each do |status|
|
151
|
-
# puts "#{status.user.screen_name}: #{status.text}"
|
152
|
-
# end
|
153
|
-
def user_timeline(param = {})
|
154
|
-
param_s = param_serializer(param)
|
155
|
-
begin
|
156
|
-
response = @access_token.get("http://api.twitter.com/1/statuses/user_timeline.xml"+param_s)
|
157
|
-
rescue
|
158
|
-
return false
|
159
|
-
end
|
160
|
-
doc = REXML::Document.new(response.body)
|
161
|
-
return false if doc.is_error?
|
162
|
-
statuses = Array.new
|
163
|
-
doc.get_elements('/statuses/status').each{|element|
|
164
|
-
status = Status.new(element)
|
165
|
-
statuses << status
|
166
|
-
}
|
167
|
-
return statuses
|
168
|
-
end
|
169
|
-
|
170
|
-
# @param [Hash] param
|
171
|
-
# @return [Hash] mention
|
172
|
-
def mentions(param = {})
|
173
|
-
param_s = param_serializer(param)
|
174
|
-
begin
|
175
|
-
response = @access_token.get("http://api.twitter.com/1/statuses/mentions.xml"+param_s)
|
176
|
-
rescue
|
177
|
-
return false
|
178
|
-
end
|
179
|
-
doc = REXML::Document.new(response.body)
|
180
|
-
return false if doc.is_error?
|
181
|
-
statuses = Array.new
|
182
|
-
|
183
|
-
doc.get_elements('/statuses/status').each{|element|
|
184
|
-
status = Status.new(element)
|
185
|
-
statuses << status
|
186
|
-
}
|
187
|
-
|
188
|
-
return statuses
|
189
|
-
end
|
190
|
-
|
191
|
-
# Returning direct messages
|
192
|
-
# @param [Hash] param
|
193
|
-
# @return [Hash] directmessages
|
194
|
-
def dm(param = {})
|
195
|
-
param_s = param_serializer(param)
|
196
|
-
begin
|
197
|
-
response = @access_token.get("http://api.twitter.com/1/direct_messages.xml"+param_s)
|
198
|
-
rescue
|
199
|
-
return false
|
200
|
-
end
|
201
|
-
doc = REXML::Document.new(response.body)
|
202
|
-
return false if doc.is_error?
|
203
|
-
directmessages = Array.new
|
204
|
-
|
205
|
-
doc.get_elements('/direct-messages/direct_message').each{|element|
|
206
|
-
dm = DirectMessage.new(element)
|
207
|
-
directmessages << dm
|
208
|
-
}
|
209
|
-
|
210
|
-
return directmessages
|
211
|
-
end
|
212
|
-
|
213
|
-
# Returning direct messages you sent
|
214
|
-
# @param [Hash] param
|
215
|
-
# @return [Hash] directmessage you sent
|
216
|
-
def dm_sent(param = {})
|
217
|
-
param_s = param_serializer(param)
|
218
|
-
begin
|
219
|
-
response = @access_token.get("http://api.twitter.com/1/direct_messages/sent.xml"+param_s)
|
220
|
-
rescue
|
221
|
-
return false
|
222
|
-
end
|
223
|
-
doc = REXML::Document.new(response.body)
|
224
|
-
return false if doc.is_error?
|
225
|
-
directmessages = Array.new
|
226
|
-
|
227
|
-
doc.get_elements('/direct-messages/direct_message').each{|element|
|
228
|
-
dm = DirectMessage.new(element)
|
229
|
-
directmessages << dm
|
230
|
-
}
|
231
|
-
|
232
|
-
return directmessages
|
233
|
-
end
|
234
|
-
|
235
|
-
# Delete direct message
|
236
|
-
# @param [Fixnum] dm_id message id that you want to delete
|
237
|
-
# @return [Hash] response
|
238
|
-
def dm_destroy(dm_id)
|
239
|
-
begin
|
240
|
-
response = @access_token.post("http://api.twitter.com/1/direct_messages/destroy/#{dm_id}.xml")
|
241
|
-
rescue
|
242
|
-
return false
|
243
|
-
end
|
244
|
-
return response
|
245
|
-
end
|
246
|
-
|
247
|
-
# Check friendships
|
248
|
-
# @param [String] src source user
|
249
|
-
# @param [String] dst destination user
|
250
|
-
# @return [Boolean] return true if paired users have friendship, or ruturn false
|
251
|
-
def friendship_exists?(src, dst)
|
252
|
-
begin
|
253
|
-
response = @access_token.get("http://api.twitter.com/1/friendships/exists.xml?user_a=#{src}&user_b=#{dst}")
|
254
|
-
rescue
|
255
|
-
return false
|
256
|
-
end
|
257
|
-
doc = REXML::Document.new(response.body)
|
258
|
-
return false if doc.is_error?
|
259
|
-
if doc.elements["friends"].text() == "true" then
|
260
|
-
return true
|
261
|
-
else
|
262
|
-
return false
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
# Follow user for screen_name
|
267
|
-
# @param [String] name screen_name
|
268
|
-
# @return [Hash] response
|
269
|
-
def follow name
|
270
|
-
begin
|
271
|
-
response = @access_token.post("http://api.twitter.com/1/friendships/create/#{name}.xml")
|
272
|
-
rescue
|
273
|
-
return false
|
274
|
-
end
|
275
|
-
return response
|
276
|
-
end
|
277
|
-
|
278
|
-
# Unfollow user for screen_name
|
279
|
-
# @param [String] name screen_name
|
280
|
-
# @return [Hash] response
|
281
|
-
def unfollow name
|
282
|
-
begin
|
283
|
-
response = @access_token.post("http://api.twitter.com/1/friendships/destroy/#{name}.xml")
|
284
|
-
rescue
|
285
|
-
return false
|
286
|
-
end
|
287
|
-
return response
|
288
|
-
end
|
289
|
-
|
290
|
-
# @param [Fixnum] id id
|
291
|
-
# @return [Hash] response
|
292
|
-
def block(id)
|
293
|
-
begin
|
294
|
-
response = @access_token.post("http://api.twitter.com/1/blocks/create.xml?id=#{id}")
|
295
|
-
rescue
|
296
|
-
return false
|
297
|
-
end
|
298
|
-
return response
|
299
|
-
end
|
300
|
-
|
301
|
-
# @param [Fixnum] id id
|
302
|
-
# @return [Hash] response
|
303
|
-
def unblock(id)
|
304
|
-
begin
|
305
|
-
response = @access_token.post("http://api.twitter.com/1/blocks/destroy.xml?id=#{id}")
|
306
|
-
rescue
|
307
|
-
return false
|
308
|
-
end
|
309
|
-
return response
|
310
|
-
end
|
311
|
-
|
312
|
-
# @return [Hash] list of blocking users
|
313
|
-
def blocking
|
314
|
-
response = @access_token.get("http://api.twitter.com/1/blocks/blocking.xml")
|
315
|
-
doc = REXML::Document.new(response.body)
|
316
|
-
return false if doc.is_error?
|
317
|
-
users = Array.new
|
318
|
-
doc.get_elements('/users/user').each{|element|
|
319
|
-
user = User.new(element)
|
320
|
-
users << user
|
321
|
-
}
|
322
|
-
return users
|
323
|
-
end
|
324
|
-
|
325
|
-
# @param [Fixnum] id list id
|
326
|
-
# @param [String] ids id comma separated
|
327
|
-
# @return [Hash] response
|
328
|
-
def addlist(listid,ids)
|
329
|
-
response = @access_token.post("http://api.twitter.com/1/#{@username}/#{listid}/create_all.xml?user_id=#{ids}")
|
330
|
-
return response
|
331
|
-
end
|
332
|
-
|
333
|
-
# @return [Hash] lists
|
334
|
-
def lists
|
335
|
-
response = @access_token.get("http://api.twitter.com/1/#{@username}/lists.xml")
|
336
|
-
doc = REXML::Document.new(response.body)
|
337
|
-
return false if doc.is_error?
|
338
|
-
lists = Array.new
|
339
|
-
doc.get_elements('/lists_list/lists/list').each{|element|
|
340
|
-
list = List.new(element)
|
341
|
-
lists << list
|
342
|
-
}
|
343
|
-
return lists
|
344
|
-
end
|
345
|
-
|
346
|
-
|
347
|
-
def lists_member_create(listid,id)
|
348
|
-
begin
|
349
|
-
response = @access_token.post("http://api.twitter.com/1/#{@username}/#{listid}/members.xml?id=#{id}")
|
350
|
-
rescue
|
351
|
-
return false
|
352
|
-
else
|
353
|
-
return response
|
354
|
-
end
|
355
|
-
|
356
|
-
end
|
357
|
-
|
358
|
-
def lookup(param = [])
|
359
|
-
param_s = param.join(",")
|
360
|
-
begin
|
361
|
-
response = @access_token.get("http://api.twitter.com/1/users/lookup.xml?user_id="+param_s)
|
362
|
-
rescue
|
363
|
-
return false
|
364
|
-
end
|
365
|
-
doc = REXML::Document.new(response.body)
|
366
|
-
return false if doc.is_error?
|
367
|
-
users = Array.new
|
368
|
-
doc.get_elements('/users/user').each{|element|
|
369
|
-
user = User.new(element)
|
370
|
-
users << user
|
371
|
-
}
|
372
|
-
|
373
|
-
return users
|
374
|
-
end
|
375
|
-
|
376
|
-
def friends_ids(name)
|
377
|
-
begin
|
378
|
-
response = @access_token.get("http://api.twitter.com/1/friends/ids/#{name}.xml")
|
379
|
-
rescue
|
380
|
-
return false
|
381
|
-
end
|
382
|
-
doc = REXML::Document.new(response.body)
|
383
|
-
return false if doc.is_error?
|
384
|
-
ids = Array.new
|
385
|
-
|
386
|
-
doc.get_elements('/ids/id').each{|element|
|
387
|
-
ids << element.text()
|
388
|
-
}
|
389
|
-
|
390
|
-
return ids
|
391
|
-
end
|
392
|
-
|
393
|
-
def followers_ids(name)
|
394
|
-
begin
|
395
|
-
response = @access_token.get("http://api.twitter.com/1/followers/ids/#{name}.xml")
|
396
|
-
rescue
|
397
|
-
return false
|
398
|
-
end
|
399
|
-
doc = REXML::Document.new(response.body)
|
400
|
-
if doc.is_error? then
|
401
|
-
return doc.get_error_message
|
402
|
-
end
|
403
|
-
ids = Array.new
|
404
|
-
|
405
|
-
doc.get_elements('/ids/id').each{|element|
|
406
|
-
ids << element.text()
|
407
|
-
}
|
408
|
-
|
409
|
-
return ids
|
410
|
-
end
|
411
|
-
|
412
|
-
def rate_limit
|
413
|
-
begin
|
414
|
-
response = @access_token.get("http://api.twitter.com/1/account/rate_limit_status.xml")
|
415
|
-
rescue
|
416
|
-
return false
|
417
|
-
end
|
418
|
-
doc = REXML::Document.new(response.body)
|
419
|
-
return false if doc.is_error?
|
420
|
-
limit = doc.get_elements('/hash/hourly-limit').shift.text()
|
421
|
-
|
422
|
-
return limit
|
423
|
-
end
|
424
|
-
|
425
|
-
def update(status,irt='')
|
426
|
-
begin
|
427
|
-
response = @access_token.post(
|
428
|
-
'http://api.twitter.com/1/statuses/update.json',
|
429
|
-
'status'=> status,
|
430
|
-
'in_reply_to_status_id' => irt
|
431
|
-
)
|
432
|
-
rescue
|
433
|
-
return false
|
434
|
-
end
|
435
|
-
return response
|
436
|
-
end
|
437
|
-
|
438
|
-
def destroy(status_id)
|
439
|
-
begin
|
440
|
-
response = @access_token.post("http://api.twitter.com/1/statuses/destroy/#{status_id}.xml")
|
441
|
-
rescue
|
442
|
-
return false
|
443
|
-
end
|
444
|
-
return response
|
445
|
-
end
|
446
|
-
|
447
|
-
def update_location(location='')
|
448
|
-
location = URI.escape(location)
|
449
|
-
begin
|
450
|
-
response = @access_token.post("http://api.twitter.com/1/account/update_location.xml?location=#{location}")
|
451
|
-
rescue
|
452
|
-
return false
|
453
|
-
end
|
454
|
-
return response
|
455
|
-
end
|
456
|
-
|
457
|
-
class List
|
458
|
-
attr_reader :id
|
459
|
-
attr_reader :name
|
460
|
-
attr_reader :full_name
|
461
|
-
attr_reader :slug
|
462
|
-
attr_reader :description
|
463
|
-
attr_reader :subscriber_count
|
464
|
-
attr_reader :member_count
|
465
|
-
attr_reader :uri
|
466
|
-
attr_reader :following
|
467
|
-
attr_reader :mode
|
468
|
-
attr_reader :user
|
469
|
-
|
470
|
-
def initialize(element)
|
471
|
-
@id = element.elements['id'].text()
|
472
|
-
@name = element.elements['name'].text()
|
473
|
-
@full_name = element.elements['full_name'].text()
|
474
|
-
@slug = element.elements['slug'].text()
|
475
|
-
@description = element.elements['description'].text()
|
476
|
-
@subscriber_count = element.elements['subscriber_count'].text()
|
477
|
-
@member_count = element.elements['member_count'].text()
|
478
|
-
@uri = element.elements['uri'].text()
|
479
|
-
@following = element.elements['following'].text()
|
480
|
-
@mode = element.elements['mode'].text()
|
481
|
-
@user = User.new(element.elements['user'])
|
482
|
-
end
|
483
|
-
end
|
484
|
-
class DirectMessage
|
485
|
-
attr_reader :id
|
486
|
-
attr_reader :sender_id
|
487
|
-
attr_reader :text
|
488
|
-
attr_reader :recipient_id
|
489
|
-
attr_reader :created_at
|
490
|
-
attr_reader :sender_screen_name
|
491
|
-
attr_reader :recipient_screen_name
|
492
|
-
attr_reader :sender
|
493
|
-
attr_reader :recipient
|
494
|
-
|
495
|
-
def initialize(element)
|
496
|
-
@id = element.elements['id'].text()
|
497
|
-
@sender_id = element.elements['sender_id'].text()
|
498
|
-
@text = element.elements['text'].text()
|
499
|
-
@recipient_id = element.elements['recipient_id'].text()
|
500
|
-
@created_at = element.elements['created_at'].text()
|
501
|
-
@sender_screen_name = element.elements['sender_screen_name'].text()
|
502
|
-
@recipient_screen_name= element.elements['recipient_screen_name'].text()
|
503
|
-
@sender = User.new(element.elements['sender'])
|
504
|
-
@recipient = User.new(element.elements['recipient'])
|
505
|
-
end
|
506
|
-
end
|
507
|
-
class User
|
508
|
-
attr_reader :id
|
509
|
-
attr_reader :name
|
510
|
-
attr_reader :screen_name
|
511
|
-
attr_reader :description
|
512
|
-
attr_reader :url
|
513
|
-
attr_reader :followers_count
|
514
|
-
attr_reader :friends_count
|
515
|
-
attr_reader :statuses_count
|
516
|
-
attr_reader :location
|
517
|
-
attr_reader :profile_image_url
|
518
|
-
attr_reader :profile_background_color
|
519
|
-
attr_reader :profile_background_image_url
|
520
|
-
attr_reader :profile_background_tile
|
521
|
-
attr_reader :profile_text_color
|
522
|
-
attr_reader :profile_link_color
|
523
|
-
attr_reader :profile_sidebar_fill_color
|
524
|
-
attr_reader :profile_sidebar_border_color
|
525
|
-
attr_reader :protected
|
526
|
-
attr_reader :created_at
|
527
|
-
attr_reader :favourites_count
|
528
|
-
attr_reader :utc_offset
|
529
|
-
attr_reader :time_zone
|
530
|
-
attr_reader :notifications
|
531
|
-
attr_reader :geo_enabled
|
532
|
-
attr_reader :verified
|
533
|
-
attr_reader :lang
|
534
|
-
attr_reader :contributors_enabled
|
535
|
-
attr_reader :following
|
536
|
-
attr_reader :follow_request_sent
|
537
|
-
|
538
|
-
def initialize(element)
|
539
|
-
@id = element.elements['id'].text()
|
540
|
-
@name = element.elements['name'].text()
|
541
|
-
@screen_name = element.elements['screen_name'].text()
|
542
|
-
@location = element.elements['location'].text()
|
543
|
-
@description = element.elements['description'].text()
|
544
|
-
@profile_image_url = element.elements['profile_image_url'].text()
|
545
|
-
@url = element.elements['url'].text()
|
546
|
-
@protected = element.elements['protected'].text()
|
547
|
-
@followers_count = element.elements['followers_count'].text()
|
548
|
-
@friends_count = element.elements['friends_count'].text()
|
549
|
-
@profile_background_color = element.elements['profile_background_color'].text()
|
550
|
-
@profile_background_image_url = element.elements['profile_background_image_url'].text()
|
551
|
-
@profile_background_tile = element.elements['profile_background_tile'].text()
|
552
|
-
@profile_text_color = element.elements['profile_text_color'].text()
|
553
|
-
@profile_link_color = element.elements['profile_link_color'].text()
|
554
|
-
@profile_sidebar_fill_color = element.elements['profile_sidebar_fill_color'].text()
|
555
|
-
@profile_sidebar_border_color = element.elements['profile_sidebar_border_color'].text()
|
556
|
-
@statuses_count = element.elements['statuses_count'].text()
|
557
|
-
@created_at = element.elements['created_at'].text()
|
558
|
-
@favourites_count = element.elements['favourites_count'].text()
|
559
|
-
@utc_offset = element.elements['utc_offset'].text()
|
560
|
-
@time_zone = element.elements['time_zone'].text()
|
561
|
-
@notifications = element.elements['notifications'].text()
|
562
|
-
@geo_enabled = element.elements['geo_enabled'].text()
|
563
|
-
@verified = element.elements['verified'].text()
|
564
|
-
@lang = element.elements['lang'].text()
|
565
|
-
@contributors_enabled = element.elements['contributors_enabled'].text()
|
566
|
-
@following = element.elements['following'].text()
|
567
|
-
@follow_request_sent = element.elements['follow_request_sent'].text()
|
568
|
-
end
|
569
|
-
end
|
570
|
-
|
571
|
-
class Status
|
572
|
-
attr_reader :created_at
|
573
|
-
attr_reader :id
|
574
|
-
attr_reader :text
|
575
|
-
attr_reader :source
|
576
|
-
attr_reader :truncated
|
577
|
-
attr_reader :in_reply_to_status_id
|
578
|
-
attr_reader :in_reply_to_user_id
|
579
|
-
attr_reader :in_reply_to_screen_name
|
580
|
-
attr_reader :favorited
|
581
|
-
attr_reader :user
|
582
|
-
attr_reader :geo
|
583
|
-
attr_reader :place
|
584
|
-
attr_reader :coordinates
|
585
|
-
attr_reader :contributors
|
586
|
-
attr_reader :annotations
|
587
|
-
attr_reader :entities
|
588
|
-
|
589
|
-
def initialize(element)
|
590
|
-
@created_at = element.elements['created_at'].text()
|
591
|
-
@id = element.elements['id'].text()
|
592
|
-
@text = element.elements['text'].text()
|
593
|
-
@source = element.elements['source'].text()
|
594
|
-
@truncated = element.elements['truncated'].text()
|
595
|
-
@in_reply_to_status_id = element.elements['in_reply_to_status_id'].text()
|
596
|
-
@in_reply_to_user_id = element.elements['in_reply_to_user_id'].text()
|
597
|
-
@in_reply_to_screen_name = element.elements['in_reply_to_screen_name'].text()
|
598
|
-
@favorited = element.elements['favorited'].text()
|
599
|
-
@user = User.new(element.elements['user'])
|
600
|
-
@geo = element.elements['geo'].text()
|
601
|
-
@place = element.elements['place'].text()
|
602
|
-
@coordinates = (element.elements['coordinates'].nil?) ? nil : element.elements['coordinates'].text()
|
603
|
-
@contributors = (element.elements['contributors'].nil?) ? nil : element.elements['contributors'].text()
|
604
|
-
@annotations = (element.elements['annotations'].nil?) ? nil : element.elements['annotations'].text()
|
605
|
-
@entities = (element.elements['entities'].nil?) ? nil : Entities.new(element.elements['entities'])
|
606
|
-
end
|
607
|
-
end
|
608
|
-
|
609
|
-
class Entities
|
610
|
-
attr_reader :user_mentions
|
611
|
-
attr_reader :urls
|
612
|
-
attr_reader :hashtags
|
613
|
-
|
614
|
-
def initialize(element)
|
615
|
-
@user_mentions = UserMention.new(element.elements['user_mention'])
|
616
|
-
@urls = URL.new(element.elements['urls'])
|
617
|
-
@hashtags = Hashtag.new(element.elements['hashtags'])
|
618
|
-
end
|
619
|
-
end
|
620
|
-
|
621
|
-
class UserMention
|
622
|
-
attr_reader :id
|
623
|
-
attr_reader :screen_name
|
624
|
-
attr_reader :name
|
625
|
-
attr_reader :start
|
626
|
-
attr_reader :end
|
627
|
-
|
628
|
-
def initialize(element)
|
629
|
-
@id = element.elements['id'].text()
|
630
|
-
@screen_name = element.elements['screen_name'].text()
|
631
|
-
@name = element.elements['name'].text()
|
632
|
-
@start = element.attributes['start']
|
633
|
-
@end = element.attributes['end']
|
634
|
-
end
|
635
|
-
end
|
636
|
-
|
637
|
-
class URL
|
638
|
-
attr_reader :url
|
639
|
-
attr_reader :expanded_url
|
640
|
-
attr_reader :start
|
641
|
-
attr_reader :end
|
642
|
-
|
643
|
-
def initialize(element)
|
644
|
-
@url = element.elements['url'].text()
|
645
|
-
@expanded_url = element.elements['expanded_url'].text()
|
646
|
-
@start = element.attributes['start']
|
647
|
-
@end = element.attributes['end']
|
648
|
-
end
|
649
|
-
end
|
650
|
-
|
651
|
-
class Hashtag
|
652
|
-
attr_reader :text
|
653
|
-
attr_reader :start
|
654
|
-
attr_reader :end
|
655
|
-
|
656
|
-
def initialize(element)
|
657
|
-
@text = element.elements['text'].text()
|
658
|
-
@start = element.attributes['start']
|
659
|
-
@end = element.attributes['end']
|
660
|
-
end
|
661
|
-
end
|
662
|
-
end
|
3
|
+
require "net/http"
|
4
|
+
require "uri"
|
5
|
+
require "pp"
|
6
|
+
require "rubygems" if RUBY_VERSION < "1.9.0"
|
7
|
+
require "json"
|
8
|
+
require "oauth"
|
9
|
+
|
10
|
+
$LOAD_PATH << File.dirname(File.expand_path(__FILE__)) if RUBY_VERSION >= "1.9.0"
|
11
|
+
require "pupil/base"
|
12
|
+
require "pupil/schemes"
|
13
|
+
require "pupil/account"
|
14
|
+
require "pupil/statuses"
|
15
|
+
require "pupil/users"
|
16
|
+
require "pupil/direct_messages"
|
17
|
+
require "pupil/lists"
|
18
|
+
require "pupil/friendships"
|
19
|
+
require "pupil/blocks"
|
20
|
+
require "pupil/stream"
|