tjplurker 1.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tjplurker.rb +19 -4
- metadata +6 -5
data/lib/tjplurker.rb
CHANGED
@@ -129,7 +129,7 @@ class TJPlurker
|
|
129
129
|
http = Net::HTTP.new('www.plurk.com', 80)
|
130
130
|
begin
|
131
131
|
resp = http.start{
|
132
|
-
$tjpLog.
|
132
|
+
$tjpLog.debug(self.class){"Request: #{method}, #{attr}"}
|
133
133
|
http.request(req)
|
134
134
|
}
|
135
135
|
@cookie ||= resp['set-cookie']
|
@@ -211,19 +211,34 @@ class TJPlurker
|
|
211
211
|
loop{
|
212
212
|
@tjplurker.comet_channel{|data|
|
213
213
|
@services.each{|service|
|
214
|
-
|
214
|
+
begin
|
215
|
+
service.serve(@tjplurker, data)
|
216
|
+
rescue => ex
|
217
|
+
$tjpLog.error(self.class){"An error occured in #{service.class}, message:\n#{ex.message}"}
|
218
|
+
end
|
215
219
|
}
|
216
220
|
}
|
217
221
|
}
|
218
222
|
end
|
219
223
|
|
220
224
|
def add_service service
|
221
|
-
|
225
|
+
if service.is_a? Service
|
226
|
+
@services << service
|
227
|
+
$tjpLog.info(self.class){"Add service: #{service.name}"}
|
228
|
+
elsif service <= Service
|
229
|
+
tmp = service.new
|
230
|
+
@services << tmp
|
231
|
+
$tjpLog.info(self.class){"Add service: #{tmp.name}"}
|
232
|
+
else
|
233
|
+
$tjpLog.warn(self.class){"Unrecognized service, ignored."}
|
234
|
+
end
|
222
235
|
end
|
223
236
|
end
|
224
237
|
|
225
238
|
class Service
|
226
|
-
|
239
|
+
attr_reader :name
|
240
|
+
def initialize name=self.class.to_s,&proc
|
241
|
+
@name = name
|
227
242
|
if block_given?
|
228
243
|
@serve = proc
|
229
244
|
else
|
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:
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-05-
|
12
|
+
date: 2011-05-24 00:00:00.000000000 +08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
17
|
-
requirement: &
|
17
|
+
requirement: &18733956 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,8 +22,9 @@ dependencies:
|
|
22
22
|
version: 1.4.2
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
26
|
-
description:
|
25
|
+
version_requirements: *18733956
|
26
|
+
description: A safe Plurk API wrapper based on Ruby and mainly designed for easily
|
27
|
+
making plurk robot.
|
27
28
|
email: tonytonyjan.cs97@g2.nctu.edu.tw
|
28
29
|
executables: []
|
29
30
|
extensions: []
|