twitter4r 0.3.1 → 0.3.2
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 +2 -0
- data/lib/twitter/client/base.rb +4 -1
- data/lib/twitter/client/user.rb +3 -2
- data/lib/twitter/core.rb +2 -2
- data/lib/twitter/model.rb +2 -2
- data/lib/twitter/version.rb +1 -1
- data/spec/twitter/client/user_spec.rb +5 -5
- metadata +3 -3
data/README
CHANGED
@@ -13,6 +13,8 @@ Code:
|
|
13
13
|
* Adam Stiles <adam at stilesoft dot com> - URI.encode => CGI.escape fix
|
14
14
|
* Carl Crawley <cwcrawley at gmail dot com> - Friendship get => post fix
|
15
15
|
* Christian Johansen <christian at cjohansen dot no> - in_reply_to attributes in Twitter::Status
|
16
|
+
* Harry Love <harrylove at gmail dot com> - added attributes to Twitter::Status
|
17
|
+
* Filipe Giusti <filipegiusti at gmail dot com> - fixed users/show issue that Twitter.com changed from under us
|
16
18
|
|
17
19
|
Design Suggestions:
|
18
20
|
* Bosco So <rubymeetup at boscoso dot com> - making Twitter::Error a RuntimeError instead of an Exception to prevent irb from crashing out.
|
data/lib/twitter/client/base.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
class Twitter::Client
|
2
2
|
alias :old_inspect :inspect
|
3
|
+
|
3
4
|
def inspect
|
4
5
|
s = old_inspect
|
5
6
|
s.gsub!(/@password=".*?"/, '@password="XXXX"')
|
6
7
|
end
|
8
|
+
|
7
9
|
protected
|
8
10
|
attr_accessor :login, :password
|
9
11
|
|
@@ -34,8 +36,10 @@ class Twitter::Client
|
|
34
36
|
@@http_header = nil
|
35
37
|
|
36
38
|
def raise_rest_error(response, uri = nil)
|
39
|
+
map = JSON.parse(response.body)
|
37
40
|
raise Twitter::RESTError.new(:code => response.code,
|
38
41
|
:message => response.message,
|
42
|
+
:error => map["error"],
|
39
43
|
:uri => uri)
|
40
44
|
end
|
41
45
|
|
@@ -90,4 +94,3 @@ class Twitter::Client
|
|
90
94
|
Net::HTTP::Delete.new(path, http_header)
|
91
95
|
end
|
92
96
|
end
|
93
|
-
|
data/lib/twitter/client/user.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Twitter::Client
|
2
2
|
@@USER_URIS = {
|
3
|
-
:info => '/users/show',
|
3
|
+
:info => '/users/show.json',
|
4
4
|
:friends => '/statuses/friends.json',
|
5
5
|
:followers => '/statuses/followers.json',
|
6
6
|
}
|
@@ -33,7 +33,8 @@ class Twitter::Client
|
|
33
33
|
def user(id, action = :info, options = {})
|
34
34
|
raise ArgumentError, "Invalid user action: #{action}" unless @@USER_URIS.keys.member?(action)
|
35
35
|
id = id.to_i if id.is_a?(Twitter::User)
|
36
|
-
|
36
|
+
id_param = id.is_a?(String) ? :screen_name : :user_id
|
37
|
+
params = options.merge(id_param => id)
|
37
38
|
response = http_connect {|conn| create_http_get_request(@@USER_URIS[action], params) }
|
38
39
|
bless_models(Twitter::User.unmarshal(response.body))
|
39
40
|
end
|
data/lib/twitter/core.rb
CHANGED
@@ -101,8 +101,8 @@ module Twitter
|
|
101
101
|
# /i_am_crap.json
|
102
102
|
class RESTError < RuntimeError
|
103
103
|
include ClassUtilMixin
|
104
|
-
@@ATTRIBUTES = [:code, :message, :uri]
|
105
|
-
attr_accessor :code, :message, :uri
|
104
|
+
@@ATTRIBUTES = [:code, :message, :uri, :error]
|
105
|
+
attr_accessor :code, :message, :uri, :error
|
106
106
|
|
107
107
|
# Returns string in following format:
|
108
108
|
# "HTTP #{@code}: #{@message} at #{@uri}"
|
data/lib/twitter/model.rb
CHANGED
@@ -225,7 +225,7 @@ module Twitter
|
|
225
225
|
# Represents a status posted to <tt>Twitter</tt> by a <tt>Twitter</tt> user.
|
226
226
|
class Status
|
227
227
|
include ModelMixin
|
228
|
-
@@ATTRIBUTES = [:id, :text, :source, :truncated, :created_at, :user,
|
228
|
+
@@ATTRIBUTES = [:id, :text, :source, :truncated, :created_at, :user, :from_user, :to_user,
|
229
229
|
:favorited, :in_reply_to_status_id, :in_reply_to_user_id,
|
230
230
|
:in_reply_to_screen_name]
|
231
231
|
attr_accessor *@@ATTRIBUTES
|
@@ -311,7 +311,7 @@ module Twitter
|
|
311
311
|
# For example:
|
312
312
|
# status = Twitter::Message.create(
|
313
313
|
# :text => 'I am shopping for flip flops',
|
314
|
-
# :
|
314
|
+
# :recipient => 'anotherlogin',
|
315
315
|
# :client => client)
|
316
316
|
#
|
317
317
|
# An <tt>ArgumentError</tt> will be raised if no valid client context
|
data/lib/twitter/version.rb
CHANGED
@@ -21,12 +21,12 @@ describe Twitter::Client, "#user(id, :info)" do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should create expected HTTP GET request when giving numeric user id" do
|
24
|
-
@twitter.should_receive(:create_http_get_request).with(@uris[:info], {:
|
24
|
+
@twitter.should_receive(:create_http_get_request).with(@uris[:info], {:user_id => @id}).and_return(@request)
|
25
25
|
@twitter.user(@id)
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should create expected HTTP GET request when giving screen name" do
|
29
|
-
@twitter.should_receive(:create_http_get_request).with(@uris[:info], {:
|
29
|
+
@twitter.should_receive(:create_http_get_request).with(@uris[:info], {:screen_name => @screen_name}).and_return(@request)
|
30
30
|
@twitter.user(@screen_name)
|
31
31
|
end
|
32
32
|
|
@@ -68,7 +68,7 @@ describe Twitter::Client, "#user(id, :friends)" do
|
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should create expected HTTP GET request when giving numeric user id" do
|
71
|
-
@twitter.should_receive(:create_http_get_request).with(@uris[:friends], {:
|
71
|
+
@twitter.should_receive(:create_http_get_request).with(@uris[:friends], {:user_id => @id}).and_return(@request)
|
72
72
|
@twitter.user(@id, :friends)
|
73
73
|
end
|
74
74
|
|
@@ -78,12 +78,12 @@ describe Twitter::Client, "#user(id, :friends)" do
|
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should create expected HTTP GET request when giving Twitter::User object" do
|
81
|
-
@twitter.should_receive(:create_http_get_request).with(@uris[:friends], {:
|
81
|
+
@twitter.should_receive(:create_http_get_request).with(@uris[:friends], {:user_id => @user.to_i}).and_return(@request)
|
82
82
|
@twitter.user(@user, :friends)
|
83
83
|
end
|
84
84
|
|
85
85
|
it "should create expected HTTP GET request when giving screen name" do
|
86
|
-
@twitter.should_receive(:create_http_get_request).with(@uris[:friends], {:
|
86
|
+
@twitter.should_receive(:create_http_get_request).with(@uris[:friends], {:screen_name => @screen_name}).and_return(@request)
|
87
87
|
@twitter.user(@screen_name, :friends)
|
88
88
|
end
|
89
89
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twitter4r
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Susan Potter
|
@@ -9,7 +9,7 @@ autorequire: twitter
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-10-27 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -110,7 +110,7 @@ requirements:
|
|
110
110
|
- json gem, version 0.4.3 or higher
|
111
111
|
- jcode (for unicode support)
|
112
112
|
rubyforge_project: twitter4r
|
113
|
-
rubygems_version: 1.3.
|
113
|
+
rubygems_version: 1.3.5
|
114
114
|
signing_key:
|
115
115
|
specification_version: 3
|
116
116
|
summary: A clean Twitter client API in pure Ruby. Will include Twitter add-ons also in Ruby.
|