stack_overflow 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +3 -1
- data/README.rdoc +10 -0
- data/lib/.stack_overflow.rb.swp +0 -0
- data/lib/stack_overflow/version.rb +1 -1
- data/lib/stack_overflow.rb +11 -0
- data/spec/stack_overflow_spec.rb +23 -0
- data/stack_overflow.gemspec +1 -0
- metadata +16 -3
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
stack_overflow (0.0.
|
4
|
+
stack_overflow (0.0.6)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: http://rubygems.org/
|
@@ -10,6 +10,7 @@ GEM
|
|
10
10
|
diff-lcs (1.1.2)
|
11
11
|
httparty (0.6.1)
|
12
12
|
crack (= 0.1.8)
|
13
|
+
json (1.4.6)
|
13
14
|
rspec (2.4.0)
|
14
15
|
rspec-core (~> 2.4.0)
|
15
16
|
rspec-expectations (~> 2.4.0)
|
@@ -24,5 +25,6 @@ PLATFORMS
|
|
24
25
|
|
25
26
|
DEPENDENCIES
|
26
27
|
httparty
|
28
|
+
json
|
27
29
|
rspec
|
28
30
|
stack_overflow!
|
data/README.rdoc
CHANGED
@@ -14,6 +14,16 @@ Be sure to set the API Key.
|
|
14
14
|
|
15
15
|
You can get your key from StackOverflow by going here : http://stackapps.com/apps/register
|
16
16
|
|
17
|
+
== Get all Users
|
18
|
+
|
19
|
+
API documentation can be found at http://api.stackoverflow.com/1.1/usage/methods/users
|
20
|
+
|
21
|
+
StackOverflow.get_all_users
|
22
|
+
|
23
|
+
By default the api returns the first page of users with 30 per page. This information can be read from the results. To get additional pages or change the pagesize (0-100) you can make call like:
|
24
|
+
|
25
|
+
StackOverflow.get_all_users(:page => 2, :per_page => 50)
|
26
|
+
|
17
27
|
== Get User(s)
|
18
28
|
|
19
29
|
API documentation can be found at http://api.stackoverflow.com/1.1/usage/methods/users-by-ids
|
data/lib/.stack_overflow.rb.swp
CHANGED
Binary file
|
data/lib/stack_overflow.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'httparty'
|
2
|
+
require 'json'
|
2
3
|
|
3
4
|
class StackOverflow
|
4
5
|
include HTTParty
|
@@ -9,6 +10,16 @@ class StackOverflow
|
|
9
10
|
@@API_KEY = value
|
10
11
|
end
|
11
12
|
|
13
|
+
def self.get_all_users(options={})
|
14
|
+
key = @@API_KEY
|
15
|
+
page = options[:page] || 1
|
16
|
+
pagesize = options[:pagesize] || 30
|
17
|
+
url = URI.parse(@@URL + "users?key=#{key}&page=#{page}&pagesize=#{pagesize}")
|
18
|
+
response = Net::HTTP.get_response url
|
19
|
+
gz = Zlib::GzipReader.new(StringIO.new(response.body))
|
20
|
+
JSON.parse(gz.read)
|
21
|
+
end
|
22
|
+
|
12
23
|
def self.get_user(user_id)
|
13
24
|
result = get(@@URL + "users/#{user_id}?key=#{@@API_KEY}")
|
14
25
|
result["users"].first
|
data/spec/stack_overflow_spec.rb
CHANGED
@@ -4,6 +4,29 @@ describe StackOverflow do
|
|
4
4
|
before(:each) do
|
5
5
|
StackOverflow.API_KEY = ENV["SO_API_KEY"]
|
6
6
|
end
|
7
|
+
|
8
|
+
describe "get all users" do
|
9
|
+
context "all users" do
|
10
|
+
before(:each) do
|
11
|
+
@result = StackOverflow.get_all_users
|
12
|
+
end
|
13
|
+
it { @result.should_not be_nil }
|
14
|
+
end
|
15
|
+
|
16
|
+
context "second page" do
|
17
|
+
before(:each) do
|
18
|
+
@result = StackOverflow.get_all_users(:page => 2)
|
19
|
+
end
|
20
|
+
it { @result.should_not be_nil }
|
21
|
+
end
|
22
|
+
|
23
|
+
context "50 per page" do
|
24
|
+
before(:each) do
|
25
|
+
@result = StackOverflow.get_all_users(:pagesize => 50)
|
26
|
+
end
|
27
|
+
it { @result["users"].count.should == 50 }
|
28
|
+
end
|
29
|
+
end
|
7
30
|
|
8
31
|
describe "get user" do
|
9
32
|
before(:each) do
|
data/stack_overflow.gemspec
CHANGED
@@ -16,6 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
|
17
17
|
s.add_development_dependency "rspec"
|
18
18
|
s.add_development_dependency "httparty"
|
19
|
+
s.add_development_dependency "json"
|
19
20
|
|
20
21
|
s.files = `git ls-files`.split("\n")
|
21
22
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 7
|
9
|
+
version: 0.0.7
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jonathan Birkholz
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-06-02 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -43,6 +43,19 @@ dependencies:
|
|
43
43
|
version: "0"
|
44
44
|
type: :development
|
45
45
|
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: json
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
type: :development
|
58
|
+
version_requirements: *id003
|
46
59
|
description: HTTParty over the StackOverflow API
|
47
60
|
email:
|
48
61
|
- rookieone@gmail.com
|