twitter4r 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,11 +17,13 @@ class Twitter::Client
17
17
  # is given. Valid actions are:
18
18
  # * +:received+
19
19
  # * +:sent+
20
- def messages(action)
20
+ def messages(action, options = nil)
21
+ # method scoped method
22
+ def uri_suffix(opts); opts && opts[:page] ? "?page=#{opts[:page]}" : ""; end
21
23
  raise ArgumentError, "Invalid messaging action: #{action}" unless [:sent, :received].member?(action)
22
- uri = @@MESSAGING_URIS[action]
23
- response = http_connect {|conn| create_http_get_request(uri) }
24
- bless_models(Twitter::Message.unmarshal(response.body))
24
+ uri = @@MESSAGING_URIS[action] + uri_suffix(options)
25
+ response = http_connect {|conn| create_http_get_request(uri) }
26
+ bless_models(Twitter::Message.unmarshal(response.body))
25
27
  end
26
28
 
27
29
  # Provides access to Twitter's Messaging API for sending and deleting
@@ -4,7 +4,7 @@
4
4
  module Twitter::Version #:nodoc:
5
5
  MAJOR = 0
6
6
  MINOR = 2
7
- REVISION = 4
7
+ REVISION = 5
8
8
  class << self
9
9
  # Returns X.Y.Z formatted version string
10
10
  def to_version
@@ -10,6 +10,7 @@ describe Twitter::Client, "#messages" do
10
10
  Net::HTTP.stub!(:new).and_return(@connection)
11
11
  @messages = []
12
12
  Twitter::Message.stub!(:unmarshal).and_return(@messages)
13
+ @page = 2
13
14
  end
14
15
 
15
16
  it "should create expected HTTP GET request for :received case" do
@@ -37,6 +38,22 @@ describe Twitter::Client, "#messages" do
37
38
  @twitter.messages(:crap)
38
39
  }.should raise_error(ArgumentError)
39
40
  end
41
+
42
+ it "should accept an options Hash for paging" do
43
+ lambda {
44
+ @twitter.messages(:sent, :page => @page)
45
+ }.should_not raise_error(Exception)
46
+ end
47
+
48
+ it "should generate expected GET HTTP request for paging case" do
49
+ @twitter.should_receive(:create_http_get_request).with(@uris[:received] + "?page=#{@page}").and_return(@request)
50
+ @twitter.messages(:received, :page => @page)
51
+ end
52
+
53
+ it "should bless models for paging case" do
54
+ @twitter.should_receive(:bless_models).with(@messages).and_return(@messages)
55
+ @twitter.messages(:sent, :page => @page)
56
+ end
40
57
 
41
58
  after(:each) do
42
59
  nilize(@twitter, @uris, @request, @response, @connection, @messages)
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: twitter4r
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.4
7
- date: 2007-07-25 00:00:00 -05:00
6
+ version: 0.2.5
7
+ date: 2007-09-23 00:00:00 -07:00
8
8
  summary: A clean Twitter client API in pure Ruby. Will include Twitter add-ons also in Ruby.
9
9
  require_paths:
10
10
  - lib
@@ -29,40 +29,40 @@ post_install_message:
29
29
  authors:
30
30
  - Susan Potter
31
31
  files:
32
- - lib/twitter.rb
33
- - lib/twitter/ext/stdlib.rb
34
- - lib/twitter/console.rb
35
- - lib/twitter/ext.rb
36
- - lib/twitter/rails.rb
37
- - lib/twitter/meta.rb
38
- - lib/twitter/client.rb
39
- - lib/twitter/client/status.rb
40
- - lib/twitter/client/friendship.rb
41
- - lib/twitter/client/user.rb
32
+ - lib/twitter/extras.rb
33
+ - lib/twitter/config.rb
34
+ - lib/twitter/core.rb
42
35
  - lib/twitter/client/timeline.rb
43
36
  - lib/twitter/client/messaging.rb
44
37
  - lib/twitter/client/base.rb
45
- - lib/twitter/config.rb
46
- - lib/twitter/model.rb
47
- - lib/twitter/extras.rb
38
+ - lib/twitter/client/status.rb
39
+ - lib/twitter/client/friendship.rb
40
+ - lib/twitter/client/user.rb
41
+ - lib/twitter/rails.rb
42
+ - lib/twitter/client.rb
43
+ - lib/twitter/console.rb
48
44
  - lib/twitter/version.rb
49
- - lib/twitter/core.rb
50
- - spec/twitter/meta_spec.rb
51
- - spec/twitter/ext/stdlib_spec.rb
52
- - spec/twitter/client_spec.rb
53
- - spec/twitter/version_spec.rb
54
- - spec/twitter/console_spec.rb
55
- - spec/twitter/client/base_spec.rb
45
+ - lib/twitter/model.rb
46
+ - lib/twitter/meta.rb
47
+ - lib/twitter/ext.rb
48
+ - lib/twitter/ext/stdlib.rb
49
+ - lib/twitter.rb
50
+ - spec/twitter/config_spec.rb
51
+ - spec/twitter/core_spec.rb
52
+ - spec/twitter/model_spec.rb
53
+ - spec/twitter/client/status_spec.rb
54
+ - spec/twitter/client/timeline_spec.rb
56
55
  - spec/twitter/client/user_spec.rb
57
- - spec/twitter/client/friendship_spec.rb
58
56
  - spec/twitter/client/messaging_spec.rb
59
- - spec/twitter/client/timeline_spec.rb
60
- - spec/twitter/client/status_spec.rb
61
- - spec/twitter/extras_spec.rb
62
- - spec/twitter/core_spec.rb
57
+ - spec/twitter/client/base_spec.rb
58
+ - spec/twitter/client/friendship_spec.rb
59
+ - spec/twitter/version_spec.rb
63
60
  - spec/twitter/rails_spec.rb
64
- - spec/twitter/config_spec.rb
65
- - spec/twitter/model_spec.rb
61
+ - spec/twitter/client_spec.rb
62
+ - spec/twitter/meta_spec.rb
63
+ - spec/twitter/console_spec.rb
64
+ - spec/twitter/extras_spec.rb
65
+ - spec/twitter/ext/stdlib_spec.rb
66
66
  test_files: []
67
67
 
68
68
  rdoc_options: []