rubytter 1.2.0 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -13,6 +13,7 @@ begin
13
13
  gem.authors = ["jugyo"]
14
14
  gem.files = FileList['lib/**/*.rb', 'VERSION', 'README.rdoc', 'History.txt', 'Rakefile', 'spec/**/*.rb', 'spec/**/*.json', 'examples/**/*.rb']
15
15
  gem.add_dependency("json", ">= 1.1.3")
16
+ gem.add_dependency("oauth", ">= 0.3.6")
16
17
  gem.add_development_dependency "rspec"
17
18
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
19
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 1.2.2
@@ -5,9 +5,9 @@ require 'rubytter'
5
5
  key = ""
6
6
  secret = ""
7
7
 
8
- consumer = OAuth::Consumer.new(key, secret, :site => "http://twitter.com")
8
+ oauth = Rubytter::OAuth.new(key, secret)
9
9
 
10
- request_token = consumer.get_request_token
10
+ request_token = oauth.get_request_token
11
11
  system('open', request_token.authorize_url) || puts("Access here: #{request_token.authorize_url}\nand...")
12
12
 
13
13
  print "Enter PIN: "
@@ -2,22 +2,15 @@ $:.unshift File.join(File.dirname(__FILE__), '../lib')
2
2
  require 'rubygems'
3
3
  require 'rubytter'
4
4
 
5
- XAuthRubytter.init(
6
- :key => 'CONSUMER-KEY',
7
- :secret => 'CONSUMER-SECRET'
8
- )
5
+ key = ''
6
+ secret = ''
7
+ login = ''
8
+ password = ''
9
9
 
10
- # # OR
11
- # XAuthRubytter.init(
12
- # :key => 'CONSUMER-KEY',
13
- # :secret => 'CONSUMER-SECRET',
14
- # :ca_file => 'PATH-TO-CA_FILE'
15
- # )
16
-
17
- client = XAuthRubytter.new('LOGIN', 'PASSWORD')
18
- p client.access_token.token
19
- p client.access_token.secret
10
+ oauth = Rubytter::OAuth.new(key, secret)
11
+ access_token = oauth.get_access_token_with_xauth(login, password)
20
12
 
13
+ client = OAuthRubytter.new(access_token)
21
14
  client.friends_timeline.each do |status|
22
15
  puts "#{status.user.screen_name}: #{status.text}"
23
16
  end
@@ -7,6 +7,19 @@ class Rubytter
7
7
  end
8
8
 
9
9
  def get_access_token_with_xauth(login, password)
10
+ consumer = create_consumer
11
+ consumer.get_access_token(nil, {}, {
12
+ :x_auth_mode => "client_auth",
13
+ :x_auth_username => login,
14
+ :x_auth_password => password
15
+ })
16
+ end
17
+
18
+ def get_request_token
19
+ create_consumer.get_request_token
20
+ end
21
+
22
+ def create_consumer
10
23
  if @ca_file
11
24
  consumer = ::OAuth::Consumer.new(@key, @secret,
12
25
  :site => 'https://api.twitter.com', :ca_file => @ca_file)
@@ -15,12 +28,7 @@ class Rubytter
15
28
  :site => 'https://api.twitter.com')
16
29
  consumer.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
17
30
  end
18
-
19
- consumer.get_access_token(nil, {}, {
20
- :x_auth_mode => "client_auth",
21
- :x_auth_username => login,
22
- :x_auth_password => password
23
- })
31
+ consumer
24
32
  end
25
33
  end
26
34
  end
@@ -9,16 +9,17 @@ class Rubytter::OAuth
9
9
  @oauth = Rubytter::OAuth.new('key', 'secret', 'ca_file')
10
10
  end
11
11
 
12
+ it 'should get_request_token' do
13
+ consumer = Object.new
14
+ @oauth.should_receive(:create_consumer).and_return(consumer)
15
+ consumer.should_receive(:get_request_token).and_return('request_token')
16
+ request_token = @oauth.get_request_token
17
+ request_token.should == 'request_token'
18
+ end
19
+
12
20
  it 'should get_access_token_with_xauth' do
