githu3 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.
Files changed (63) hide show
  1. data/.autotest +3 -0
  2. data/.document +5 -0
  3. data/.gitignore +22 -0
  4. data/.rspec +4 -0
  5. data/.travis.yml +8 -0
  6. data/Gemfile +11 -0
  7. data/LICENSE.txt +20 -0
  8. data/README.rdoc +20 -0
  9. data/Rakefile +16 -0
  10. data/githu3.gemspec +34 -0
  11. data/lib/githu3/branch.rb +4 -0
  12. data/lib/githu3/client.rb +68 -0
  13. data/lib/githu3/comment.rb +5 -0
  14. data/lib/githu3/event.rb +5 -0
  15. data/lib/githu3/issue.rb +9 -0
  16. data/lib/githu3/key.rb +4 -0
  17. data/lib/githu3/label.rb +5 -0
  18. data/lib/githu3/milestone.rb +5 -0
  19. data/lib/githu3/org.rb +20 -0
  20. data/lib/githu3/repo.rb +16 -0
  21. data/lib/githu3/resource.rb +64 -0
  22. data/lib/githu3/tag.rb +4 -0
  23. data/lib/githu3/team.rb +14 -0
  24. data/lib/githu3/user.rb +13 -0
  25. data/lib/githu3/version.rb +3 -0
  26. data/lib/githu3.rb +30 -0
  27. data/spec/fixtures/all_repos.json +54 -0
  28. data/spec/fixtures/issues/comments.json +41 -0
  29. data/spec/fixtures/issues/event.json +12 -0
  30. data/spec/fixtures/issues/events.json +14 -0
  31. data/spec/fixtures/me.json +31 -0
  32. data/spec/fixtures/orgs/github.json +18 -0
  33. data/spec/fixtures/orgs/rails.json +18 -0
  34. data/spec/fixtures/orgs.json +14 -0
  35. data/spec/fixtures/public_repos.json +132 -0
  36. data/spec/fixtures/repos/branches.json +23 -0
  37. data/spec/fixtures/repos/contributors.json +58 -0
  38. data/spec/fixtures/repos/faraday.json +31 -0
  39. data/spec/fixtures/repos/issue.json +53 -0
  40. data/spec/fixtures/repos/issues.json +55 -0
  41. data/spec/fixtures/repos/label.json +5 -0
  42. data/spec/fixtures/repos/labels.json +7 -0
  43. data/spec/fixtures/repos/milestone.json +17 -0
  44. data/spec/fixtures/repos/milestones.json +19 -0
  45. data/spec/fixtures/repos/tags.json +164 -0
  46. data/spec/fixtures/repos/teams.json +17 -0
  47. data/spec/fixtures/teams/1.json +8 -0
  48. data/spec/fixtures/teams/members.json +8 -0
  49. data/spec/fixtures/teams/repos.json +28 -0
  50. data/spec/fixtures/users/followers.json +80 -0
  51. data/spec/fixtures/users/following.json +182 -0
  52. data/spec/fixtures/users/orgs.json +8 -0
  53. data/spec/fixtures/users/repos.json +132 -0
  54. data/spec/fixtures/users/sbellity.json +20 -0
  55. data/spec/githu3/client_spec.rb +66 -0
  56. data/spec/githu3/issue_spec.rb +54 -0
  57. data/spec/githu3/org_spec.rb +79 -0
  58. data/spec/githu3/repo_spec.rb +100 -0
  59. data/spec/githu3/team_spec.rb +47 -0
  60. data/spec/githu3/user_spec.rb +47 -0
  61. data/spec/githu3_spec.rb +7 -0
  62. data/spec/helper.rb +21 -0
  63. metadata +334 -0
