pilha 0.1.1
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/pilha.rb +92 -0
- data/lib/pilha/stack_overflow/badge.rb +29 -0
- data/lib/pilha/stack_overflow/statistics.rb +29 -0
- data/lib/pilha/stack_overflow/user.rb +33 -0
- data/pilha.gemspec +26 -0
- data/spec/fixtures/badges.json +400 -0
- data/spec/fixtures/badges_by_id.json +966 -0
- data/spec/fixtures/badges_by_id_page2.json +1612 -0
- data/spec/fixtures/badges_name.json +400 -0
- data/spec/fixtures/stats.json +20 -0
- data/spec/pilha/stack_overflow/badge_spec.rb +23 -0
- data/spec/pilha/stack_overflow/stack_overflow_spec.rb +60 -0
- data/spec/pilha/stack_overflow/statistics_spec.rb +27 -0
- data/spec/pilha/stack_overflow/user_spec.rb +47 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +33 -0
- metadata +77 -0
@@ -0,0 +1,400 @@
|
|
1
|
+
{
|
2
|
+
"badges": [
|
3
|
+
{
|
4
|
+
"badge_id": 9,
|
5
|
+
"rank": "bronze",
|
6
|
+
"name": "Autobiographer",
|
7
|
+
"description": "Completed all user profile fields",
|
8
|
+
"award_count": 28066,
|
9
|
+
"tag_based": false,
|
10
|
+
"badges_recipients_url": "/badges/9"
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"badge_id": 30,
|
14
|
+
"rank": "silver",
|
15
|
+
"name": "Beta",
|
16
|
+
"description": "Actively participated in the Stack Overflow private beta",
|
17
|
+
"award_count": 2606,
|
18
|
+
"tag_based": false,
|
19
|
+
"badges_recipients_url": "/badges/30"
|
20
|
+
},
|
21
|
+
{
|
22
|
+
"badge_id": 8,
|
23
|
+
"rank": "bronze",
|
24
|
+
"name": "Citizen Patrol",
|
25
|
+
"description": "First flagged post",
|
26
|
+
"award_count": 5690,
|
27
|
+
"tag_based": false,
|
28
|
+
"badges_recipients_url": "/badges/8"
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"badge_id": 32,
|
32
|
+
"rank": "silver",
|
33
|
+
"name": "Civic Duty",
|
34
|
+
"description": "Voted 300 or more times",
|
35
|
+
"award_count": 4693,
|
36
|
+
"tag_based": false,
|
37
|
+
"badges_recipients_url": "/badges/32"
|
38
|
+
},
|
39
|
+
{
|
40
|
+
"badge_id": 4,
|
41
|
+
"rank": "bronze",
|
42
|
+
"name": "Cleanup",
|
43
|
+
"description": "First rollback",
|
44
|
+
"award_count": 3813,
|
45
|
+
"tag_based": false,
|
46
|
+
"badges_recipients_url": "/badges/4"
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"badge_id": 31,
|
50
|
+
"rank": "bronze",
|
51
|
+
"name": "Commentator",
|
52
|
+
"description": "Left 10 comments",
|
53
|
+
"award_count": 31097,
|
54
|
+
"tag_based": false,
|
55
|
+
"badges_recipients_url": "/badges/31"
|
56
|
+
},
|
57
|
+
{
|
58
|
+
"badge_id": 7,
|
59
|
+
"rank": "bronze",
|
60
|
+
"name": "Critic",
|
61
|
+
"description": "First down vote",
|
62
|
+
"award_count": 25328,
|
63
|
+
"tag_based": false,
|
64
|
+
"badges_recipients_url": "/badges/7"
|
65
|
+
},
|
66
|
+
{
|
67
|
+
"badge_id": 37,
|
68
|
+
"rank": "bronze",
|
69
|
+
"name": "Disciplined",
|
70
|
+
"description": "Deleted own post with score of 3 or higher",
|
71
|
+
"award_count": 1665,
|
72
|
+
"tag_based": false,
|
73
|
+
"badges_recipients_url": "/badges/37"
|
74
|
+
},
|
75
|
+
{
|
76
|
+
"badge_id": 3,
|
77
|
+
"rank": "bronze",
|
78
|
+
"name": "Editor",
|
79
|
+
"description": "First edit",
|
80
|
+
"award_count": 63224,
|
81
|
+
"tag_based": false,
|
82
|
+
"badges_recipients_url": "/badges/3"
|
83
|
+
},
|
84
|
+
{
|
85
|
+
"badge_id": 155,
|
86
|
+
"rank": "gold",
|
87
|
+
"name": "Electorate",
|
88
|
+
"description": "Voted on 600 questions and 25% or more of total votes are on questions",
|
89
|
+
"award_count": 276,
|
90
|
+
"tag_based": false,
|
91
|
+
"badges_recipients_url": "/badges/155"
|
92
|
+
},
|
93
|
+
{
|
94
|
+
"badge_id": 19,
|
95
|
+
"rank": "silver",
|
96
|
+
"name": "Enlightened",
|
97
|
+
"description": "First answer was accepted with score of 10 or more",
|
98
|
+
"award_count": 11407,
|
99
|
+
"tag_based": false,
|
100
|
+
"badges_recipients_url": "/badges/19"
|
101
|
+
},
|
102
|
+
{
|
103
|
+
"badge_id": 71,
|
104
|
+
"rank": "silver",
|
105
|
+
"name": "Enthusiast",
|
106
|
+
"description": "Visited the site each day for 30 consecutive days",
|
107
|
+
"award_count": 6940,
|
108
|
+
"tag_based": false,
|
109
|
+
"badges_recipients_url": "/badges/71"
|
110
|
+
},
|
111
|
+
{
|
112
|
+
"badge_id": 145,
|
113
|
+
"rank": "silver",
|
114
|
+
"name": "Epic",
|
115
|
+
"description": "Hit the daily reputation cap on 50 days",
|
116
|
+
"award_count": 86,
|
117
|
+
"tag_based": false,
|
118
|
+
"badges_recipients_url": "/badges/145"
|
119
|
+
},
|
120
|
+
{
|
121
|
+
"badge_id": 28,
|
122
|
+
"rank": "gold",
|
123
|
+
"name": "Famous Question",
|
124
|
+
"description": "Asked a question with 10,000 views",
|
125
|
+
"award_count": 1063,
|
126
|
+
"tag_based": false,
|
127
|
+
"badges_recipients_url": "/badges/28"
|
128
|
+
},
|
129
|
+
{
|
130
|
+
"badge_id": 83,
|
131
|
+
"rank": "gold",
|
132
|
+
"name": "Fanatic",
|
133
|
+
"description": "Visited the site each day for 100 consecutive days",
|
134
|
+
"award_count": 937,
|
135
|
+
"tag_based": false,
|
136
|
+
"badges_recipients_url": "/badges/83"
|
137
|
+
},
|
138
|
+
{
|
139
|
+
"badge_id": 33,
|
140
|
+
"rank": "silver",
|
141
|
+
"name": "Favorite Question",
|
142
|
+
"description": "Question favorited by 25 users",
|
143
|
+
"award_count": 1082,
|
144
|
+
"tag_based": false,
|
145
|
+
"badges_recipients_url": "/badges/33"
|
146
|
+
},
|
147
|
+
{
|
148
|
+
"badge_id": 15,
|
149
|
+
"rank": "silver",
|
150
|
+
"name": "Generalist",
|
151
|
+
"description": "Provided non-wiki answers of 15 total score in 20 of top 40 tags",
|
152
|
+
"award_count": 133,
|
153
|
+
"tag_based": false,
|
154
|
+
"badges_recipients_url": "/badges/15"
|
155
|
+
},
|
156
|
+
{
|
157
|
+
"badge_id": 24,
|
158
|
+
"rank": "silver",
|
159
|
+
"name": "Good Answer",
|
160
|
+
"description": "Answer score of 25 or more",
|
161
|
+
"award_count": 9093,
|
162
|
+
"tag_based": false,
|
163
|
+
"badges_recipients_url": "/badges/24"
|
164
|
+
},
|
165
|
+
{
|
166
|
+
"badge_id": 21,
|
167
|
+
"rank": "silver",
|
168
|
+
"name": "Good Question",
|
169
|
+
"description": "Question score of 25 or more",
|
170
|
+
"award_count": 2268,
|
171
|
+
"tag_based": false,
|
172
|
+
"badges_recipients_url": "/badges/21"
|
173
|
+
},
|
174
|
+
{
|
175
|
+
"badge_id": 25,
|
176
|
+
"rank": "gold",
|
177
|
+
"name": "Great Answer",
|
178
|
+
"description": "Answer score of 100 or more",
|
179
|
+
"award_count": 1020,
|
180
|
+
"tag_based": false,
|
181
|
+
"badges_recipients_url": "/badges/25"
|
182
|
+
},
|
183
|
+
{
|
184
|
+
"badge_id": 22,
|
185
|
+
"rank": "gold",
|
186
|
+
"name": "Great Question",
|
187
|
+
"description": "Question score of 100 or more",
|
188
|
+
"award_count": 197,
|
189
|
+
"tag_based": false,
|
190
|
+
"badges_recipients_url": "/badges/22"
|
191
|
+
},
|
192
|
+
{
|
193
|
+
"badge_id": 18,
|
194
|
+
"rank": "silver",
|
195
|
+
"name": "Guru",
|
196
|
+
"description": "Accepted answer and score of 40 or more",
|
197
|
+
"award_count": 1128,
|
198
|
+
"tag_based": false,
|
199
|
+
"badges_recipients_url": "/badges/18"
|
200
|
+
},
|
201
|
+
{
|
202
|
+
"badge_id": 146,
|
203
|
+
"rank": "gold",
|
204
|
+
"name": "Legendary",
|
205
|
+
"description": "Hit the daily reputation cap on 150 days",
|
206
|
+
"award_count": 18,
|
207
|
+
"tag_based": false,
|
208
|
+
"badges_recipients_url": "/badges/146"
|
209
|
+
},
|
210
|
+
{
|
211
|
+
"badge_id": 144,
|
212
|
+
"rank": "bronze",
|
213
|
+
"name": "Mortarboard",
|
214
|
+
"description": "Hit the daily reputation cap for the first time",
|
215
|
+
"award_count": 4128,
|
216
|
+
"tag_based": false,
|
217
|
+
"badges_recipients_url": "/badges/144"
|
218
|
+
},
|
219
|
+
{
|
220
|
+
"badge_id": 17,
|
221
|
+
"rank": "silver",
|
222
|
+
"name": "Necromancer",
|
223
|
+
"description": "Answered a question more than 60 days later with score of 5 or more",
|
224
|
+
"award_count": 4894,
|
225
|
+
"tag_based": false,
|
226
|
+
"badges_recipients_url": "/badges/17"
|
227
|
+
},
|
228
|
+
{
|
229
|
+
"badge_id": 23,
|
230
|
+
"rank": "bronze",
|
231
|
+
"name": "Nice Answer",
|
232
|
+
"description": "Answer score of 10 or more",
|
233
|
+
"award_count": 55511,
|
234
|
+
"tag_based": false,
|
235
|
+
"badges_recipients_url": "/badges/23"
|
236
|
+
},
|
237
|
+
{
|
238
|
+
"badge_id": 20,
|
239
|
+
"rank": "bronze",
|
240
|
+
"name": "Nice Question",
|
241
|
+
"description": "Question score of 10 or more",
|
242
|
+
"award_count": 13355,
|
243
|
+
"tag_based": false,
|
244
|
+
"badges_recipients_url": "/badges/20"
|
245
|
+
},
|
246
|
+
{
|
247
|
+
"badge_id": 27,
|
248
|
+
"rank": "silver",
|
249
|
+
"name": "Notable Question",
|
250
|
+
"description": "Asked a question with 2,500 views",
|
251
|
+
"award_count": 14373,
|
252
|
+
"tag_based": false,
|
253
|
+
"badges_recipients_url": "/badges/27"
|
254
|
+
},
|
255
|
+
{
|
256
|
+
"badge_id": 5,
|
257
|
+
"rank": "bronze",
|
258
|
+
"name": "Organizer",
|
259
|
+
"description": "First retag",
|
260
|
+
"award_count": 12069,
|
261
|
+
"tag_based": false,
|
262
|
+
"badges_recipients_url": "/badges/5"
|
263
|
+
},
|
264
|
+
{
|
265
|
+
"badge_id": 38,
|
266
|
+
"rank": "bronze",
|
267
|
+
"name": "Peer Pressure",
|
268
|
+
"description": "Deleted own post with score of -3 or lower",
|
269
|
+
"award_count": 2965,
|
270
|
+
"tag_based": false,
|
271
|
+
"badges_recipients_url": "/badges/38"
|
272
|
+
},
|
273
|
+
{
|
274
|
+
"badge_id": 26,
|
275
|
+
"rank": "bronze",
|
276
|
+
"name": "Popular Question",
|
277
|
+
"description": "Asked a question with 1,000 views",
|
278
|
+
"award_count": 51937,
|
279
|
+
"tag_based": false,
|
280
|
+
"badges_recipients_url": "/badges/26"
|
281
|
+
},
|
282
|
+
{
|
283
|
+
"badge_id": 62,
|
284
|
+
"rank": "gold",
|
285
|
+
"name": "Populist",
|
286
|
+
"description": "Answer outscored an accepted answer with score of more than 10 by more than 2x",
|
287
|
+
"award_count": 344,
|
288
|
+
"tag_based": false,
|
289
|
+
"badges_recipients_url": "/badges/62"
|
290
|
+
},
|
291
|
+
{
|
292
|
+
"badge_id": 94,
|
293
|
+
"rank": "silver",
|
294
|
+
"name": "Pundit",
|
295
|
+
"description": "Left 10 comments with score of 10 or more",
|
296
|
+
"award_count": 83,
|
297
|
+
"tag_based": false,
|
298
|
+
"badges_recipients_url": "/badges/94"
|
299
|
+
},
|
300
|
+
{
|
301
|
+
"badge_id": 95,
|
302
|
+
"rank": "gold",
|
303
|
+
"name": "Reversal",
|
304
|
+
"description": "Provided answer of +20 score to a question of -5 score",
|
305
|
+
"award_count": 38,
|
306
|
+
"tag_based": false,
|
307
|
+
"badges_recipients_url": "/badges/95"
|
308
|
+
},
|
309
|
+
{
|
310
|
+
"badge_id": 10,
|
311
|
+
"rank": "bronze",
|
312
|
+
"name": "Scholar",
|
313
|
+
"description": "Asked a question and accepted an answer",
|
314
|
+
"award_count": 69357,
|
315
|
+
"tag_based": false,
|
316
|
+
"badges_recipients_url": "/badges/10"
|
317
|
+
},
|
318
|
+
{
|
319
|
+
"badge_id": 14,
|
320
|
+
"rank": "bronze",
|
321
|
+
"name": "Self-Learner",
|
322
|
+
"description": "Answered your own question with score of 3 or more",
|
323
|
+
"award_count": 3841,
|
324
|
+
"tag_based": false,
|
325
|
+
"badges_recipients_url": "/badges/14"
|
326
|
+
},
|
327
|
+
{
|
328
|
+
"badge_id": 36,
|
329
|
+
"rank": "gold",
|
330
|
+
"name": "Stellar Question",
|
331
|
+
"description": "Question favorited by 100 users",
|
332
|
+
"award_count": 153,
|
333
|
+
"tag_based": false,
|
334
|
+
"badges_recipients_url": "/badges/36"
|
335
|
+
},
|
336
|
+
{
|
337
|
+
"badge_id": 12,
|
338
|
+
"rank": "silver",
|
339
|
+
"name": "Strunk & White",
|
340
|
+
"description": "Edited 100 entries",
|
341
|
+
"award_count": 649,
|
342
|
+
"tag_based": false,
|
343
|
+
"badges_recipients_url": "/badges/12"
|
344
|
+
},
|
345
|
+
{
|
346
|
+
"badge_id": 2,
|
347
|
+
"rank": "bronze",
|
348
|
+
"name": "Student",
|
349
|
+
"description": "Asked first question with at least one up vote",
|
350
|
+
"award_count": 85755,
|
351
|
+
"tag_based": false,
|
352
|
+
"badges_recipients_url": "/badges/2"
|
353
|
+
},
|
354
|
+
{
|
355
|
+
"badge_id": 6,
|
356
|
+
"rank": "bronze",
|
357
|
+
"name": "Supporter",
|
358
|
+
"description": "First up vote",
|
359
|
+
"award_count": 61321,
|
360
|
+
"tag_based": false,
|
361
|
+
"badges_recipients_url": "/badges/6"
|
362
|
+
},
|
363
|
+
{
|
364
|
+
"badge_id": 11,
|
365
|
+
"rank": "silver",
|
366
|
+
"name": "Taxonomist",
|
367
|
+
"description": "Created a tag used by 50 questions",
|
368
|
+
"award_count": 2083,
|
369
|
+
"tag_based": false,
|
370
|
+
"badges_recipients_url": "/badges/11"
|
371
|
+
},
|
372
|
+
{
|
373
|
+
"badge_id": 1,
|
374
|
+
"rank": "bronze",
|
375
|
+
"name": "Teacher",
|
376
|
+
"description": "Answered first question with score of 1 or more",
|
377
|
+
"award_count": 71525,
|
378
|
+
"tag_based": false,
|
379
|
+
"badges_recipients_url": "/badges/1"
|
380
|
+
},
|
381
|
+
{
|
382
|
+
"badge_id": 63,
|
383
|
+
"rank": "bronze",
|
384
|
+
"name": "Tumbleweed",
|
385
|
+
"description": "Asked a question with no answers, no comments, and low views for a week",
|
386
|
+
"award_count": 23224,
|
387
|
+
"tag_based": false,
|
388
|
+
"badges_recipients_url": "/badges/63"
|
389
|
+
},
|
390
|
+
{
|
391
|
+
"badge_id": 13,
|
392
|
+
"rank": "silver",
|
393
|
+
"name": "Yearling",
|
394
|
+
"description": "Active member for a year, earning at least 200 reputation",
|
395
|
+
"award_count": 19443,
|
396
|
+
"tag_based": false,
|
397
|
+
"badges_recipients_url": "/badges/13"
|
398
|
+
}
|
399
|
+
]
|
400
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"statistics": [
|
3
|
+
{
|
4
|
+
"total_questions": 692539,
|
5
|
+
"total_unanswered": 107245,
|
6
|
+
"total_answers": 1938135,
|
7
|
+
"total_comments": 2724322,
|
8
|
+
"total_votes": 6817279,
|
9
|
+
"total_badges": 699700,
|
10
|
+
"total_users": 247683,
|
11
|
+
"questions_per_minute": 1.78,
|
12
|
+
"answers_per_minute": 3.71,
|
13
|
+
"badges_per_minute": 1.58,
|
14
|
+
"api_version": {
|
15
|
+
"version": "0.8",
|
16
|
+
"revision": "1.0.1234.5678"
|
17
|
+
}
|
18
|
+
}
|
19
|
+
]
|
20
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe StackExchange::StackOverflow::Badge do
|
4
|
+
|
5
|
+
before do
|
6
|
+
StackExchange::StackOverflow::Client.config
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'when querying for badges' do
|
10
|
+
it 'should return badges' do
|
11
|
+
response = StackOverflow::Badge.all
|
12
|
+
first_badge = response.first
|
13
|
+
first_badge.badge_id.should == 9
|
14
|
+
first_badge.id.should == 9
|
15
|
+
first_badge.rank.should == "bronze"
|
16
|
+
first_badge.name.should == "Autobiographer"
|
17
|
+
first_badge.description.should == "Completed all user profile fields"
|
18
|
+
first_badge.award_count.should == 28065
|
19
|
+
first_badge.tag_based.should be_false
|
20
|
+
first_badge.badges_recipients_url.should == "/badges/9"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe StackOverflow::Client do
|
4
|
+
before do
|
5
|
+
@client = StackOverflow::Client.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should provide the api method path with its parameters' do
|
9
|
+
url1 = @client.api_method_path('/foo/bar')
|
10
|
+
url1.should == '/foo/bar/'
|
11
|
+
|
12
|
+
url2 = @client.api_method_path('/foo/:bar/', :bar => 2)
|
13
|
+
url2.should == '/foo/2/'
|
14
|
+
|
15
|
+
url3 = @client.api_method_path('/foo/:bar/eggs', :bar => 'fried')
|
16
|
+
url3.should == '/foo/fried/eggs/'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should provide the full url for the api method' do
|
20
|
+
url = @client.api_method_url('/foo/bar', :query => { :name => 'smith', :lastname => 'smith'})
|
21
|
+
url.should == @client.root_path + '/foo/bar/?lastname=smith&name=smith'
|
22
|
+
|
23
|
+
url2 = @client.api_method_url('/foo/:bar', :bar => 2)
|
24
|
+
url2.should == @client.root_path + '/foo/2/'
|
25
|
+
|
26
|
+
url3 = @client.api_method_url('/foo/:bar/eggs', :bar => :fried, :query => { :with => 'bacon'} )
|
27
|
+
url3.should == @client.root_path + '/foo/fried/eggs/?with=bacon'
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'when using #config for configuration setup' do
|
31
|
+
before do
|
32
|
+
@client = StackOverflow::Client.new
|
33
|
+
@old_url = @client.url
|
34
|
+
|
35
|
+
StackOverflow::Client.config do |options|
|
36
|
+
options[:url] = 'http://test.it'
|
37
|
+
options[:api_version] = '666'
|
38
|
+
options[:api_key] = 'key1234'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
after do
|
43
|
+
StackOverflow::Client.config do |options|
|
44
|
+
options[:url] = @old_url
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should modify the api url' do
|
49
|
+
StackOverflow::Statistics.client.url.should == 'http://test.it/'
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should modify the api version' do
|
53
|
+
StackOverflow::Statistics.client.api_version.should == '666'
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should modify the api key' do
|
57
|
+
StackOverflow::Statistics.client.api_key.should == 'key1234'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|