jugyo-rubytter 0.4.7 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +5 -7
- data/Rakefile +1 -0
- data/examples/direct_message.rb +1 -1
- data/examples/favorite.rb +1 -1
- data/examples/follow.rb +1 -1
- data/examples/friends_timeline.rb +1 -1
- data/examples/limit.rb +1 -1
- data/examples/replies.rb +1 -1
- data/examples/search.rb +1 -1
- data/examples/update_status.rb +1 -1
- data/examples/user.rb +1 -1
- data/lib/rubytter.rb +12 -4
- data/lib/rubytter/connection.rb +1 -0
- data/spec/rubytter_spec.rb +16 -4
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -46,14 +46,16 @@ implemented API methods:
|
|
46
46
|
|
47
47
|
== SYNOPSIS:
|
48
48
|
|
49
|
-
|
49
|
+
initialize:
|
50
50
|
|
51
51
|
client = Rubytter.new(user_id, password)
|
52
|
+
|
53
|
+
update status:
|
54
|
+
|
52
55
|
client.update('hello twitter!!')
|
53
56
|
|
54
|
-
get friends timeline
|
57
|
+
get friends timeline:
|
55
58
|
|
56
|
-
client = Rubytter.new(user_id, password)
|
57
59
|
client.friends_timeline.each do |status|
|
58
60
|
puts "#{status.user.screen_name}: #{status.text}"
|
59
61
|
end
|
@@ -75,10 +77,6 @@ or
|
|
75
77
|
gem source -a http://gems.github.com
|
76
78
|
sudo gem install jugyo-rubytter
|
77
79
|
|
78
|
-
== TODO:
|
79
|
-
|
80
|
-
- search
|
81
|
-
|
82
80
|
== LICENSE:
|
83
81
|
|
84
82
|
(The MIT License)
|
data/Rakefile
CHANGED
data/examples/direct_message.rb
CHANGED
data/examples/favorite.rb
CHANGED
data/examples/follow.rb
CHANGED
data/examples/limit.rb
CHANGED
data/examples/replies.rb
CHANGED
data/examples/search.rb
CHANGED
data/examples/update_status.rb
CHANGED
data/examples/user.rb
CHANGED
data/lib/rubytter.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require 'rubygems'
|
2
3
|
require 'json'
|
3
4
|
require 'net/https'
|
@@ -7,10 +8,16 @@ require 'rubytter/connection'
|
|
7
8
|
|
8
9
|
class Rubytter
|
9
10
|
|
10
|
-
class APIError < StandardError
|
11
|
+
class APIError < StandardError
|
12
|
+
attr_reader :response
|
13
|
+
def initialize(msg, response = nil)
|
14
|
+
super(msg)
|
15
|
+
@response = response
|
16
|
+
end
|
17
|
+
end
|
11
18
|
|
12
19
|
APP_NAME = 'Rubytter'
|
13
|
-
VERSION = '0.4.
|
20
|
+
VERSION = '0.4.8'
|
14
21
|
HOMEPAGE = 'http://github.com/jugyo/rubytter'
|
15
22
|
|
16
23
|
attr_reader :login
|
@@ -20,7 +27,8 @@ class Rubytter
|
|
20
27
|
@login = login
|
21
28
|
@password = password
|
22
29
|
@host = options[:host] || 'twitter.com'
|
23
|
-
@header =
|
30
|
+
@header = {'User-Agent' => "#{APP_NAME}/#{VERSION} (#{HOMEPAGE})"}
|
31
|
+
@header.merge!(options[:header]) if options[:header]
|
24
32
|
@connection = Connection.new(options)
|
25
33
|
end
|
26
34
|
|
@@ -126,7 +134,7 @@ class Rubytter
|
|
126
134
|
when "200"
|
127
135
|
struct
|
128
136
|
else
|
129
|
-
raise APIError
|
137
|
+
raise APIError.new(struct.error, res)
|
130
138
|
end
|
131
139
|
end
|
132
140
|
|
data/lib/rubytter/connection.rb
CHANGED
data/spec/rubytter_spec.rb
CHANGED
@@ -135,9 +135,9 @@ class Rubytter
|
|
135
135
|
end
|
136
136
|
|
137
137
|
it 'should raise when call to_param_str with invalid arg' do
|
138
|
-
lambda { @rubytter.to_param_str(nil) }.should raise_error
|
139
|
-
lambda { @rubytter.to_param_str('foo') }.should raise_error
|
140
|
-
lambda { @rubytter.to_param_str(:bar) }.should raise_error
|
138
|
+
lambda { @rubytter.to_param_str(nil) }.should raise_error(ArgumentError)
|
139
|
+
lambda { @rubytter.to_param_str('foo') }.should raise_error(ArgumentError)
|
140
|
+
lambda { @rubytter.to_param_str(:bar) }.should raise_error(ArgumentError)
|
141
141
|
end
|
142
142
|
|
143
143
|
it 'should set default header' do
|
@@ -145,7 +145,19 @@ class Rubytter
|
|
145
145
|
rubytter.header.should == {'User-Agent', "#{APP_NAME}/#{VERSION} (#{HOMEPAGE})"}
|
146
146
|
end
|
147
147
|
|
148
|
-
it 'should able to set custom header' do
|
148
|
+
it 'should able to set custom header 1' do
|
149
|
+
rubytter = Rubytter.new('test', 'test',
|
150
|
+
{
|
151
|
+
:header => {
|
152
|
+
'foo' => 'bar'
|
153
|
+
}
|
154
|
+
}
|
155
|
+
)
|
156
|
+
rubytter.header['foo'].should == 'bar'
|
157
|
+
rubytter.header.has_key?('User-Agent').should == true
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'should able to set custom header 2' do
|
149
161
|
rubytter = Rubytter.new('test', 'test',
|
150
162
|
{
|
151
163
|
:header => {
|