pilha 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,49 @@
1
+ = Pilha
2
+
3
+ A object oriented wrapper for the StackExchange/StackOverflow API
4
+
5
+ == Why such a strange name?
6
+
7
+ 'Pilha'(pronounced peeleeah) means 'stack' in portuguese.
8
+
9
+ == Instalation
10
+
11
+ gem install pilha
12
+
13
+ == Example
14
+
15
+ Pilha aims to provide a ActiveRecord like interface for querying the StackExchange API.
16
+
17
+ include StackExchange::StackOverflow
18
+ StackExchange::StackOverflow::Client.config do |options|
19
+ options.api_key = 'your_key' #optional
20
+ end
21
+
22
+ Badge.all # returns all badges
23
+ User.find_by_badge_id(2) # returns all users awarded by the badge identified with 'id'
24
+
25
+ = License
26
+
27
+ (The MIT License)
28
+
29
+ Copyright (c) 2010-2010 Dalto Curvelano Junior
30
+
31
+ Permission is hereby granted, free of charge, to any person obtaining
32
+ a copy of this software and associated documentation files (the
33
+ "Software"), to deal in the Software without restriction, including
34
+ without limitation the rights to use, copy, modify, merge, publish,
35
+ distribute, sublicense, and/or sell copies of the Software, and to
36
+ permit persons to whom the Software is furnished to do so, subject to
37
+ the following conditions:
38
+
39
+ The above copyright notice and this permission notice shall be
40
+ included in all copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
43
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
46
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
47
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
48
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
49
+
@@ -0,0 +1,24 @@
1
+ module StackExchange
2
+ module StackOverflow
3
+ class Tag < Base
4
+ extend Forwardable
5
+
6
+ def_delegators :@struct, :name, :count, :user_id
7
+
8
+ class << self
9
+ def all(options = {})
10
+ request('/tags', nil, options)
11
+ end
12
+
13
+ def find_by_user_id(id, options = {})
14
+ request('/users/:id/tags', id, options)
15
+ end
16
+
17
+ def parse(response)
18
+ parse_with_class(response, 'tags', Tag)
19
+ OpenStruct.new response
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe StackExchange::StackOverflow::Tag do
4
+
5
+ it 'should get all tags' do
6
+ response = StackOverflow::Tag.all
7
+ response.total.should == 29199
8
+ response.pagesize.should == 70
9
+ response.page == 1
10
+
11
+ response.tags.should have(response.pagesize).tags
12
+
13
+ tag = response.tags.first
14
+ tag.name.should == "c#"
15
+ tag.count.should == 84875
16
+ end
17
+
18
+ it 'should find all tags used by an user identified by id' do
19
+ response = StackOverflow::Tag.find_by_user_id(549)
20
+ response.total.should == 151
21
+ response.page.should == 1
22
+
23
+
24
+ tag = response.tags.first
25
+ tag.name.should == ".net"
26
+ tag.count.should == 25
27
+ tag.user_id.should == 549
28
+
29
+ response.tags.should have(response.pagesize).tags
30
+
31
+ response.tags.each do |tag|
32
+ tag.user_id.should == 549
33
+ end
34
+ end
35
+
36
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pilha
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 11
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 1
8
- - 7
9
- version: 0.1.7
9
+ - 8
10
+ version: 0.1.8
10
11
  platform: ruby
11
12
  authors:
12
13
  - Dalto Curvelano Junior
@@ -14,10 +15,23 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-06-03 00:00:00 -03:00
18
+ date: 2010-12-10 00:00:00 -02:00
18
19
  default_executable:
19
- dependencies: []
20
-
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :development
34
+ version_requirements: *id001
21
35
  description: A ruby wrapper to the Stack Exchange (Stack Overflow and friends) API.
22
36
  email:
23
37
  executables: []
@@ -27,116 +41,186 @@ extensions: []
27
41
  extra_rdoc_files: []
28
42
 
29
43
  files:
30
- - pilha.gemspec
31
- - lib/pilha.rb
32
- - lib/pilha/stack_overflow/badge.rb
44
+ - lib/pilha/stack_overflow/base.rb
45
+ - lib/pilha/stack_overflow/question.rb
46
+ - lib/pilha/stack_overflow/comment.rb
47
+ - lib/pilha/stack_overflow/tag.rb
33
48
  - lib/pilha/stack_overflow/statistics.rb
