stack_overflow 0.0.1 → 0.0.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.rdoc CHANGED
@@ -4,6 +4,8 @@ This is a simple gem that utilizes HTTParty and the StackOverflow API.
4
4
 
5
5
  gem install stack_overflow
6
6
 
7
+ The StackOverflow API help can be found at http://api.stackoverflow.com/1.0/help
8
+
7
9
  == Set API Key
8
10
 
9
11
  Be sure to set the API Key.
@@ -12,9 +14,15 @@ Be sure to set the API Key.
12
14
 
13
15
  You can get your key from StackOverflow by going here : http://stackapps.com/apps/register
14
16
 
15
- == Get Flair
17
+ == Get User(s)
18
+
19
+ API documentation can be found at http://api.stackoverflow.com/1.0/help/method?method=users/{id}
20
+
21
+ StackOverflow.get_user(#user_id)
22
+
23
+ You can also get a group of users by using
16
24
 
17
- StackOverflow.get_flair(#user_id)
25
+ StackOverflow.get_users([#user_id1, #user_id2, etc])
18
26
 
19
27
  == Work in progress
20
28
 
@@ -1,3 +1,3 @@
1
1
  module StackOverflow
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -8,8 +8,14 @@ class StackOverflow
8
8
  @@API_KEY = value
9
9
  end
10
10
 
11
- def self.get_flair(user_id)
12
- get("http://stackoverflow.com/users/flair/#{user_id}.json?key=#{@@API_KEY}")
11
+ def self.get_user(user_id)
12
+ result = get("http://api.stackoverflow.com/1.0/users/#{user_id}?key=#{@@API_KEY}")
13
+ result["users"].first
13
14
  end
14
15
 
16
+ def self.get_users(user_ids)
17
+ user_id = user_ids.join(";").to_s
18
+ result = get("http://api.stackoverflow.com/1.0/users/#{user_id}?key=#{@@API_KEY}")
19
+ result["users"]
20
+ end
15
21
  end
@@ -5,12 +5,22 @@ describe StackOverflow do
5
5
  StackOverflow.API_KEY = ENV["SO_API_KEY"]
6
6
  end
7
7
 
8
- describe "get flair" do
8
+ describe "get user" do
9
9
  before(:each) do
10
- @flair = StackOverflow.get_flair(60336)
10
+ @user = StackOverflow.get_user(60336)
11
11
  end
12
- it { @flair.should_not be_nil }
13
- it { @flair["displayName"].should == "JB"}
12
+ it { @user.should_not be_nil }
13
+ it { @user["display_name"].should == "JB"}
14
14
  end
15
15
 
16
+ describe "get user2" do
17
+ before(:each) do
18
+ @users = StackOverflow.get_users([60336, 3381])
19
+ end
20
+ it { @users.should_not be_nil }
21
+ it { @users.select{|u| u["display_name"] == "JB"}.should_not be_nil }
22
+ it { @users.select{|u| u["display_name"] == "Ben Scheirman"}.should_not be_nil }
23
+ end
24
+
25
+
16
26
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jonathan Birkholz