jugyo-rubytter 0.6.6 → 0.7.0
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/README.rdoc +13 -5
- data/lib/rubytter/oauth_rubytter.rb +19 -0
- data/lib/rubytter.rb +2 -1
- data/spec/rubytter_spec.rb +23 -2
- metadata +3 -2
data/README.rdoc
CHANGED
|
@@ -6,9 +6,11 @@ http://wiki.github.com/jugyo/rubytter
|
|
|
6
6
|
|
|
7
7
|
Rubytter is simple twitter library.
|
|
8
8
|
|
|
9
|
-
== FEATURES
|
|
9
|
+
== FEATURES:
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
* Supports OAuth
|
|
12
|
+
|
|
13
|
+
=== implemented API methods:
|
|
12
14
|
|
|
13
15
|
- /statuses/update
|
|
14
16
|
- /statuses/destroy/id
|
|
@@ -46,15 +48,21 @@ implemented API methods:
|
|
|
46
48
|
|
|
47
49
|
== SYNOPSIS:
|
|
48
50
|
|
|
49
|
-
initialize:
|
|
51
|
+
=== initialize:
|
|
50
52
|
|
|
51
53
|
client = Rubytter.new(user_id, password)
|
|
52
54
|
|
|
53
|
-
|
|
55
|
+
or
|
|
56
|
+
|
|
57
|
+
client = OAuthRubytter.new(access_token)
|
|
58
|
+
|
|
59
|
+
You must specify valid instance of OAuth::AccessToken as acces_token.
|
|
60
|
+
|
|
61
|
+
=== update status:
|
|
54
62
|
|
|
55
63
|
client.update('hello twitter!!')
|
|
56
64
|
|
|
57
|
-
get friends timeline:
|
|
65
|
+
=== get friends timeline:
|
|
58
66
|
|
|
59
67
|
client.friends_timeline.each do |status|
|
|
60
68
|
puts "#{status.user.screen_name}: #{status.text}"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# must use oauth library.
|
|
3
|
+
class OAuthRubytter < Rubytter
|
|
4
|
+
# access_token: must be instance of OAuth::AccessToken
|
|
5
|
+
def initialize(access_token, options = {})
|
|
6
|
+
super(options)
|
|
7
|
+
@access_token = access_token
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def get(path, params = {})
|
|
11
|
+
path += '.json'
|
|
12
|
+
@access_token.get(path, params, @header)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def post(path, params = {})
|
|
16
|
+
path += '.json'
|
|
17
|
+
@access_token.post(path, params, @header)
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/rubytter.rb
CHANGED
data/spec/rubytter_spec.rb
CHANGED
|
@@ -189,8 +189,8 @@ class Rubytter
|
|
|
189
189
|
struct.e[0].a.should == 1
|
|
190
190
|
struct.e[0].b.should == 2
|
|
191
191
|
struct.e[1].c.should == '"<>&'
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
struct.x.should == nil
|
|
193
|
+
struct.regex.should == nil
|
|
194
194
|
end
|
|
195
195
|
|
|
196
196
|
it 'should create same structs from same datas' do
|
|
@@ -248,5 +248,26 @@ class Rubytter
|
|
|
248
248
|
status.user.screen_name.should == "jugyo"
|
|
249
249
|
status.user.profile_image_url.should == "http://s3.amazonaws.com/twitter_production/profile_images/63467667/megane2_normal.png"
|
|
250
250
|
end
|
|
251
|
+
|
|
252
|
+
it 'should post using access_token' do
|
|
253
|
+
access_token = Object.new
|
|
254
|
+
rubytter = OAuthRubytter.new(access_token)
|
|
255
|
+
access_token.should_receive(:post).with('/statuses/update.json', {:status => 'test'}, {"User-Agent"=>"Rubytter/0.6.6 (http://github.com/jugyo/rubytter)"})
|
|
256
|
+
rubytter.update('test')
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
it 'should get using access_token' do
|
|
260
|
+
access_token = Object.new
|
|
261
|
+
rubytter = OAuthRubytter.new(access_token)
|
|
262
|
+
access_token.should_receive(:get).with('/statuses/friends_timeline.json', {}, {"User-Agent"=>"Rubytter/0.6.6 (http://github.com/jugyo/rubytter)"})
|
|
263
|
+
rubytter.friends_timeline
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
it 'should get with params using access_token' do
|
|
267
|
+
access_token = Object.new
|
|
268
|
+
rubytter = OAuthRubytter.new(access_token)
|
|
269
|
+
access_token.should_receive(:get).with('/statuses/friends_timeline.json', {:page => 2}, {"User-Agent"=>"Rubytter/0.6.6 (http://github.com/jugyo/rubytter)"})
|
|
270
|
+
rubytter.friends_timeline(:page => 2)
|
|
271
|
+
end
|
|
251
272
|
end
|
|
252
273
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jugyo-rubytter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- jugyo
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-
|
|
12
|
+
date: 2009-04-01 00:00:00 -07:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
@@ -33,6 +33,7 @@ extra_rdoc_files:
|
|
|
33
33
|
- History.txt
|
|
34
34
|
files:
|
|
35
35
|
- lib/rubytter/connection.rb
|
|
36
|
+
- lib/rubytter/oauth_rubytter.rb
|
|
36
37
|
- lib/rubytter.rb
|
|
37
38
|
- spec/rubytter_spec.rb
|
|
38
39
|
- spec/spec_helper.rb
|