49
+ - lib/pilha/stack_overflow/badge.rb
34
50
  - lib/pilha/stack_overflow/user.rb
35
- - lib/pilha/stack_overflow/comment.rb
36
51
  - lib/pilha/stack_overflow/answer.rb
37
- - lib/pilha/stack_overflow/question.rb
38
- - lib/pilha/stack_overflow/base.rb
39
- - spec/pilha/stack_overflow/badge_spec.rb
40
- - spec/pilha/stack_overflow/stack_overflow_spec.rb
52
+ - lib/pilha.rb
53
+ - README.rdoc
41
54
  - spec/pilha/stack_overflow/statistics_spec.rb
42
- - spec/pilha/stack_overflow/user_spec.rb
43
55
  - spec/pilha/stack_overflow/comment_spec.rb
44
- - spec/pilha/stack_overflow/answer_spec.rb
56
+ - spec/pilha/stack_overflow/tag_spec.rb
45
57
  - spec/pilha/stack_overflow/question_spec.rb
58
+ - spec/pilha/stack_overflow/stack_overflow_spec.rb
59
+ - spec/pilha/stack_overflow/badge_spec.rb
60
+ - spec/pilha/stack_overflow/answer_spec.rb
61
+ - spec/pilha/stack_overflow/user_spec.rb
46
62
  - spec/spec.opts
47
- - spec/spec_helper.rb
63
+ - spec/fixtures/tags_by_user_id.json
64
+ - spec/fixtures/questions_tagged_gwt_and_googleappengine.json
65
+ - spec/fixtures/user_tags.json
66
+ - spec/fixtures/answers_by_question_id.json.gz
67
+ - spec/fixtures/badges_name.json
48
68
  - spec/fixtures/comments.json.gz
69
+ - spec/fixtures/answers_by_id.json.gz
49
70
  - spec/fixtures/comments_by_user_id_to_mentioned_user_id.json.gz
50
- - spec/fixtures/question_by_user_id.json.gz
71
+ - spec/fixtures/comments_by_user_to_mentioned_user_id.json.gz
72
+ - spec/fixtures/badges.json.gz
73
+ - spec/fixtures/all_tags.json.gz
74
+ - spec/fixtures/questions_tagged_gwt_and_googleappengine.json.gz
75
+ - spec/fixtures/answers_by_question_id.json
76
+ - spec/fixtures/favorite_questions_by_user_id.json.gz
77
+ - spec/fixtures/answers_by_id.json
51
78
  - spec/fixtures/users_by_id.json
52
- - spec/fixtures/badges.json
53
- - spec/fixtures/questions_unanswered.json
54
79
  - spec/fixtures/questions_tagged_ruby.json.gz
55
- - spec/fixtures/comments_by_user_to_mentioned_user.json
56
- - spec/fixtures/answer_with_comments.json
57
- - spec/fixtures/answers_by_id.json.gz
58
- - spec/fixtures/search_tagged_ruby_rails.json
59
- - spec/fixtures/stats.json
60
- - spec/fixtures/answer_with_comments.json.gz
61
- - spec/fixtures/user_tags.json
62
- - spec/fixtures/badges_name.json
63
- - spec/fixtures/answers_by_question_id.json.gz
64
- - spec/fixtures/badges_tag_based.json
65
- - spec/fixtures/badges.json.gz
66
- - spec/fixtures/comments.json
67
- - spec/fixtures/question_by_id.json
80
+ - spec/fixtures/badges_by_id.json
81
+ - spec/fixtures/badges_name.json.gz
68
82
  - spec/fixtures/tags_by_user_id.json.gz
69
- - spec/fixtures/search_intitle_ruby.json
70
- - spec/fixtures/question_by_id_with_body.json.gz
71
- - spec/fixtures/favorite_questions_by_user_id.json.gz
72
- - spec/fixtures/questions_unanswered.json.gz
73
- - spec/fixtures/question_by_id.json.gz
74
- - spec/fixtures/revisions_by_id.json
75
- - spec/fixtures/all_tags.json.gz
76
- - spec/fixtures/questions_tagged_ruby.json
77
- - spec/fixtures/comments_by_user_to_mentioned_user_id.json.gz
78
- - spec/fixtures/answer_comments.json
83
+ - spec/fixtures/questions.json.gz
79
84
  - spec/fixtures/questions.json
