rhaiker 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.ja.txt +4 -0
- data/History.txt +6 -0
- data/lib/rhaiker.rb +71 -163
- data/lib/rhaiker/utils.rb +4 -2
- data/lib/rhaiker/version.rb +1 -1
- data/spec/rhaiker_spec.rb +1 -1
- data/website/index.html +1 -1
- metadata +3 -3
data/History.ja.txt
CHANGED
data/History.txt
CHANGED
data/lib/rhaiker.rb
CHANGED
|
@@ -26,7 +26,7 @@ class Rhaiker
|
|
|
26
26
|
attr_accessor :source
|
|
27
27
|
|
|
28
28
|
# Hatena::Haiku::API BaseURL
|
|
29
|
-
|
|
29
|
+
BASE_ADDRESS = 'http://h.hatena.ne.jp/api/'
|
|
30
30
|
# Utilities.
|
|
31
31
|
include Utils
|
|
32
32
|
# Customized XML Parser for
|
|
@@ -44,7 +44,7 @@ Description::
|
|
|
44
44
|
Hatena::Haiku::API[http://h.hatena.ne.jp/api#statuses-public_timeline]
|
|
45
45
|
|
|
46
46
|
Return::
|
|
47
|
-
timeline ([{:id => 12345, ...}, ...])
|
|
47
|
+
timeline ([{:id => 12345, ...}, ...])
|
|
48
48
|
|
|
49
49
|
RelatedMethods::
|
|
50
50
|
Utils#create_uri,
|
|
@@ -54,16 +54,12 @@ RelatedMethods::
|
|
|
54
54
|
=end
|
|
55
55
|
def get_public_timeline
|
|
56
56
|
uri = create_uri(
|
|
57
|
-
|
|
57
|
+
BASE_ADDRESS +
|
|
58
58
|
'statuses/public_timeline.xml'
|
|
59
59
|
)
|
|
60
60
|
request = create_request(:get, uri)
|
|
61
61
|
document = http_access(uri, request)
|
|
62
|
-
|
|
63
|
-
return parse_timeline(document)
|
|
64
|
-
else
|
|
65
|
-
return false
|
|
66
|
-
end
|
|
62
|
+
return parse_timeline(document)
|
|
67
63
|
end
|
|
68
64
|
|
|
69
65
|
=begin rdoc
|
|
@@ -76,7 +72,7 @@ Params::
|
|
|
76
72
|
options ({:count => 20, [...]})]
|
|
77
73
|
|
|
78
74
|
Return::
|
|
79
|
-
timeline ([{:id => 12345, ...}, ...])
|
|
75
|
+
timeline ([{:id => 12345, ...}, ...])
|
|
80
76
|
|
|
81
77
|
RelatedMethods::
|
|
82
78
|
Utils#create_uri,
|
|
@@ -86,17 +82,13 @@ RelatedMethods::
|
|
|
86
82
|
XML_Parser#parse_timeline,
|
|
87
83
|
=end
|
|
88
84
|
def get_friends_timeline(user_id = nil, options = nil)
|
|
89
|
-
uri_base =
|
|
85
|
+
uri_base = BASE_ADDRESS + 'statuses/friends_timeline'
|
|
90
86
|
uri_base += user_id ? "/#{user_id}.xml" : '.xml'
|
|
91
87
|
uri_base += parse_options(options) if options
|
|
92
88
|
uri = create_uri(uri_base)
|
|
93
89
|
request = create_request(:get, uri, user_id.nil?)
|
|
94
90
|
document = http_access(uri, request)
|
|
95
|
-
|
|
96
|
-
return parse_timeline(document)
|
|
97
|
-
else
|
|
98
|
-
return false
|
|
99
|
-
end
|
|
91
|
+
return parse_timeline(document)
|
|
100
92
|
end
|
|
101
93
|
|
|
102
94
|
=begin rdoc
|
|
@@ -109,7 +101,7 @@ Params::
|
|
|
109
101
|
options ({:count => 20, [...]})]
|
|
110
102
|
|
|
111
103
|
Return::
|
|
112
|
-
timeline ([{:id => 12345, ...}, ...])
|
|
104
|
+
timeline ([{:id => 12345, ...}, ...])
|
|
113
105
|
|
|
114
106
|
RelatedMethods::
|
|
115
107
|
Utils#create_uri,
|
|
@@ -119,17 +111,13 @@ RelatedMethods::
|
|
|
119
111
|
XML_Parser#parse_timeline,
|
|
120
112
|
=end
|
|
121
113
|
def get_user_timeline(user_id = nil, options = nil)
|
|
122
|
-
uri_base =
|
|
114
|
+
uri_base = BASE_ADDRESS + 'statuses/user_timeline'
|
|
123
115
|
uri_base += user_id ? "/#{user_id}.xml" : '.xml'
|
|
124
116
|
uri_base += parse_options(options) if options
|
|
125
117
|
uri = create_uri(uri_base)
|
|
126
118
|
request = create_request(:get, uri, user_id.nil?)
|
|
127
119
|
document = http_access(uri, request)
|
|
128
|
-
|
|
129
|
-
return parse_timeline(document)
|
|
130
|
-
else
|
|
131
|
-
return false
|
|
132
|
-
end
|
|
120
|
+
return parse_timeline(document)
|
|
133
121
|
end
|
|
134
122
|
|
|
135
123
|
=begin rdoc
|
|
@@ -142,7 +130,7 @@ Params::
|
|
|
142
130
|
options ({:count => 20, [...]})]
|
|
143
131
|
|
|
144
132
|
Return::
|
|
145
|
-
timeline ([{:id => 12345, ...}, ...])
|
|
133
|
+
timeline ([{:id => 12345, ...}, ...])
|
|
146
134
|
|
|
147
135
|
RelatedMethods::
|
|
148
136
|
Utils#create_uri,
|
|
@@ -152,18 +140,14 @@ RelatedMethods::
|
|
|
152
140
|
XML_Parser#parse_timeline
|
|
153
141
|
=end
|
|
154
142
|
def get_keyword_timeline(keyword, options = nil)
|
|
155
|
-
uri_base =
|
|
143
|
+
uri_base = BASE_ADDRESS +
|
|
156
144
|
'statuses/keyword_timeline/' +
|
|
157
145
|
keyword + '.xml'
|
|
158
146
|
uri_base += parse_options(options) if options
|
|
159
147
|
uri = create_uri(uri_base)
|
|
160
148
|
request = create_request(:get, uri)
|
|
161
149
|
document = http_access(uri, request)
|
|
162
|
-
|
|
163
|
-
return parse_timeline(document)
|
|
164
|
-
else
|
|
165
|
-
return false
|
|
166
|
-
end
|
|
150
|
+
return parse_timeline(document)
|
|
167
151
|
end
|
|
168
152
|
|
|
169
153
|
=begin rdoc
|
|
@@ -175,7 +159,7 @@ Params::
|
|
|
175
159
|
keyword (target keyword)
|
|
176
160
|
|
|
177
161
|
Return::
|
|
178
|
-
timeline ([{:id => 12345, ...}, ...])
|
|
162
|
+
timeline ([{:id => 12345, ...}, ...])
|
|
179
163
|
|
|
180
164
|
RelatedMethods::
|
|
181
165
|
Utils#create_uri,
|
|
@@ -185,16 +169,12 @@ RelatedMethods::
|
|
|
185
169
|
XML_Parser#parse_timeline
|
|
186
170
|
=end
|
|
187
171
|
def get_album(keyword = nil)
|
|
188
|
-
uri_base =
|
|
172
|
+
uri_base = BASE_ADDRESS + 'statuses/album'
|
|
189
173
|
uri_base += keyword ? "/#{keyword}.xml" : '.xml'
|
|
190
174
|
uri = create_uri(uri_base)
|
|
191
175
|
request = create_request(:get, uri)
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
return parse_timeline(document)
|
|
195
|
-
else
|
|
196
|
-
return false
|
|
197
|
-
end
|
|
176
|
+
http_access(uri, request)
|
|
177
|
+
return parse_timeline(document)
|
|
198
178
|
end
|
|
199
179
|
|
|
200
180
|
=begin rdoc
|
|
@@ -206,7 +186,7 @@ Params::
|
|
|
206
186
|
status_id (target status_id)
|
|
207
187
|
|
|
208
188
|
Return::
|
|
209
|
-
status ({:id => 12345, ...})
|
|
189
|
+
status ({:id => 12345, ...})
|
|
210
190
|
|
|
211
191
|
RelatedMethods::
|
|
212
192
|
Utils#create_uri,
|
|
@@ -216,17 +196,13 @@ RelatedMethods::
|
|
|
216
196
|
=end
|
|
217
197
|
def get_status(status_id)
|
|
218
198
|
uri = create_uri(
|
|
219
|
-
|
|
199
|
+
BASE_ADDRESS +
|
|
220
200
|
'statuses/show/' +
|
|
221
201
|
status_id.to_s + '.xml'
|
|
222
202
|
)
|
|
223
203
|
request = create_request(:get, uri)
|
|
224
204
|
document = http_access(uri, request)
|
|
225
|
-
|
|
226
|
-
return parse_status(document.root)
|
|
227
|
-
else
|
|
228
|
-
return false
|
|
229
|
-
end
|
|
205
|
+
return parse_status(document.root)
|
|
230
206
|
end
|
|
231
207
|
|
|
232
208
|
=begin rdoc
|
|
@@ -238,7 +214,7 @@ Params::
|
|
|
238
214
|
user_id (target user_id)
|
|
239
215
|
|
|
240
216
|
Return::
|
|
241
|
-
users ([{:name => 'hoge', ...}, ...])
|
|
217
|
+
users ([{:name => 'hoge', ...}, ...])
|
|
242
218
|
|
|
243
219
|
RelatedMethods::
|
|
244
220
|
Utils#create_uri,
|
|
@@ -247,16 +223,12 @@ RelatedMethods::
|
|
|
247
223
|
XML_Parser#parse_users
|
|
248
224
|
=end
|
|
249
225
|
def get_friends(user_id = nil)
|
|
250
|
-
uri_base =
|
|
226
|
+
uri_base = BASE_ADDRESS + 'statuses/friends'
|
|
251
227
|
uri_base += user_id ? "/#{user_id}.xml" : '.xml'
|
|
252
228
|
uri = create_uri(uri_base)
|
|
253
229
|
request = create_request(:get, uri, user_id.nil?)
|
|
254
230
|
document = http_access(uri, request)
|
|
255
|
-
|
|
256
|
-
return parse_users(document)
|
|
257
|
-
else
|
|
258
|
-
return false
|
|
259
|
-
end
|
|
231
|
+
return parse_users(document)
|
|
260
232
|
end
|
|
261
233
|
|
|
262
234
|
=begin rdoc
|
|
@@ -268,7 +240,7 @@ Params::
|
|
|
268
240
|
user_id (target user_id)
|
|
269
241
|
|
|
270
242
|
Return::
|
|
271
|
-
users ([{:name => 'hoge', ...}, ...])
|
|
243
|
+
users ([{:name => 'hoge', ...}, ...])
|
|
272
244
|
|
|
273
245
|
RelatedMethods::
|
|
274
246
|
Utils#create_uri,
|
|
@@ -277,16 +249,12 @@ RelatedMethods::
|
|
|
277
249
|
XML_Parser#parse_users
|
|
278
250
|
=end
|
|
279
251
|
def get_followers(user_id = nil)
|
|
280
|
-
uri_base =
|
|
252
|
+
uri_base = BASE_ADDRESS + 'statuses/followers'
|
|
281
253
|
uri_base += user_id ? "/#{user_id}.xml" : '.xml'
|
|
282
254
|
uri = create_uri(uri_base)
|
|
283
255
|
request = create_request(:get, uri, user_id.nil?)
|
|
284
256
|
document = http_access(uri, request)
|
|
285
|
-
|
|
286
|
-
return parse_users(document)
|
|
287
|
-
else
|
|
288
|
-
return false
|
|
289
|
-
end
|
|
257
|
+
return parse_users(document)
|
|
290
258
|
end
|
|
291
259
|
|
|
292
260
|
=begin rdoc
|
|
@@ -298,7 +266,7 @@ Params::
|
|
|
298
266
|
user_id (target user_id)
|
|
299
267
|
|
|
300
268
|
Return::
|
|
301
|
-
user ({:name => 'hoge', ...})
|
|
269
|
+
user ({:name => 'hoge', ...})
|
|
302
270
|
|
|
303
271
|
RelatedMethods::
|
|
304
272
|
Utils#create_uri,
|
|
@@ -308,17 +276,13 @@ RelatedMethods::
|
|
|
308
276
|
=end
|
|
309
277
|
def get_friend(user_id)
|
|
310
278
|
uri = create_uri(
|
|
311
|
-
|
|
279
|
+
BASE_ADDRESS +
|
|
312
280
|
'friendships/show/' +
|
|
313
281
|
user_id + '.xml'
|
|
314
282
|
)
|
|
315
283
|
request = create_request(:get, uri)
|
|
316
284
|
document = http_access(uri, request)
|
|
317
|
-
|
|
318
|
-
return parse_user(document.root)
|
|
319
|
-
else
|
|
320
|
-
return false
|
|
321
|
-
end
|
|
285
|
+
return parse_user(document.root)
|
|
322
286
|
end
|
|
323
287
|
|
|
324
288
|
=begin rdoc
|
|
@@ -327,7 +291,7 @@ Description::
|
|
|
327
291
|
Hatena::Haiku::API[http://h.hatena.ne.jp/api#keywords-hot]
|
|
328
292
|
|
|
329
293
|
Return::
|
|
330
|
-
keywords ([{:title => 'hoge', ...}, ...])
|
|
294
|
+
keywords ([{:title => 'hoge', ...}, ...])
|
|
331
295
|
|
|
332
296
|
RelatedMethods::
|
|
333
297
|
Utils#create_uri,
|
|
@@ -336,14 +300,10 @@ RelatedMethods::
|
|
|
336
300
|
XML_Parser#parse_keywords
|
|
337
301
|
=end
|
|
338
302
|
def get_hot_keywords
|
|
339
|
-
uri = create_uri(
|
|
303
|
+
uri = create_uri(BASE_ADDRESS + 'keywords/hot.xml')
|
|
340
304
|
request = create_request(:get, uri)
|
|
341
305
|
document = http_access(uri, request)
|
|
342
|
-
|
|
343
|
-
return parse_keywords(document)
|
|
344
|
-
else
|
|
345
|
-
return false
|
|
346
|
-
end
|
|
306
|
+
return parse_keywords(document)
|
|
347
307
|
end
|
|
348
308
|
|
|
349
309
|
=begin rdoc
|
|
@@ -355,7 +315,7 @@ Params::
|
|
|
355
315
|
options => {:page => pagenum}
|
|
356
316
|
|
|
357
317
|
Return::
|
|
358
|
-
keywords ([{:title => 'hoge', ...}, ...])
|
|
318
|
+
keywords ([{:title => 'hoge', ...}, ...])
|
|
359
319
|
|
|
360
320
|
RelatedMethods::
|
|
361
321
|
Utils#create_uri,
|
|
@@ -365,16 +325,12 @@ RelatedMethods::
|
|
|
365
325
|
XML_Parser#parse_keywords
|
|
366
326
|
=end
|
|
367
327
|
def get_keyword_list(options = nil)
|
|
368
|
-
uri_base =
|
|
328
|
+
uri_base = BASE_ADDRESS + 'keywords/list.xml'
|
|
369
329
|
uri_base += parse_options(options) if options
|
|
370
330
|
uri = create_uri(uri_base)
|
|
371
331
|
request = create_request(:get, uri)
|
|
372
332
|
document = http_access(uri, request)
|
|
373
|
-
|
|
374
|
-
return parse_keywords(document)
|
|
375
|
-
else
|
|
376
|
-
return false
|
|
377
|
-
end
|
|
333
|
+
return parse_keywords(document)
|
|
378
334
|
end
|
|
379
335
|
|
|
380
336
|
=begin rdoc
|
|
@@ -386,7 +342,7 @@ Params::
|
|
|
386
342
|
user_id (target user_id)
|
|
387
343
|
|
|
388
344
|
Return::
|
|
389
|
-
keywords ([{:title => 'hoge', ...}, ...])
|
|
345
|
+
keywords ([{:title => 'hoge', ...}, ...])
|
|
390
346
|
|
|
391
347
|
RelatedMethods::
|
|
392
348
|
Utils#create_uri
|
|
@@ -395,16 +351,12 @@ RelatedMethods::
|
|
|
395
351
|
XML_Parser#parse_keywords
|
|
396
352
|
=end
|
|
397
353
|
def get_keywords(user_id = nil)
|
|
398
|
-
uri_base =
|
|
354
|
+
uri_base = BASE_ADDRESS + 'statuses/keywrods'
|
|
399
355
|
uri_base += user_id ? "/#{user_id}.xml" : '.xml'
|
|
400
356
|
uri = create_uri(uri_base)
|
|
401
357
|
request = create_request(:get, uri, user_id.nil?)
|
|
402
358
|
document = http_access(uri, request)
|
|
403
|
-
|
|
404
|
-
return parse_timeline(document)
|
|
405
|
-
else
|
|
406
|
-
return false
|
|
407
|
-
end
|
|
359
|
+
return parse_timeline(document)
|
|
408
360
|
end
|
|
409
361
|
|
|
410
362
|
=begin rdoc
|
|
@@ -416,7 +368,7 @@ Params::
|
|
|
416
368
|
keyword (target keyword)
|
|
417
369
|
|
|
418
370
|
Return::
|
|
419
|
-
keyword ({:title => 'hoge', ...})
|
|
371
|
+
keyword ({:title => 'hoge', ...})
|
|
420
372
|
|
|
421
373
|
RelatedMethods::
|
|
422
374
|
Utils#create_uri,
|
|
@@ -426,17 +378,13 @@ RelatedMethods::
|
|
|
426
378
|
=end
|
|
427
379
|
def get_keyword(keyword)
|
|
428
380
|
uri = create_uri(
|
|
429
|
-
|
|
381
|
+
BASE_ADDRESS +
|
|
430
382
|
'keywords/show/' +
|
|
431
383
|
keyword + 'xml'
|
|
432
384
|
)
|
|
433
385
|
request = create_request(:get, uri)
|
|
434
386
|
document = http_access(uri, request)
|
|
435
|
-
|
|
436
|
-
return parse_keyword(document.root)
|
|
437
|
-
else
|
|
438
|
-
return false
|
|
439
|
-
end
|
|
387
|
+
return parse_keyword(document.root)
|
|
440
388
|
end
|
|
441
389
|
|
|
442
390
|
=begin rdoc
|
|
@@ -448,7 +396,7 @@ Params::
|
|
|
448
396
|
options ({:status => 'hoge', ...}]
|
|
449
397
|
|
|
450
398
|
Return::
|
|
451
|
-
status ({:text => 'hoge', ...})
|
|
399
|
+
status ({:text => 'hoge', ...})
|
|
452
400
|
|
|
453
401
|
RelatedMethods::
|
|
454
402
|
Utils#create_uri,
|
|
@@ -461,17 +409,13 @@ Notes::
|
|
|
461
409
|
Still does not support of 'Upload Image File'
|
|
462
410
|
=end
|
|
463
411
|
def status_update(options)
|
|
464
|
-
uri_base =
|
|
412
|
+
uri_base = BASE_ADDRESS + 'statuses/update.xml'
|
|
465
413
|
uri_base += parse_options(options)
|
|
466
414
|
uri_base += '&source=' + @source
|
|
467
415
|
uri = create_uri(uri_base)
|
|
468
416
|
request = create_request(:post, uri, true)
|
|
469
417
|
document = http_access(uri, request)
|
|
470
|
-
|
|
471
|
-
return parse_status(document.root)
|
|
472
|
-
else
|
|
473
|
-
return false
|
|
474
|
-
end
|
|
418
|
+
return parse_status(document.root)
|
|
475
419
|
end
|
|
476
420
|
|
|
477
421
|
=begin rdoc
|
|
@@ -483,7 +427,7 @@ Params::
|
|
|
483
427
|
status_id (target status_id)
|
|
484
428
|
|
|
485
429
|
Return::
|
|
486
|
-
status ({:text => 'hoge', ...})
|
|
430
|
+
status ({:text => 'hoge', ...})
|
|
487
431
|
|
|
488
432
|
RelationMethods::
|
|
489
433
|
create_uri,
|
|
@@ -493,17 +437,13 @@ RelationMethods::
|
|
|
493
437
|
=end
|
|
494
438
|
def status_destroy(status_id)
|
|
495
439
|
uri = create_uri(
|
|
496
|
-
|
|
440
|
+
BASE_ADDRESS +
|
|
497
441
|
'statuses/status/destroy/' +
|
|
498
442
|
status_id.to_s + '.xml'
|
|
499
443
|
)
|
|
500
444
|
request = create_request(:post, uri, true)
|
|
501
445
|
document = http_access(uri, request)
|
|
502
|
-
|
|
503
|
-
return parse_status(document.root)
|
|
504
|
-
else
|
|
505
|
-
return false
|
|
506
|
-
end
|
|
446
|
+
return parse_status(document.root)
|
|
507
447
|
end
|
|
508
448
|
|
|
509
449
|
=begin rdoc
|
|
@@ -515,7 +455,7 @@ Params::
|
|
|
515
455
|
user_id (target user_id)
|
|
516
456
|
|
|
517
457
|
Return::
|
|
518
|
-
user ({:id => 'hoge', ...})
|
|
458
|
+
user ({:id => 'hoge', ...})
|
|
519
459
|
|
|
520
460
|
RelatedMethods::
|
|
521
461
|
Utils#create_uri,
|
|
@@ -525,17 +465,13 @@ RelatedMethods::
|
|
|
525
465
|
=end
|
|
526
466
|
def friendship_create(user_id)
|
|
527
467
|
uri = create_uri(
|
|
528
|
-
|
|
468
|
+
BASE_ADDRESS +
|
|
529
469
|
'friendships/create/' +
|
|
530
470
|
user_id + '.xml'
|
|
531
471
|
)
|
|
532
472
|
request = create_request(:post, uri, true)
|
|
533
473
|
document = http_access(uri, request)
|
|
534
|
-
|
|
535
|
-
return parse_user(document.root)
|
|
536
|
-
else
|
|
537
|
-
return false
|
|
538
|
-
end
|
|
474
|
+
return parse_user(document.root)
|
|
539
475
|
end
|
|
540
476
|
|
|
541
477
|
=begin rdoc
|
|
@@ -547,7 +483,7 @@ Params::
|
|
|
547
483
|
user_id (target user_id)
|
|
548
484
|
|
|
549
485
|
Return::
|
|
550
|
-
user ({:id => 'hoge', ...})
|
|
486
|
+
user ({:id => 'hoge', ...})
|
|
551
487
|
|
|
552
488
|
RelatedMethods::
|
|
553
489
|
Utils#create_uri,
|
|
@@ -557,17 +493,13 @@ RelatedMethods::
|
|
|
557
493
|
=end
|
|
558
494
|
def friendship_destroy(user_id)
|
|
559
495
|
uri = create_uri(
|
|
560
|
-
|
|
496
|
+
BASE_ADDRESS +
|
|
561
497
|
'friendships/destroy/' +
|
|
562
498
|
user_id + '.xml'
|
|
563
499
|
)
|
|
564
500
|
request = create_request(:post, uri, true)
|
|
565
501
|
document = http_access(uri, request)
|
|
566
|
-
|
|
567
|
-
return parse_user(document.root)
|
|
568
|
-
else
|
|
569
|
-
return false
|
|
570
|
-
end
|
|
502
|
+
return parse_user(document.root)
|
|
571
503
|
end
|
|
572
504
|
|
|
573
505
|
=begin rdoc
|
|
@@ -579,7 +511,7 @@ Params::
|
|
|
579
511
|
status_id (target status_id)
|
|
580
512
|
|
|
581
513
|
Return::
|
|
582
|
-
status ({:text => 'hoge', ...})
|
|
514
|
+
status ({:text => 'hoge', ...})
|
|
583
515
|
|
|
584
516
|
RelatedMethods::
|
|
585
517
|
Utils#create_uri,
|
|
@@ -589,17 +521,13 @@ RelatedMethods::
|
|
|
589
521
|
=end
|
|
590
522
|
def favorites_create(status_id)
|
|
591
523
|
uri = create_uri(
|
|
592
|
-
|
|
524
|
+
BASE_ADDRESS +
|
|
593
525
|
'favorites/create/' +
|
|
594
526
|
status_id.to_s + '.xml'
|
|
595
527
|
)
|
|
596
528
|
request = create_request(:post, uri, true)
|
|
597
529
|
document = http_access(uri, request)
|
|
598
|
-
|
|
599
|
-
return parse_status(document.root)
|
|
600
|
-
else
|
|
601
|
-
return false
|
|
602
|
-
end
|
|
530
|
+
return parse_status(document.root)
|
|
603
531
|
end
|
|
604
532
|
|
|
605
533
|
=begin rdoc
|
|
@@ -611,7 +539,7 @@ Params::
|
|
|
611
539
|
status_id (target status_id)
|
|
612
540
|
|
|
613
541
|
Return::
|
|
614
|
-
status {:text => 'hoge', ...})
|
|
542
|
+
status {:text => 'hoge', ...})
|
|
615
543
|
|
|
616
544
|
RelatedMethods::
|
|
617
545
|
Utils#create_uri,
|
|
@@ -621,17 +549,13 @@ RelatedMethods::
|
|
|
621
549
|
=end
|
|
622
550
|
def favorites_destroy(status_id)
|
|
623
551
|
uri = create_uri(
|
|
624
|
-
|
|
552
|
+
BASE_ADDRESS +
|
|
625
553
|
'favorites/destroy/' +
|
|
626
554
|
status_id.to_s + '.xml'
|
|
627
555
|
)
|
|
628
556
|
request = create_request(:post, uri, true)
|
|
629
557
|
document = http_access(uri, request)
|
|
630
|
-
|
|
631
|
-
return parse_status(document.root)
|
|
632
|
-
else
|
|
633
|
-
return false
|
|
634
|
-
end
|
|
558
|
+
return parse_status(document.root)
|
|
635
559
|
end
|
|
636
560
|
|
|
637
561
|
=begin rdoc
|
|
@@ -643,7 +567,7 @@ Params::
|
|
|
643
567
|
keyword (target keyword)
|
|
644
568
|
|
|
645
569
|
Return::
|
|
646
|
-
keyword ({:title => 'hoge', ...}
|
|
570
|
+
keyword ({:title => 'hoge', ...}
|
|
647
571
|
|
|
648
572
|
RelatedMethods::
|
|
649
573
|
Utils#create_uri,
|
|
@@ -653,17 +577,13 @@ RelatedMethods::
|
|
|
653
577
|
=end
|
|
654
578
|
def keyword_create(keyword)
|
|
655
579
|
uri = create_uri(
|
|
656
|
-
|
|
580
|
+
BASE_ADDRESS +
|
|
657
581
|
'keywords/create/' +
|
|
658
582
|
keyword + '.xml'
|
|
659
583
|
)
|
|
660
584
|
request = create_request(:post, uri, true)
|
|
661
585
|
document = http_access(uri, request)
|
|
662
|
-
|
|
663
|
-
return parse_keyword(document.root)
|
|
664
|
-
else
|
|
665
|
-
return false
|
|
666
|
-
end
|
|
586
|
+
return parse_keyword(document.root)
|
|
667
587
|
end
|
|
668
588
|
|
|
669
589
|
=begin rdoc
|
|
@@ -675,7 +595,7 @@ Params::
|
|
|
675
595
|
keyword (target keyword)
|
|
676
596
|
|
|
677
597
|
Return::
|
|
678
|
-
keyword ({:title => 'hoge', ...})
|
|
598
|
+
keyword ({:title => 'hoge', ...})
|
|
679
599
|
|
|
680
600
|
RelatedMethods::
|
|
681
601
|
Utils#create_uri,
|
|
@@ -685,17 +605,13 @@ RelatedMethods::
|
|
|
685
605
|
=end
|
|
686
606
|
def keyword_destroy(keyword)
|
|
687
607
|
uri = create_uri(
|
|
688
|
-
|
|
608
|
+
BASE_ADDRESS +
|
|
689
609
|
'keywords/destroy/' +
|
|
690
610
|
keyword + '.xml'
|
|
691
611
|
)
|
|
692
612
|
request = create_request(:post, uri, true)
|
|
693
613
|
document = http_access(uri, request)
|
|
694
|
-
|
|
695
|
-
return parse_keyword(document.root)
|
|
696
|
-
else
|
|
697
|
-
return false
|
|
698
|
-
end
|
|
614
|
+
return parse_keyword(document.root)
|
|
699
615
|
end
|
|
700
616
|
|
|
701
617
|
=begin rdoc
|
|
@@ -708,7 +624,7 @@ Params::
|
|
|
708
624
|
word2 (target word)
|
|
709
625
|
|
|
710
626
|
Return::
|
|
711
|
-
keyword ({:title => 'hoge', ...})
|
|
627
|
+
keyword ({:title => 'hoge', ...})
|
|
712
628
|
|
|
713
629
|
RelatedMethods::
|
|
714
630
|
Utils#create_uri,
|
|
@@ -718,18 +634,14 @@ RelatedMethods::
|
|
|
718
634
|
=end
|
|
719
635
|
def keyword_relation_create(word1, word2)
|
|
720
636
|
uri = create_uri(
|
|
721
|
-
|
|
637
|
+
BASE_ADDRESS +
|
|
722
638
|
'keywords/relation/create.xml' +
|
|
723
639
|
'?word1=' + word1 +
|
|
724
640
|
'&word2=' + word2
|
|
725
641
|
)
|
|
726
642
|
request = create_request(:post, uri, true)
|
|
727
643
|
document = http_access(uri, request)
|
|
728
|
-
|
|
729
|
-
return parse_keyword(document.root)
|
|
730
|
-
else
|
|
731
|
-
return false
|
|
732
|
-
end
|
|
644
|
+
return parse_keyword(document.root)
|
|
733
645
|
end
|
|
734
646
|
|
|
735
647
|
=begin rdoc
|
|
@@ -742,7 +654,7 @@ Params::
|
|
|
742
654
|
word2 (rarget word)
|
|
743
655
|
|
|
744
656
|
Return::
|
|
745
|
-
keyword ({:title => 'hoge', ...})
|
|
657
|
+
keyword ({:title => 'hoge', ...})
|
|
746
658
|
|
|
747
659
|
RelatedMethods::
|
|
748
660
|
Utils#create_uri,
|
|
@@ -752,17 +664,13 @@ RelatedMethods::
|
|
|
752
664
|
=end
|
|
753
665
|
def keyword_relation_destroy(word1, word2)
|
|
754
666
|
uri = create_uri(
|
|
755
|
-
|
|
667
|
+
BASE_ADDRESS +
|
|
756
668
|
'keywords/relation/destroy.xml' +
|
|
757
669
|
'?word1=' + word1 +
|
|
758
670
|
'&word2=' + word2
|
|
759
671
|
)
|
|
760
672
|
request = create_request(:post, uri, true)
|
|
761
673
|
document = http_access(uri, request)
|
|
762
|
-
|
|
763
|
-
return parse_keyword(document.root)
|
|
764
|
-
else
|
|
765
|
-
return false
|
|
766
|
-
end
|
|
674
|
+
return parse_keyword(document.root)
|
|
767
675
|
end
|
|
768
676
|
end
|
data/lib/rhaiker/utils.rb
CHANGED
|
@@ -35,6 +35,8 @@ RelatedMethods::
|
|
|
35
35
|
request = Net::HTTP::Get.new(uri.request_uri)
|
|
36
36
|
when :post
|
|
37
37
|
request = Net::HTTP::Post.new(uri.request_uri)
|
|
38
|
+
else
|
|
39
|
+
raise ArgumentError, 'type must be :get or :post'
|
|
38
40
|
end
|
|
39
41
|
request['User-Agent'] = @user_agent
|
|
40
42
|
request.basic_auth @user_id, @api_key if use_basic_auth
|
|
@@ -69,7 +71,7 @@ Params::
|
|
|
69
71
|
request (Net::HTTPRequest-Instance)
|
|
70
72
|
|
|
71
73
|
Return::
|
|
72
|
-
REXML::Document-Instance
|
|
74
|
+
REXML::Document-Instance
|
|
73
75
|
|
|
74
76
|
RelatedMethods::
|
|
75
77
|
create_uri,
|
|
@@ -84,7 +86,7 @@ RelatedMethods::
|
|
|
84
86
|
if response.code == '200'
|
|
85
87
|
return REXML::Document.new(response.body)
|
|
86
88
|
else
|
|
87
|
-
|
|
89
|
+
raise "HTTP access failed: status code #{response.code}"
|
|
88
90
|
end
|
|
89
91
|
}
|
|
90
92
|
end
|
data/lib/rhaiker/version.rb
CHANGED
data/spec/rhaiker_spec.rb
CHANGED
data/website/index.html
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
<h1>rhaiker</h1>
|
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/rhaiker"; return false'>
|
|
35
35
|
<p>Get Version</p>
|
|
36
|
-
<a href="http://rubyforge.org/projects/rhaiker" class="numbers">0.
|
|
36
|
+
<a href="http://rubyforge.org/projects/rhaiker" class="numbers">0.1.1</a>
|
|
37
37
|
</div>
|
|
38
38
|
<h2>What</h2>
|
|
39
39
|
<p>Rhaiker is Hatena::Haiku::<span class="caps">API</span> ruby binding.<br />
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rhaiker
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- saronpasu
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-
|
|
12
|
+
date: 2009-05-25 00:00:00 +09:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
95
95
|
requirements: []
|
|
96
96
|
|
|
97
97
|
rubyforge_project: rhaiker
|
|
98
|
-
rubygems_version: 1.
|
|
98
|
+
rubygems_version: 1.3.1
|
|
99
99
|
signing_key:
|
|
100
100
|
specification_version: 2
|
|
101
101
|
summary: Hatena::Haiku::API ruby binding
|