mikedamage-tweeb 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,7 +29,7 @@ h3. Tweeb::Client
29
29
  tweeb = Tweeb::Client.new('username', 'password')
30
30
  public_timeline = tweeb.public_timeline # can also be: tweeb.timeline(:public)
31
31
  public_timeline.each do |tweet|
32
- puts tweet["text"]
32
+ puts tweet[:text]
33
33
  end
34
34
  </pre>
35
35
 
@@ -43,7 +43,7 @@ h3. Tweeb::Stream
43
43
 
44
44
  # Uses Twitter's "spritzer" stream
45
45
  tweeb.spritzer do |tweet|
46
- puts tweet["text"]
46
+ puts tweet[:text]
47
47
  end
48
48
  </pre>
49
49
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -1,3 +1,4 @@
1
+ require "time"
1
2
  require "rubygems"
2
3
  require "httparty"
3
4
  require File.join(File.dirname(__FILE__), "tweeb_client_error.rb")
@@ -17,7 +18,7 @@ end
17
18
  module Tweeb
18
19
  class Client
19
20
  include HTTParty
20
- attr_reader :username, :password
21
+ attr_reader :username, :password, :rate_limit_total, :rate_limit_reset, :rate_limit_remaining
21
22
 
22
23
  base_uri "http://twitter.com"
23
24
  format :json
@@ -30,6 +31,9 @@ module Tweeb
30
31
  }.merge(options)
31
32
  self.class.basic_auth(@username, @password)
32
33
  @symbolizer = lambda {|hash| hash['user'].symbolize_keys; hash.symbolize_keys; return hash }
34
+ @rate_limit_total = 150
35
+ @rate_limit_reset = nil
36
+ @rate_limit_remaining = nil
33
37
  end
34
38
 
35
39
  def timeline(type, options={})
@@ -284,5 +288,17 @@ module Tweeb
284
288
  false
285
289
  end
286
290
 
291
+ def update_rate_limits
292
+ json = self.class.get("/account/rate_limit_status.json")
293
+ @rate_limit_total = json["hourly_limit"].to_i
294
+ @rate_limit_remaining = json["remaining_hits"].to_i
295
+ @rate_limit_reset = Time.parse(json["reset_time"])
296
+ rate_limits
297
+ end
298
+
299
+ def rate_limits
300
+ {:total => @rate_limit_total, :remaining => @rate_limit_remaining, :reset_time => @rate_limit_reset}
301
+ end
302
+
287
303
  end
288
304
  end
@@ -36,4 +36,8 @@ describe "a Tweeb::Client instance" do
36
36
  it "should throw a Tweeb::ClientError when the friends timeline's count option is too high" do
37
37
  should.raise(Tweeb::ClientError) { @tweeb.friends_timeline(:count => 400) }
38
38
  end
39
+
40
+ it "should return a hash with symbolized keys when following a user" do
41
+ @tweeb.follow("mikedamage")
42
+ end
39
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mikedamage-tweeb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Green