85
+ - spec/fixtures/questions.part
86
+ - spec/fixtures/answer_comments.json
87
+ - spec/fixtures/question_by_user_id.json.gz
80
88
  - spec/fixtures/comments_by_question_id.json.gz
81
- - spec/fixtures/comments_by_user_to_mentioned_user.json.gz
82
- - spec/fixtures/answers_by_id.json
83
- - spec/fixtures/users_by_id.json.gz
84
- - spec/fixtures/stats.json.gz
85
- - spec/fixtures/users.json
86
- - spec/fixtures/comments_by_mentioned_user_id.json.gz
87
89
  - spec/fixtures/comments_by_user_id.json.gz
88
- - spec/fixtures/questions_tagged_gwt_and_googleappengine.json
89
90
  - spec/fixtures/users_answers.json
91
+ - spec/fixtures/badges_tag_based.json
92
+ - spec/fixtures/stats.json
93
+ - spec/fixtures/badges_tag_based.json.gz
94
+ - spec/fixtures/all_tags.json
95
+ - spec/fixtures/comments_by_mentioned_user_id.json.gz
96
+ - spec/fixtures/answer_with_comments.json.gz
97
+ - spec/fixtures/question_by_id.json.gz
98
+ - spec/fixtures/questions_by_user_id.json
99
+ - spec/fixtures/questions_unanswered.json.gz
100
+ - spec/fixtures/comments.json
101
+ - spec/fixtures/stats.json.gz
90
102
  - spec/fixtures/questions_by_user_id.json.gz
91
- - spec/fixtures/users_answers.json.gz
92
- - spec/fixtures/badges_by_id.json
93
- - spec/fixtures/comments_by_question_id.json
94
- - spec/fixtures/badges_by_id.json.gz
103
+ - spec/fixtures/badges_by_id_page2.json.gz
104
+ - spec/fixtures/questions_tagged_ruby.json
105
+ - spec/fixtures/questions_unanswered.json
95
106
  - spec/fixtures/favorite_questions_by_user_id.json
96
- - spec/fixtures/badges_tag_based.json.gz
97
- - spec/fixtures/tags_by_user_id.json
107
+ - spec/fixtures/users_by_id.json.gz
108
+ - spec/fixtures/question_by_id_with_body.json.gz
109
+ - spec/fixtures/badges_by_id.json.gz
110
+ - spec/fixtures/question_by_id.json
111
+ - spec/fixtures/answer_with_comments.json
112
+ - spec/fixtures/users_answers.json.gz
98
113
  - spec/fixtures/comments_by_user_id.json
99
- - spec/fixtures/questions_tagged_gwt_and_googleappengine.json.gz
100
- - spec/fixtures/questions.json.gz
101
- - spec/fixtures/questions_by_user_id.json
102
- - spec/fixtures/question_by_id_with_body.json
103
- - spec/fixtures/answers_by_question_id.json
104
- - spec/fixtures/post_comments.json
105
- - spec/fixtures/all_tags.json
106
- - spec/fixtures/questions.part
114
+ - spec/fixtures/comments_by_user_to_mentioned_user.json.gz
115
+ - spec/fixtures/comments_by_user_to_mentioned_user.json
107
116
  - spec/fixtures/comments_by_mentioned_user_id.json
108
- - spec/fixtures/badges_by_id_page2.json.gz
109
- - spec/fixtures/badges_name.json.gz
117
+ - spec/fixtures/badges.json
110
118
  - spec/fixtures/badges_by_id_page2.json
119
+ - spec/fixtures/comments_by_question_id.json
120
+ - spec/fixtures/users.json
121
+ - spec/fixtures/question_by_id_with_body.json
122
+ - spec/spec_helper.rb
111
123
  has_rdoc: true
112
124
  homepage: http://github.com/dlt/pilha
