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 CHANGED
@@ -6,9 +6,11 @@ http://wiki.github.com/jugyo/rubytter
6
6
 
7
7
  Rubytter is simple twitter library.
8
8
 
9
- == FEATURES/PROBLEMS:
9
+ == FEATURES:
10
10
 
11
- implemented API methods:
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
- update status:
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
@@ -5,10 +5,11 @@ require 'net/https'
5
5
  require 'cgi'
6
6
 
7
7
  require 'rubytter/connection'
8
+ require 'rubytter/oauth_rubytter'
8
9
 
9
10
  class Rubytter
10
11
 
11
- VERSION = '0.6.6'
12
+ VERSION = '0.7.0'
12
13
 
13
14
  class APIError < StandardError
14
15
  attr_reader :response
@@ -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
- lambda {struct.x}.should raise_error(NoMethodError)
193
- lambda {struct.regex}.should raise_error(NoMethodError)
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.6.6
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-03-26 00:00:00 -07:00
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