@@ -0,0 +1,100 @@
1
+ require 'helper'
2
+
3
+ describe Githu3::Repo do
4
+
5
+ def faraday
6
+ stub_get "/repos/technoweenie/faraday", "repos/faraday"
7
+ @client.repo("technoweenie/faraday")
8
+ end
9
+
10
+ before do
11
+ @client = Githu3::Client.new("myvalidtoken")
12
+ end
13
+
14
+ describe "Getting a repo's stuff..." do
15
+
16
+ it "should get the repo infos" do
17
+ faraday.name.should == "faraday"
18
+ faraday.owner['login'].should == "technoweenie"
19
+ end
20
+
21
+ it "should fetch its contributors" do
22
+ stub_get "/repos/technoweenie/faraday/contributors", "repos/contributors"
23
+ faraday.contributors.length.should == 8
24
+ faraday.contributors.first.login.should == "technoweenie"
25
+ end
26
+
27
+ it "should fetch its teams" do
28
+ stub_get "/repos/technoweenie/faraday/teams", "repos/teams"
29
+ teams = faraday.teams
30
+ teams.length.should == 3
31
+ teams.first.name.should == "Developers"
32
+ end
33
+
34
+ end
35
+
36
+ describe "Getting a repo's refs" do
37
+
38
+ it "should fetch its tags" do
39
+ stub_get "/repos/technoweenie/faraday/tags", "repos/tags"
40
+ tags = faraday.tags
41
+ tags.length.should == 18
42
+ tags.first.name.should == "v0.5.6"
43
+ end
44
+
45
+ it "should fetch its branches" do
46
+ stub_get "/repos/technoweenie/faraday/branches", "repos/branches"
47
+ branches = faraday.branches
48
+ branches.length.should == 3
49
+ branches.first.name.should == "master"
50
+ end
51
+
52
+ end
53
+
54
+ describe "Wokring with its issues..." do
55
+
56
+ it "should list its issues" do
57
+ stub_get "/repos/technoweenie/faraday/issues", "repos/issues"
58
+ faraday.issues.length.should == 1
59
+ end
60
+
61
+ it "should filter its issues" do
62
+ stub_get "/repos/technoweenie/faraday/issues?state=open&labels=bug,feature", "repos/issues"
63
+ faraday.issues(:state => "open", :labels => "bug,feature").length.should == 1
64
+ end
65
+
66
+ it "should fetch a single issue" do
67
+ stub_get "/repos/technoweenie/faraday/issues/1", "repos/issue"
68
+ faraday.issues("1").state.should == "open"
69
+ end
70
+
71
+ it "should list its issues" do
72
+ stub_get "/repos/technoweenie/faraday/issues/events", "issues/events"
73
+ faraday.events.length.should == 1
74
+ end
75
+
76
+ it "should list its labels" do
77
+ stub_get "/repos/technoweenie/faraday/labels", "repos/labels"
78
+ faraday.labels.length.should == 1
79
+ faraday.labels.first.name.should == "bug"
80
+ end
81
+
82
+ it "should get a single labels" do
83
+ stub_get "/repos/technoweenie/faraday/labels/bug", "repos/label"
84
+ faraday.labels("bug").name.should == "bug"
85
+ end
86
+
87
+ it "should list its milestones" do
88
+ stub_get "/repos/technoweenie/faraday/milestones", "repos/milestones"
89
+ faraday.milestones.length.should == 1
90
+ faraday.milestones.first.title.should == "v1.0"
91
+ end
92
+
93
+ it "should get a single milestone" do
94
+ stub_get "/repos/technoweenie/faraday/milestones/1", "repos/milestone"
95
+ faraday.milestones("1").title.should == "v1.0"
96
+ end
97
+
98
+ end
99
+
100
+ end
@@ -0,0 +1,47 @@
1
+ require 'helper'
2
+
3
+ describe Githu3::Team do
4
+
5
+ def team
6
+ stub_get "/teams/1", "teams/1"
7
+ @client.team "1"
8
+ end
9
+
10
+
11
+ before do
12
+ @client = Githu3::Client.new("myvalidtoken")
13
+ end
14
+
15
+ it "should get its name right" do
16
+ team.name.should == "Owners"
17
+ end
18
+
19
+ describe "Getting the team's members..." do
20
+
21
+ it "should get its members" do
22
+ stub_get "/teams/1/members", "teams/members"
23
+ team.members.length.should == 1
24
+ team.members.first.login.should == "octocat"
25
+ end
26
+
27
+ it 'should tell me if a user IS a member of the team' do
28
+ stub_request(:get, "https://api.github.com/teams/1/members/octocat").to_return(:status => 204)
29
+ team.member?('octocat').should be_true
30
+ end
31
+
32
+ it 'should tell me if a user IS NOT a member of the team' do
33
+ stub_request(:get, "https://api.github.com/teams/1/members/billevans").to_return(:status => 404)
34
+ team.member?('billevans').should be_false
35
+ end
36
+ end
37
+
38
+ describe "Getting the team's repos..." do
39
+
40
+ it "should list the team's repos" do
41
+ stub_get "/teams/1/repos", "teams/repos"
42
+ team.repos.length.should == 1
43
+ end
44
+
45
+ end
46
+
47
+ end
@@ -0,0 +1,47 @@
1
+ require 'helper'
2
+
3
+ describe Githu3::User do
4
+
5
+ def sbellity
6
+ stub_get "/users/sbellity", "users/sbellity"
7
+ @client.user("sbellity")
8
+ end
9
+
10
+ before do
11
+ @client = Githu3::Client.new("myvalidtoken")
12
+ end
13
+
14
+ describe "Getting a users's stuff..." do
15
+
16
+ it "should get a user's infos" do
17
+ sbellity.login.should == "sbellity"
18
+ end
19
+
20
+ it "should get the user's public repos" do
21
+ stub_get "/users/sbellity/repos", "users/repos"
22
+ sbellity.repos.length.should == 5
23
+ end
24
+
25
+ it "should get the user's member repos" do
26
+ stub_get "/users/sbellity/repos?type=member", "users/repos"
27
+ sbellity.repos(:type => 'member').length.should == 5
28
+ end
29
+
30
+ it "should get the user's public orgs" do
31
+ stub_get "/users/sbellity/orgs", "users/orgs"
32
+ sbellity.orgs.length.should == 1
33
+ sbellity.orgs.first.login.should == "sixdegrees"
34
+ end
35
+
36
+ it "should get the user's followers" do
37
+ stub_get "/users/sbellity/followers", "users/followers"
38
+ sbellity.followers.length.should == 13
39
+ end
40
+
41
+ it "should get the user's following" do
42
+ stub_get "/users/sbellity/following", "users/following"
43
+ sbellity.following.length.should == 30
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,7 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ describe Githu3 do
5
+
6
+
7
+ end
data/spec/helper.rb ADDED
@@ -0,0 +1,21 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+ require 'githu3'
6
+ require 'rspec'
7
+ require 'webmock/rspec'
8
+
9
+ def fixture_path
10
+ File.expand_path("../fixtures", __FILE__)
11
+ end
12
+
13
+ def fixture(file)
14
+ File.new(fixture_path + '/' + file)
15
+ end
16
+
17
+ def stub_get url, fixture_name, headers={ 'Authorization'=>'token myvalidtoken' }
18
+ stub_request(:get, "https://api.github.com#{url}").
19
+ with(:headers => headers).
20
+ to_return(:status => 200, :body => fixture("#{fixture_name}.json"))
21
+ end
metadata ADDED
@@ -0,0 +1,334 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: githu3
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
11
+ platform: ruby
12
+ authors:
13
+ - Stephane Bellity
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-06-26 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: activesupport
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 7
29
+ segments:
30
+ - 3
31
+ - 0
32
+ - 0
33
+ version: 3.0.0
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: i18n
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 11
45
+ segments:
46
+ - 0
47
+ - 5
48
+ - 0
49
+ version: 0.5.0
50
+ type: :runtime
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: faraday
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ hash: 7
61
+ segments:
62
+ - 0
63
+ - 6
64
+ - 0
65
+ version: 0.6.0
66
+ type: :runtime
67
+ version_requirements: *id003
68
+ - !ruby/object:Gem::Dependency
69
+ name: faraday_middleware
70
+ prerelease: false
71
+ requirement: &id004 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ hash: 7
77
+ segments:
78
+ - 0
79
+ - 6
80
+ - 0
81
+ version: 0.6.0
82
+ type: :runtime
83
+ version_requirements: *id004
84
+ - !ruby/object:Gem::Dependency
85
+ name: multi_json
86
+ prerelease: false
87
+ requirement: &id005 !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ~>
91
+ - !ruby/object:Gem::Version
92
+ hash: 19
93
+ segments:
94
+ - 1
95
+ - 0
96
+ - 2
97
+ version: 1.0.2
98
+ type: :runtime
99
+ version_requirements: *id005
100
+ - !ruby/object:Gem::Dependency
101
+ name: ZenTest
102
+ prerelease: false
103
+ requirement: &id006 !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ~>
107
+ - !ruby/object:Gem::Version
108
+ hash: 17
109
+ segments:
110
+ - 4
111
+ - 5
112
+ version: "4.5"
113
+ type: :development
114
+ version_requirements: *id006
115
+ - !ruby/object:Gem::Dependency
116
+ name: rake
117
+ prerelease: false
118
+ requirement: &id007 !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ~>
122
+ - !ruby/object:Gem::Version
123
+ hash: 25
124
+ segments:
125
+ - 0
126
+ - 9
127
+ version: "0.9"
128
+ type: :development
129
+ version_requirements: *id007
130
+ - !ruby/object:Gem::Dependency
131
+ name: rspec
132
+ prerelease: false
133
+ requirement: &id008 !ruby/object:Gem::Requirement
134
+ none: false
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ hash: 15
139
+ segments:
140
+ - 2
141
+ - 6
142
+ version: "2.6"
143
+ type: :development
144
+ version_requirements: *id008
145
+ - !ruby/object:Gem::Dependency
146
+ name: simplecov
147
+ prerelease: false
148
+ requirement: &id009 !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ~>
152
+ - !ruby/object:Gem::Version
153
+ hash: 3
154
+ segments:
155
+ - 0
156
+ - 4
157
+ version: "0.4"
158
+ type: :development
159
+ version_requirements: *id009
160
+ - !ruby/object:Gem::Dependency
161
+ name: webmock
162
+ prerelease: false
163
+ requirement: &id010 !ruby/object:Gem::Requirement
164
+ none: false
165
+ requirements:
166
+ - - ~>
167
+ - !ruby/object:Gem::Version
168
+ hash: 3
169
+ segments:
170
+ - 1
171
+ - 6
172
+ version: "1.6"
173
+ type: :development
174
+ version_requirements: *id010
175
+ - !ruby/object:Gem::Dependency
176
+ name: yajl-ruby
177
+ prerelease: false
178
+ requirement: &id011 !ruby/object:Gem::Requirement
179
+ none: false
180
+ requirements:
181
+ - - ~>
182
+ - !ruby/object:Gem::Version
183
+ hash: 27
184
+ segments:
185
+ - 0
186
+ - 8
187
+ version: "0.8"
188
+ type: :development
189
+ version_requirements: *id011
190
+ description: Ruby wrapper for the GitHub's v3' API
191
+ email:
192
+ - sbellity@gmail.com
193
+ executables: []
194
+
195
+ extensions: []
196
+
197
+ extra_rdoc_files: []
198
+
199
+ files:
200
+ - .autotest
201
+ - .document
202
+ - .gitignore
203
+ - .rspec
204
+ - .travis.yml
205
+ - Gemfile
206
+ - LICENSE.txt
207
+ - README.rdoc
208
+ - Rakefile
209
+ - githu3.gemspec
210
+ - lib/githu3.rb
211
+ - lib/githu3/branch.rb
212
+ - lib/githu3/client.rb
213
+ - lib/githu3/comment.rb
214
+ - lib/githu3/event.rb
215
+ - lib/githu3/issue.rb
216
+ - lib/githu3/key.rb
217
+ - lib/githu3/label.rb
218
+ - lib/githu3/milestone.rb
219
+ - lib/githu3/org.rb
220
+ - lib/githu3/repo.rb
221
+ - lib/githu3/resource.rb
222
+ - lib/githu3/tag.rb
223
+ - lib/githu3/team.rb
224
+ - lib/githu3/user.rb
225
+ - lib/githu3/version.rb
226
+ - spec/fixtures/all_repos.json
227
+ - spec/fixtures/issues/comments.json
228
+ - spec/fixtures/issues/event.json
229
+ - spec/fixtures/issues/events.json
230
+ - spec/fixtures/me.json
231
+ - spec/fixtures/orgs.json
232
+ - spec/fixtures/orgs/github.json
233
+ - spec/fixtures/orgs/rails.json
234
+ - spec/fixtures/public_repos.json
235
+ - spec/fixtures/repos/branches.json
236
+ - spec/fixtures/repos/contributors.json
237
+ - spec/fixtures/repos/faraday.json
238
+ - spec/fixtures/repos/issue.json
239
+ - spec/fixtures/repos/issues.json
240
+ - spec/fixtures/repos/label.json
241
+ - spec/fixtures/repos/labels.json
242
+ - spec/fixtures/repos/milestone.json
243
+ - spec/fixtures/repos/milestones.json
244
+ - spec/fixtures/repos/tags.json
245
+ - spec/fixtures/repos/teams.json
246
+ - spec/fixtures/teams/1.json
247
+ - spec/fixtures/teams/members.json
248
+ - spec/fixtures/teams/repos.json
249
+ - spec/fixtures/users/followers.json
250
+ - spec/fixtures/users/following.json
251
+ - spec/fixtures/users/orgs.json
252
+ - spec/fixtures/users/repos.json
253
+ - spec/fixtures/users/sbellity.json
254
+ - spec/githu3/client_spec.rb
255
+ - spec/githu3/issue_spec.rb
256
+ - spec/githu3/org_spec.rb
257
+ - spec/githu3/repo_spec.rb
258
+ - spec/githu3/team_spec.rb
259
+ - spec/githu3/user_spec.rb
260
+ - spec/githu3_spec.rb
261
+ - spec/helper.rb
262
+ homepage: https://github.com/sbellity/githu3
263
+ licenses: []
264
+
265
+ post_install_message:
266
+ rdoc_options: []
267
+
268
+ require_paths:
269
+ - lib
270
+ required_ruby_version: !ruby/object:Gem::Requirement
271
+ none: false
272
+ requirements:
273
+ - - ">="
274
+ - !ruby/object:Gem::Version
275
+ hash: 3
276
+ segments:
277
+ - 0
278
+ version: "0"
279
+ required_rubygems_version: !ruby/object:Gem::Requirement
280
+ none: false
281
+ requirements:
282
+ - - ">="
283
+ - !ruby/object:Gem::Version
284
+ hash: 23
285
+ segments:
286
+ - 1
287
+ - 3
288
+ - 6
289
+ version: 1.3.6
290
+ requirements: []
291
+
292
+ rubyforge_project:
293
+ rubygems_version: 1.7.2
294
+ signing_key:
295
+ specification_version: 3
296
+ summary: Ruby wrapper for the GitHub's v3' API
297
+ test_files:
298
+ - spec/fixtures/all_repos.json
299
+ - spec/fixtures/issues/comments.json
300
+ - spec/fixtures/issues/event.json
301
+ - spec/fixtures/issues/events.json
302
+ - spec/fixtures/me.json
303
+ - spec/fixtures/orgs.json
304
+ - spec/fixtures/orgs/github.json
305
+ - spec/fixtures/orgs/rails.json
306
+ - spec/fixtures/public_repos.json
307
+ - spec/fixtures/repos/branches.json
308
+ - spec/fixtures/repos/contributors.json
309
+ - spec/fixtures/repos/faraday.json
310
+ - spec/fixtures/repos/issue.json
311
+ - spec/fixtures/repos/issues.json
312
+ - spec/fixtures/repos/label.json
313
+ - spec/fixtures/repos/labels.json
314
+ - spec/fixtures/repos/milestone.json
315
+ - spec/fixtures/repos/milestones.json
316
+ - spec/fixtures/repos/tags.json
317
+ - spec/fixtures/repos/teams.json
318
+ - spec/fixtures/teams/1.json
319
+ - spec/fixtures/teams/members.json
320
+ - spec/fixtures/teams/repos.json
321
+ - spec/fixtures/users/followers.json
322
+ - spec/fixtures/users/following.json
323
+ - spec/fixtures/users/orgs.json
324
+ - spec/fixtures/users/repos.json
325
+ - spec/fixtures/users/sbellity.json
326
+ - spec/githu3/client_spec.rb
327
+ - spec/githu3/issue_spec.rb
328
+ - spec/githu3/org_spec.rb
329
+ - spec/githu3/repo_spec.rb
330
+ - spec/githu3/team_spec.rb
331
+ - spec/githu3/user_spec.rb
332
+ - spec/githu3_spec.rb
333
+ - spec/helper.rb
334
+ has_rdoc: