tjplurker 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tjplurker.rb +21 -2
- metadata +5 -5
data/lib/tjplurker.rb
CHANGED
@@ -61,6 +61,26 @@ class TJPlurker
|
|
61
61
|
api(method, attr)
|
62
62
|
end
|
63
63
|
|
64
|
+
# This method is provided by TJPlurker.
|
65
|
+
# +max+:: The maximum number of your request
|
66
|
+
# +return+:: An array contains friends
|
67
|
+
def get_friend_list user_id, max=nil
|
68
|
+
list = []
|
69
|
+
offset = 0;
|
70
|
+
loop{
|
71
|
+
set = get_friends_by_offset(user_id, 100, offset)
|
72
|
+
size = set.size
|
73
|
+
puts size
|
74
|
+
break if size == 0
|
75
|
+
list |= set
|
76
|
+
break if max && list.size>max
|
77
|
+
offset += size
|
78
|
+
}
|
79
|
+
return list
|
80
|
+
end
|
81
|
+
|
82
|
+
# This maximum limit is set 100 officially, this method is not that useful.
|
83
|
+
# We suggest you use get_friend_list instead of get_friends_by_offset.
|
64
84
|
def get_friends_by_offset user_id, limit=100, offset='0'
|
65
85
|
method = "/API/FriendsFans/getFriendsByOffset"
|
66
86
|
attr = {:api_key=>@api_key, :user_id=>user_id, :offset=>offset, :limit=>limit}
|
@@ -138,7 +158,7 @@ class TJPlurker
|
|
138
158
|
@cookie ||= resp['set-cookie']
|
139
159
|
json = JSON.parse(resp.body)
|
140
160
|
$tjpLog.debug(self.class){"Response: #{json}"}
|
141
|
-
$tjpLog.error(self.class){json["error_text"]} if json["error_text"]
|
161
|
+
$tjpLog.error(self.class){json["error_text"]} if json.is_a?(Hash) && json["error_text"]
|
142
162
|
rescue Timeout::Error => ex
|
143
163
|
$tjpLog.warn(self.class){"Request timeout, retrying."}
|
144
164
|
retry
|
@@ -272,7 +292,6 @@ class TJPlurker
|
|
272
292
|
|
273
293
|
class ThreadService < Service
|
274
294
|
# +lasting+:: How long in second will a thread lives. If one plurk just be responsed, then it will live another +lasting+ time.
|
275
|
-
#
|
276
295
|
# +refresh+:: Interval that checks if thread should terminate.
|
277
296
|
def initialize name=self.class.to_s, lasting=60, refresh=1, &proc
|
278
297
|
super name
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tjplurker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-07-11 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
|
-
requirement: &
|
16
|
+
requirement: &18855720 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 1.4.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *18855720
|
25
25
|
description: A safe Plurk API wrapper based on Ruby and mainly designed for easily
|
26
26
|
making plurk robot.
|
27
27
|
email: tonytonyjan.cs97@g2.nctu.edu.tw
|
@@ -50,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
50
|
version: '0'
|
51
51
|
requirements: []
|
52
52
|
rubyforge_project:
|
53
|
-
rubygems_version: 1.8.
|
53
|
+
rubygems_version: 1.8.5
|
54
54
|
signing_key:
|
55
55
|
specification_version: 3
|
56
56
|
summary: A safe Plurk API wrapper based on Ruby and mainly designed for easily making
|