jnunemaker-twitter 0.6.5 → 0.6.6

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/History CHANGED
@@ -1,3 +1,11 @@
1
+ 0.6.6 - April 16, 2009
2
+ * 1 minor enhancement
3
+ * added ability to pass query parameters to user method
4
+ * httpauth can now accept :ssl option to use https instead of http
5
+ * Added Twitter.status method for no auth calls to fetch status
6
+ * Added Twitter.friend_ids method for no auth calls to fetch status
7
+ * Added Twitter.follower_ids method for no auth calls to fetch status
8
+
1
9
  0.6.5 - April 15, 2009
2
10
  * 1 bug fix
3
11
  * fixed that friend_ids and follower_ids were bombing from trying to mash them. Added :mash option to Twitter::Request so I can specifically not mash certain responses from twitter
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 6
4
- :patch: 5
4
+ :patch: 6
@@ -0,0 +1,16 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
2
+ require 'pp'
3
+
4
+ puts 'User', '*'*50
5
+ pp Twitter.user('jnunemaker')
6
+ pp Twitter.user('snitch_test')
7
+
8
+ puts 'Status', '*'*50
9
+ pp Twitter.status(1533815199)
10
+
11
+ puts 'Friend Ids', '*'*50
12
+ pp Twitter.friend_ids('jnunemaker')
13
+
14
+ puts 'Follower Ids', '*'*50
15
+ pp Twitter.follower_ids('jnunemaker')
16
+
data/lib/twitter/base.rb CHANGED
@@ -48,8 +48,8 @@ module Twitter
48
48
  perform_get('/statuses/followers.json', :query => query)
49
49
  end
50
50
 
51
- def user(id)
52
- perform_get("/users/show/#{id}.json")
51
+ def user(id, query={})
52
+ perform_get("/users/show/#{id}.json", :query => query)
53
53
  end
54
54
 
55
55
  # Options: since, since_id, page
@@ -1,13 +1,14 @@
1
1
  module Twitter
2
2
  class HTTPAuth
3
3
  include HTTParty
4
- base_uri 'http://twitter.com'
5
4
  format :plain
6
5
 
7
- attr_reader :username, :password
6
+ attr_reader :username, :password, :options
8
7
 
9
- def initialize(username, password)
8
+ def initialize(username, password, options={})
10
9
  @username, @password = username, password
10
+ @options = {:ssl => false}.merge(options)
11
+ self.class.base_uri "http#{'s' if options[:ssl]}://twitter.com"
11
12
  end
12
13
 
13
14
  def get(uri, headers={})
data/lib/twitter.rb CHANGED
@@ -38,6 +38,19 @@ module Twitter
38
38
  response = HTTParty.get("http://twitter.com/users/show/#{id}.json", :format => :json)
39
39
  Mash.new(response)
40
40
  end
41
+
42
+ def self.status(id)
43
+ response = HTTParty.get("http://twitter.com/statuses/show/#{id}.json", :format => :json)
44
+ Mash.new(response)
45
+ end
46
+
47
+ def self.friend_ids(id)
48
+ HTTParty.get("http://twitter.com/friends/ids/#{id}.json", :format => :json)
49
+ end
50
+
51
+ def self.follower_ids(id)
52
+ HTTParty.get("http://twitter.com/followers/ids/#{id}.json", :format => :json)
53
+ end
41
54
  end
42
55
 
43
56
  directory = File.dirname(__FILE__)
