lunker 0.0.5 → 0.0.7
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/lib/lunker/paged_resource.rb +0 -3
- data/lib/lunker.rb +15 -4
- metadata +4 -4
data/lib/lunker.rb
CHANGED
@@ -32,9 +32,6 @@ module Lunker
|
|
32
32
|
include Lunker::PagedResource
|
33
33
|
include Lunker::Utils
|
34
34
|
|
35
|
-
def initialize
|
36
|
-
end
|
37
|
-
|
38
35
|
def users(size_limit, parameters={:sort=>'reputation',:order =>'desc',:min =>'100000'})
|
39
36
|
parameters = {
|
40
37
|
:pagesize => "100",
|
@@ -46,6 +43,20 @@ module Lunker
|
|
46
43
|
|
47
44
|
get_paged_resource "#{SO_URL}/users?#{encoded_parameters}", size_limit
|
48
45
|
end
|
46
|
+
|
47
|
+
# These can only take 100 requests at a time, so split the ids up into batches and run sequentially
|
48
|
+
%w(questions answers).each do |meth|
|
49
|
+
define_method(meth) do |ids|
|
50
|
+
res = []
|
51
|
+
batch = ids.slice!(0...100)
|
52
|
+
while batch.length > 0
|
53
|
+
url = "#{SO_URL}/#{meth}/#{batch.join(";")}?pagesize=100&key=#{Lunker.configuration.api_key}&site=stackoverflow&filter=#{Lunker.configuration.filter}"
|
54
|
+
res += get_paged_resource url
|
55
|
+
batch = ids.slice!(0...100)
|
56
|
+
end
|
57
|
+
res
|
58
|
+
end
|
59
|
+
end
|
49
60
|
end
|
50
61
|
|
51
62
|
class User
|
@@ -57,7 +68,7 @@ module Lunker
|
|
57
68
|
%w(answers questions comments tags).each do |meth|
|
58
69
|
define_method(meth) do |*sort|
|
59
70
|
url = "#{SO_URL}/users/#{@id}/#{meth}?pagesize=100&key=#{Lunker.configuration.api_key}&site=stackoverflow&filter=#{Lunker.configuration.filter}"
|
60
|
-
# Horribleness to
|
71
|
+
# Horribleness to allow an optional sort parameter
|
61
72
|
unless sort.empty?
|
62
73
|
url = "#{url}&sort=#{sort[0]}"
|
63
74
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lunker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-04-01 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152363940 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152363940
|
25
25
|
description: See the summary.
|
26
26
|
email: jergason@gmail.com
|
27
27
|
executables: []
|
@@ -51,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
51
51
|
version: '0'
|
52
52
|
requirements: []
|
53
53
|
rubyforge_project:
|
54
|
-
rubygems_version: 1.8.
|
54
|
+
rubygems_version: 1.8.10
|
55
55
|
signing_key:
|
56
56
|
specification_version: 3
|
57
57
|
summary: A wrapper for the StackExchange API.
|