13
21
  consumer = Object.new
14
- ::OAuth::Consumer.should_receive(:new).
15
- with(
16
- 'key',
17
- 'secret',
18
- :site => 'https://api.twitter.com',
19
- :ca_file => 'ca_file'
20
- ).
21
- and_return(consumer)
22
+ @oauth.should_receive(:create_consumer).and_return(consumer)
22
23
  consumer.should_receive(:get_access_token).
23
24
  with(
24
25
  nil,
@@ -31,6 +32,19 @@ class Rubytter::OAuth
31
32
  token = @oauth.get_access_token_with_xauth('login', 'password')
32
33
  token.should == 'token'
33
34
  end
35
+
36
+ it 'should create_consumer' do
37
+ consumer = Object.new
38
+ ::OAuth::Consumer.should_receive(:new).
39
+ with(
40
+ 'key',
41
+ 'secret',
42
+ :site => 'https://api.twitter.com',
43
+ :ca_file => 'ca_file'
44
+ ).
45
+ and_return(consumer)
46
+ @oauth.create_consumer
47
+ end
34
48
  end
35
49
 
36
50
  context 'ca_file is not specified' do
@@ -38,7 +52,7 @@ class Rubytter::OAuth
38
52
  @oauth = Rubytter::OAuth.new('key', 'secret')
39
53
  end
40
54
 
41
- it 'should get_access_token_with_xauth' do
55
+ it 'should create_consumer' do
42
56
  consumer = Object.new
43
57
  http = Object.new
44
58
  consumer.should_receive(:http).and_return(http)
@@ -50,17 +64,7 @@ class Rubytter::OAuth
50
64
  :site => 'https://api.twitter.com'
51
65
  ).
52
66
  and_return(consumer)
53
- consumer.should_receive(:get_access_token).
54
- with(
55
- nil,
56
- {},
57
- :x_auth_mode => "client_auth",
58
- :x_auth_username => 'login',
59
- :x_auth_password => 'password'
60
- ).
61
- and_return('token')
62
- token = @oauth.get_access_token_with_xauth('login', 'password')
63
- token.should == 'token'
67
+ @oauth.create_consumer
64
68
  end
65
69
  end
66
70
  end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubytter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 2
8
+ - 2
9
+ version: 1.2.2
5
10
  platform: ruby
6
11
  authors:
7
12
  - jugyo
@@ -14,24 +19,44 @@ default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: json
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 1
30
+ - 3
23
31
  version: 1.1.3
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: oauth
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ - 3
44
+ - 6
45
+ version: 0.3.6
46
+ type: :runtime
47
+ version_requirements: *id002
25
48
  - !ruby/object:Gem::Dependency
26
49
  name: rspec
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
30
52
  requirements:
31
53
  - - ">="
32
54
  - !ruby/object:Gem::Version
55
+ segments:
56
+ - 0
33
57
  version: "0"
34
- version:
58
+ type: :development
59
+ version_requirements: *id003
35
60
  description: Rubytter is a simple twitter client.
36
61
  email: jugyo.org@gmail.com
37
62
  executables: []
@@ -80,18 +105,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
80
105
  requirements:
81
106
  - - ">="
82
107
  - !ruby/object:Gem::Version
108
+ segments:
109
+ - 0
83
110
  version: "0"
84
- version:
85
111
  required_rubygems_version: !ruby/object:Gem::Requirement
86
112
  requirements:
87
113
  - - ">="
88
114
  - !ruby/object:Gem::Version
115
+ segments:
116
+ - 0
89
117
  version: "0"
90
- version:
91
118
  requirements: []
92
119
 
93
120
  rubyforge_project: rubytter
94
- rubygems_version: 1.3.5
121
+ rubygems_version: 1.3.6
95
122
  signing_key:
96
123
  specification_version: 3
97
124
  summary: Simple twitter client.