@@ -0,0 +1 @@
1
+ {"in_reply_to_screen_name":null,"user":{"profile_background_image_url":"http:\/\/static.twitter.com\/images\/themes\/theme9\/bg.gif","description":"Loves his wife, ruby, notre dame football and iu basketball","time_zone":"Indiana (East)","utc_offset":-18000,"friends_count":161,"profile_sidebar_border_color":"181A1E","following":false,"favourites_count":80,"notifications":false,"profile_background_color":"1A1B1F","url":"http:\/\/railstips.org\/about","name":"John Nunemaker","statuses_count":4771,"protected":false,"profile_background_tile":false,"profile_text_color":"666666","created_at":"Sun Aug 13 22:56:06 +0000 2006","profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","profile_link_color":"2FC2EF","location":"Mishawaka, Indiana","screen_name":"jnunemaker","id":4243,"profile_sidebar_fill_color":"252429","followers_count":1252},"text":"Eating some oatmeal and butterscotch cookies with a cold glass of milk for breakfast. Tasty!","truncated":false,"in_reply_to_status_id":null,"created_at":"Thu Apr 16 14:12:36 +0000 2009","in_reply_to_user_id":null,"id":1533815199,"favorited":false,"source":"<a href=\"http:\/\/twitter.rubyforge.org\">Twitter App<\/a>"}
@@ -7,6 +7,26 @@ class HTTPAuthTest < Test::Unit::TestCase
7
7
  twitter.username.should == 'username'
8
8
  twitter.password.should == 'password'
9
9
  end
10
+
11
+ should "accept options" do
12
+ twitter = Twitter::HTTPAuth.new('username', 'password', :ssl => true)
13
+ twitter.options.should == {:ssl => true}
14
+ end
15
+
16
+ should "default ssl to false" do
17
+ twitter = Twitter::HTTPAuth.new('username', 'password')
18
+ twitter.options[:ssl].should be(false)
19
+ end
20
+
21
+ should "use https if ssl is true" do
22
+ Twitter::HTTPAuth.expects(:base_uri).with('https://twitter.com')
23
+ twitter = Twitter::HTTPAuth.new('username', 'password', :ssl => true)
24
+ end
25
+
26
+ should "use http if ssl is false" do
27
+ Twitter::HTTPAuth.expects(:base_uri).with('http://twitter.com')
28
+ twitter = Twitter::HTTPAuth.new('username', 'password', :ssl => false)
29
+ end
10
30
  end
11
31
 
12
32
  context "Client methods" do
data/test/twitter_test.rb CHANGED
@@ -16,4 +16,23 @@ class TwitterTest < Test::Unit::TestCase
16
16
  user.name.should == 'John Nunemaker'
17
17
  user.description.should == 'Loves his wife, ruby, notre dame football and iu basketball'
18
18
  end
19
+
20
+ should "have status method for unauthenticated calls to get a status" do
21
+ stub_get('http://twitter.com:80/statuses/show/1533815199.json', 'status_show.json')
22
+ status = Twitter.status(1533815199)
23
+ status.id.should == 1533815199
24
+ status.text.should == 'Eating some oatmeal and butterscotch cookies with a cold glass of milk for breakfast. Tasty!'
25
+ end
26
+
27
+ should "have friend_ids method" do
28
+ stub_get('http://twitter.com:80/friends/ids/jnunemaker.json', 'friend_ids.json')
29
+ ids = Twitter.friend_ids('jnunemaker')
30
+ ids.size.should == 161
31
+ end
32
+
33
+ should "have follower_ids method" do
34
+ stub_get('http://twitter.com:80/followers/ids/jnunemaker.json', 'follower_ids.json')
35
+ ids = Twitter.follower_ids('jnunemaker')
36
+ ids.size.should == 1252
37
+ end
19
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jnunemaker-twitter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-15 00:00:00 -07:00
12
+ date: 2009-04-16 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -114,6 +114,7 @@ files:
114
114
  - examples/ids.rb
115
115
  - examples/search.rb
116
116
  - examples/timeline.rb
117
+ - examples/unauthorized.rb
117
118
  - examples/update.rb
118
119
  - examples/user.rb
119
120
  - lib/twitter.rb
@@ -131,6 +132,7 @@ files:
131
132
  - test/fixtures/search.json
132
133
  - test/fixtures/search_from_jnunemaker.json
133
134
  - test/fixtures/status.json
135
+ - test/fixtures/status_show.json
134
136
  - test/fixtures/user.json
135
137
  - test/fixtures/user_timeline.json
136
138
  - test/test_helper.rb
@@ -181,5 +183,6 @@ test_files:
181
183
  - examples/ids.rb
182
184
  - examples/search.rb
183
185
  - examples/timeline.rb
186
+ - examples/unauthorized.rb
184
187
  - examples/update.rb
185
188
  - examples/user.rb