113
- licenses: []
114
-
125
+ licenses:
126
+ - MIT
115
127
  post_install_message:
116
128
  rdoc_options: []
117
129
 
118
130
  require_paths:
119
131
  - lib
120
132
  required_ruby_version: !ruby/object:Gem::Requirement
133
+ none: false
121
134
  requirements:
122
135
  - - ">="
123
136
  - !ruby/object:Gem::Version
137
+ hash: 3
124
138
  segments:
125
139
  - 0
126
140
  version: "0"
127
141
  required_rubygems_version: !ruby/object:Gem::Requirement
142
+ none: false
128
143
  requirements:
129
144
  - - ">="
130
145
  - !ruby/object:Gem::Version
146
+ hash: 3
131
147
  segments:
132
148
  - 0
133
149
  version: "0"
134
150
  requirements: []
135
151
 
136
152
  rubyforge_project:
137
- rubygems_version: 1.3.6
153
+ rubygems_version: 1.3.7
138
154
  signing_key:
139
155
  specification_version: 3
140
156
  summary: A ruby wrapper to the Stack Exchange (Stack Overflow and friends) API.
141
- test_files: []
142
-
157
+ test_files:
158
+ - spec/pilha/stack_overflow/statistics_spec.rb
159
+ - spec/pilha/stack_overflow/comment_spec.rb
160
+ - spec/pilha/stack_overflow/tag_spec.rb
161
+ - spec/pilha/stack_overflow/question_spec.rb
162
+ - spec/pilha/stack_overflow/stack_overflow_spec.rb
163
+ - spec/pilha/stack_overflow/badge_spec.rb
164
+ - spec/pilha/stack_overflow/answer_spec.rb
165
+ - spec/pilha/stack_overflow/user_spec.rb
166
+ - spec/spec.opts
167
+ - spec/fixtures/tags_by_user_id.json
168
+ - spec/fixtures/questions_tagged_gwt_and_googleappengine.json
169
+ - spec/fixtures/user_tags.json
170
+ - spec/fixtures/answers_by_question_id.json.gz
171
+ - spec/fixtures/badges_name.json
172
+ - spec/fixtures/comments.json.gz
173
+ - spec/fixtures/answers_by_id.json.gz
174
+ - spec/fixtures/comments_by_user_id_to_mentioned_user_id.json.gz
175
+ - spec/fixtures/comments_by_user_to_mentioned_user_id.json.gz
176
+ - spec/fixtures/badges.json.gz
177
+ - spec/fixtures/all_tags.json.gz
178
+ - spec/fixtures/questions_tagged_gwt_and_googleappengine.json.gz
179
+ - spec/fixtures/answers_by_question_id.json
180
+ - spec/fixtures/favorite_questions_by_user_id.json.gz
181
+ - spec/fixtures/answers_by_id.json
182
+ - spec/fixtures/users_by_id.json
183
+ - spec/fixtures/questions_tagged_ruby.json.gz
184
+ - spec/fixtures/badges_by_id.json
185
+ - spec/fixtures/badges_name.json.gz
186
+ - spec/fixtures/tags_by_user_id.json.gz
187
+ - spec/fixtures/questions.json.gz
188
+ - spec/fixtures/questions.json
189
+ - spec/fixtures/questions.part
190
+ - spec/fixtures/answer_comments.json
191
+ - spec/fixtures/question_by_user_id.json.gz
192
+ - spec/fixtures/comments_by_question_id.json.gz
193
+ - spec/fixtures/comments_by_user_id.json.gz
194
+ - spec/fixtures/users_answers.json
195
+ - spec/fixtures/badges_tag_based.json
196
+ - spec/fixtures/stats.json
197
+ - spec/fixtures/badges_tag_based.json.gz
198
+ - spec/fixtures/all_tags.json
199
+ - spec/fixtures/comments_by_mentioned_user_id.json.gz
200
+ - spec/fixtures/answer_with_comments.json.gz
201
+ - spec/fixtures/question_by_id.json.gz
202
+ - spec/fixtures/questions_by_user_id.json
203
+ - spec/fixtures/questions_unanswered.json.gz
204
+ - spec/fixtures/comments.json
205
+ - spec/fixtures/stats.json.gz
206
+ - spec/fixtures/questions_by_user_id.json.gz
207
+ - spec/fixtures/badges_by_id_page2.json.gz
208
+ - spec/fixtures/questions_tagged_ruby.json
209
+ - spec/fixtures/questions_unanswered.json
210
+ - spec/fixtures/favorite_questions_by_user_id.json
211
+ - spec/fixtures/users_by_id.json.gz
212
+ - spec/fixtures/question_by_id_with_body.json.gz
213
+ - spec/fixtures/badges_by_id.json.gz
214
+ - spec/fixtures/question_by_id.json
215
+ - spec/fixtures/answer_with_comments.json
216
+ - spec/fixtures/users_answers.json.gz
217
+ - spec/fixtures/comments_by_user_id.json
218
+ - spec/fixtures/comments_by_user_to_mentioned_user.json.gz
219
+ - spec/fixtures/comments_by_user_to_mentioned_user.json
220
+ - spec/fixtures/comments_by_mentioned_user_id.json
221
+ - spec/fixtures/badges.json
222
+ - spec/fixtures/badges_by_id_page2.json
223
+ - spec/fixtures/comments_by_question_id.json
224
+ - spec/fixtures/users.json
225
+ - spec/fixtures/question_by_id_with_body.json
226
+ - spec/spec_helper.rb
@@ -1,30 +0,0 @@
1
- Gem::Specification.new do |gem|
2
- gem.name = "pilha"
3
- gem.version = "0.1.7"
4
- gem.authors = ["Dalto Curvelano Junior"]
5
- gem.description = "A ruby wrapper to the Stack Exchange (Stack Overflow and friends) API."
6
- gem.summary = "A ruby wrapper to the Stack Exchange (Stack Overflow and friends) API."
7
- fixture_files = Dir["spec/fixtures/*"]
8
- gem.files = [
9
- "pilha.gemspec",
10
- "lib/pilha.rb",
11
- "lib/pilha/stack_overflow/badge.rb",
12
- "lib/pilha/stack_overflow/statistics.rb",
13
- "lib/pilha/stack_overflow/user.rb",
14
- "lib/pilha/stack_overflow/comment.rb",
15
- "lib/pilha/stack_overflow/answer.rb",
16
- "lib/pilha/stack_overflow/question.rb",
17
- "lib/pilha/stack_overflow/base.rb",
18
- "spec/pilha/stack_overflow/badge_spec.rb",
19
- "spec/pilha/stack_overflow/stack_overflow_spec.rb",
20
- "spec/pilha/stack_overflow/statistics_spec.rb",
21
- "spec/pilha/stack_overflow/user_spec.rb",
22
- "spec/pilha/stack_overflow/comment_spec.rb",
23
- "spec/pilha/stack_overflow/answer_spec.rb",
24
- "spec/pilha/stack_overflow/question_spec.rb",
25
- "spec/spec.opts",
26
- "spec/spec_helper.rb",
27
- *fixture_files
28
- ]
29
- gem.homepage = "http://github.com/dlt/pilha"
30
- end
@@ -1,6 +0,0 @@
1
- {
2
- "total": 0,
3
- "page": 1,
4
- "pagesize": 30,
5
- "comments": []
6
- }
@@ -1,25 +0,0 @@
1
- {
2
- "revisions": [
3
- {
4
- "body": "<p>Thanks a lot, great advice. The QTextDocument comparison is quite apt in my case as I'm using Qt.</p>\n",
5
- "comment": "",
6
- "creation_date": 1217646463,
7
- "is_question": false,
8
- "is_rollback": false,
9
- "last_tags": [],
10
- "revision_guid": "647c13ce-e53f-4ead-bbc8-f31f808a9253",
11
- "revision_number": 1,
12
- "tags": [],
13
- "revision_type": "single_user",
14
- "set_community_wiki": false,
15
- "user": {
16
- "user_id": 63,
17
- "user_type": "registered",
18
- "display_name": "JimDaniel",
19
- "reputation": 2023,
20
- "email_hash": "762d02eb9b882755f20e6696ed4e534e"
21
- },
22
- "post_id": 333
23
- }
24
- ]
25
- }