octokit 1.24.0 → 1.25.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,44 @@
1
+ {
2
+ "content": {
3
+ "name": "foo/bar/baz.txt",
4
+ "path": "foo/bar/baz.txt",
5
+ "sha": "46e50d3f73c39aeb86295d85e38b0364a0f0a1b6",
6
+ "size": 21,
7
+ "url": "https://api.github.com/repos/pengwynn/api-sandbox/contents/foo/bar/baz.txt?ref=some-fourth-branch",
8
+ "html_url": "https://github.com/pengwynn/api-sandbox/blob/some-fourth-branch/foo/bar/baz.txt",
9
+ "git_url": "https://api.github.com/repos/pengwynn/api-sandbox/git/blobs/46e50d3f73c39aeb86295d85e38b0364a0f0a1b6",
10
+ "type": "file",
11
+ "_links": {
12
+ "self": "https://api.github.com/repos/pengwynn/api-sandbox/contents/foo/bar/baz.txt?ref=some-fourth-branch",
13
+ "git": "https://api.github.com/repos/pengwynn/api-sandbox/git/blobs/46e50d3f73c39aeb86295d85e38b0364a0f0a1b6",
14
+ "html": "https://github.com/pengwynn/api-sandbox/blob/some-fourth-branch/foo/bar/baz.txt"
15
+ }
16
+ },
17
+ "commit": {
18
+ "sha": "15ab9bfe8985e69d64e3d06b2eaf252cfbf43a6e",
19
+ "url": "https://api.github.com/repos/pengwynn/api-sandbox/git/commits/15ab9bfe8985e69d64e3d06b2eaf252cfbf43a6e",
20
+ "html_url": "https://github.com/pengwynn/api-sandbox/commits/15ab9bfe8985e69d64e3d06b2eaf252cfbf43a6e",
21
+ "author": {
22
+ "name": "Wynn Netherland",
23
+ "email": "wynn.netherland@gmail.com",
24
+ "date": "2013-05-06T14:03:22Z"
25
+ },
26
+ "committer": {
27
+ "name": "Wynn Netherland",
28
+ "email": "wynn.netherland@gmail.com",
29
+ "date": "2013-05-06T14:03:22Z"
30
+ },
31
+ "tree": {
32
+ "sha": "4f7651e2a3cfc5fb7abfb8a38201d7c4a439d276",
33
+ "url": "https://api.github.com/repos/pengwynn/api-sandbox/git/trees/4f7651e2a3cfc5fb7abfb8a38201d7c4a439d276"
34
+ },
35
+ "message": "I am commit-ing",
36
+ "parents": [
37
+ {
38
+ "sha": "4810b8a0d076f20169bd2acca6501112f4d93e7d",
39
+ "url": "https://api.github.com/repos/pengwynn/api-sandbox/git/commits/4810b8a0d076f20169bd2acca6501112f4d93e7d",
40
+ "html_url": "https://github.com/pengwynn/api-sandbox/commits/4810b8a0d076f20169bd2acca6501112f4d93e7d"
41
+ }
42
+ ]
43
+ }
44
+ }
@@ -0,0 +1 @@
1
+ Here be moar content
@@ -48,4 +48,109 @@ describe Octokit::Client::Contents do
48
48
 
49
49
  end
50
50
 
51
+ describe ".create_contents" do
52
+ it "creates repository contents at a path" do
53
+ stub_put("/repos/pengwynn/api-sandbox/contents/foo/bar/baz.txt").
54
+ with({:body => {:message => "I am commit-ing", :content => "SGVyZSBiZSB0aGUgY29udGVudA=="}}).
55
+ to_return(json_response("create_content.json"))
56
+
57
+ response = @client.create_contents("pengwynn/api-sandbox",
58
+ "foo/bar/baz.txt",
59
+ "I am commit-ing",
60
+ "Here be the content")
61
+ expect(response.commit.sha).to eq '4810b8a0d076f20169bd2acca6501112f4d93e7d'
62
+ end
63
+ it "creates contents from file path" do
64
+ stub_put("/repos/pengwynn/api-sandbox/contents/foo/bar/baz.txt").
65
+ with({:body => {:message => "I am commit-ing", :content => "SGVyZSBiZSB0aGUgY29udGVudAo="}}).
66
+ to_return(json_response("create_content.json"))
67
+
68
+ response = @client.create_contents("pengwynn/api-sandbox",
69
+ "foo/bar/baz.txt",
70
+ "I am commit-ing",
71
+ :file => "spec/fixtures/new_file.txt")
72
+ expect(response.commit.sha).to eq '4810b8a0d076f20169bd2acca6501112f4d93e7d'
73
+ end
74
+ it "creates contents from File object" do
75
+ stub_put("/repos/pengwynn/api-sandbox/contents/foo/bar/baz.txt").
76
+ with({:body => {:message => "I am commit-ing", :content => "SGVyZSBiZSB0aGUgY29udGVudAo="}}).
77
+ to_return(json_response("create_content.json"))
78
+
79
+ file = File.new "spec/fixtures/new_file.txt", "r"
80
+ response = @client.create_contents("pengwynn/api-sandbox",
81
+ "foo/bar/baz.txt",
82
+ "I am commit-ing",
83
+ :file => file)
84
+ expect(response.commit.sha).to eq '4810b8a0d076f20169bd2acca6501112f4d93e7d'
85
+ end
86
+ end
87
+
88
+ describe ".update_contents" do
89
+ it "updates repository contents at a path" do
90
+ stub_put("/repos/pengwynn/api-sandbox/contents/foo/bar/baz.txt").
91
+ with({:body => {
92
+ :sha => "4d149b826e7305659006eb64cfecd3be68d0f2f0",
93
+ :message => "I am commit-ing",
94
+ :content => "SGVyZSBiZSBtb2FyIGNvbnRlbnQ="
95
+ }}).
96
+ to_return(json_response("update_content.json"))
97
+
98
+ response = @client.update_contents("pengwynn/api-sandbox",
99
+ "foo/bar/baz.txt",
100
+ "I am commit-ing",
101
+ "4d149b826e7305659006eb64cfecd3be68d0f2f0",
102
+ "Here be moar content")
103
+ expect(response.commit.sha).to eq '15ab9bfe8985e69d64e3d06b2eaf252cfbf43a6e'
104
+ end
105
+ it "updates repository contents with a file path" do
106
+ stub_put("/repos/pengwynn/api-sandbox/contents/foo/bar/baz.txt").
107
+ with({:body => {
108
+ :sha => "4d149b826e7305659006eb64cfecd3be68d0f2f0",
109
+ :message => "I am commit-ing",
110
+ :content => "SGVyZSBiZSBtb2FyIGNvbnRlbnQK"
111
+ }}).
112
+ to_return(json_response("update_content.json"))
113
+
114
+ response = @client.update_contents("pengwynn/api-sandbox",
115
+ "foo/bar/baz.txt",
116
+ "I am commit-ing",
117
+ "4d149b826e7305659006eb64cfecd3be68d0f2f0",
118
+ :file => "spec/fixtures/updated_file.txt")
119
+ expect(response.commit.sha).to eq '15ab9bfe8985e69d64e3d06b2eaf252cfbf43a6e'
120
+ end
121
+ it "updates repository contents with a File object" do
122
+ stub_put("/repos/pengwynn/api-sandbox/contents/foo/bar/baz.txt").
123
+ with({:body => {
124
+ :sha => "4d149b826e7305659006eb64cfecd3be68d0f2f0",
125
+ :message => "I am commit-ing",
126
+ :content => "SGVyZSBiZSBtb2FyIGNvbnRlbnQK"
127
+ }}).
128
+ to_return(json_response("update_content.json"))
129
+
130
+ file = File.new "spec/fixtures/updated_file.txt", "r"
131
+ response = @client.update_contents("pengwynn/api-sandbox",
132
+ "foo/bar/baz.txt",
133
+ "I am commit-ing",
134
+ "4d149b826e7305659006eb64cfecd3be68d0f2f0",
135
+ :file => file)
136
+ expect(response.commit.sha).to eq '15ab9bfe8985e69d64e3d06b2eaf252cfbf43a6e'
137
+ end
138
+ end
139
+
140
+ describe ".delete_contents" do
141
+ it "deletes repository contents at a path" do
142
+ stub_delete("/repos/pengwynn/api-sandbox/contents/foo/bar/baz.txt").
143
+ with({:query => {
144
+ :sha => "4d149b826e7305659006eb64cfecd3be68d0f2f0",
145
+ :message => "I am rm-ing"
146
+ }}).
147
+ to_return(json_response("delete_content.json"))
148
+
149
+ response = @client.delete_contents("pengwynn/api-sandbox",
150
+ "foo/bar/baz.txt",
151
+ "I am rm-ing",
152
+ "4d149b826e7305659006eb64cfecd3be68d0f2f0")
153
+ expect(response.commit.sha).to eq '960a747b2f5c3837184b84e1f8cae7ef1a765e2f'
154
+ end
155
+ end
51
156
  end
@@ -521,4 +521,23 @@ describe Octokit::Client::Repositories do
521
521
 
522
522
  end
523
523
 
524
+ describe ".repository?" do
525
+
526
+ it "returns true if the repository exists" do
527
+ stub_get("/repos/sferik/rails_admin").
528
+ to_return(json_response("repository.json"))
529
+
530
+ result = @client.repository?("sferik/rails_admin")
531
+ expect(result).to be_true
532
+ end
533
+
534
+ it "returns false if the repository doesn't exist" do
535
+ stub_get("/repos/pengwynn/octokit").
536
+ to_return(:status => 404)
537
+
538
+ result = @client.repository?("pengwynn/octokit")
539
+ expect(result).to be_false
540
+ end
541
+
542
+ end
524
543
  end
@@ -0,0 +1,55 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ describe Octokit::Client::Stats do
5
+
6
+ before do
7
+ @client = Octokit::Client.new(:login => 'sferik')
8
+ end
9
+
10
+ describe ".contributor_stats" do
11
+ it "returns contributors and their contribution stats" do
12
+ stub_get("/repos/pengwynn/octokit/stats/contributors").
13
+ to_return(json_response("contributor_stats.json"))
14
+ stats = @client.contributors_stats("pengwynn/octokit")
15
+ expect(stats.first.author.login).to eq("pengwynn")
16
+ end
17
+ end
18
+
19
+ describe ".commit_activity_stats" do
20
+ it "returns the commit activity stats" do
21
+ stub_get("/repos/pengwynn/octokit/stats/commit_activity").
22
+ to_return(json_response("commit_activity_stats.json"))
23
+ stats = @client.commit_activity_stats("pengwynn/octokit")
24
+ expect(stats.first.week).to eq(1336867200)
25
+ end
26
+ end
27
+
28
+ describe ".code_frequency_stats" do
29
+ it "returns the code frequency stats" do
30
+ stub_get("/repos/pengwynn/octokit/stats/code_frequency").
31
+ to_return(json_response('code_frequency_stats.json'))
32
+ stats = @client.code_frequency_stats('pengwynn/octokit')
33
+ expect(stats.first.first).to eq(1260057600)
34
+ end
35
+ end
36
+
37
+ describe ".participation_stats" do
38
+ it "returns the owner and contributor participation stats" do
39
+ stub_get("/repos/pengwynn/octokit/stats/participation").
40
+ to_return(json_response('participation_stats.json'))
41
+ stats = @client.participation_stats('pengwynn/octokit')
42
+ expect(stats.owner.first).to eq(5)
43
+ end
44
+ end
45
+
46
+ describe ".punch_card_stats" do
47
+ it "returns commit count by hour punch card stats" do
48
+ stub_get("/repos/pengwynn/octokit/stats/punch_card").
49
+ to_return(json_response('punch_card_stats.json'))
50
+ stats = @client.punch_card_stats('pengwynn/octokit')
51
+ expect(stats.last.first).to eq(6)
52
+ end
53
+ end
54
+
55
+ end
@@ -20,6 +20,18 @@ describe Octokit::Client::Users do
20
20
 
21
21
  end
22
22
 
23
+ context "with no encode url" do
24
+
25
+ it "should not raise URI::InvalidURIError and returns success" do
26
+ stub_get("https://api.github.com/legacy/user/search/follower:>0").
27
+ to_return(json_response("legacy/users.json"))
28
+ users = @client.search_users("follower:>0")
29
+ expect(users.first.login).to eq("sferik")
30
+ end
31
+
32
+ end
33
+
34
+
23
35
  end
24
36
 
25
37
  describe ".all_users" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octokit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.24.0
4
+ version: 1.25.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-03-24 00:00:00.000000000 Z
14
+ date: 2013-07-03 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -166,6 +166,7 @@ files:
166
166
  - lib/octokit/client/refs.rb
167
167
  - lib/octokit/client/repositories.rb
168
168
  - lib/octokit/client/say.rb
169
+ - lib/octokit/client/stats.rb
169
170
  - lib/octokit/client/statuses.rb
170
171
  - lib/octokit/client/users.rb
171
172
  - lib/octokit/client.rb
@@ -185,10 +186,12 @@ files:
185
186
  - spec/fixtures/blob.json
186
187
  - spec/fixtures/blob_create.json
187
188
  - spec/fixtures/branches.json
189
+ - spec/fixtures/code_frequency_stats.json
188
190
  - spec/fixtures/collaborators.json
189
191
  - spec/fixtures/comment.json
190
192
  - spec/fixtures/comments.json
191
193
  - spec/fixtures/commit.json
194
+ - spec/fixtures/commit_activity_stats.json
192
195
  - spec/fixtures/commit_comment.json
193
196
  - spec/fixtures/commit_comment_create.json
194
197
  - spec/fixtures/commit_comment_update.json
@@ -197,7 +200,10 @@ files:
197
200
  - spec/fixtures/commits.json
198
201
  - spec/fixtures/compare.json
199
202
  - spec/fixtures/contents.json
203
+ - spec/fixtures/contributor_stats.json
200
204
  - spec/fixtures/contributors.json
205
+ - spec/fixtures/create_content.json
206
+ - spec/fixtures/delete_content.json
201
207
  - spec/fixtures/download.json
202
208
  - spec/fixtures/download_create.json
203
209
  - spec/fixtures/downloads.json
@@ -237,6 +243,7 @@ files:
237
243
  - spec/fixtures/merge.json
238
244
  - spec/fixtures/milestone.json
239
245
  - spec/fixtures/milestones.json
246
+ - spec/fixtures/new_file.txt
240
247
  - spec/fixtures/not_found.json
241
248
  - spec/fixtures/notification_thread.json
242
249
  - spec/fixtures/notifications.json
@@ -250,6 +257,7 @@ files:
250
257
  - spec/fixtures/organization_team_members.json
251
258
  - spec/fixtures/organization_team_repos.json
252
259
  - spec/fixtures/organizations.json
260
+ - spec/fixtures/participation_stats.json
253
261
  - spec/fixtures/public_events.json
254
262
  - spec/fixtures/public_gists.json
255
263
  - spec/fixtures/public_key.json
@@ -268,6 +276,7 @@ files:
268
276
  - spec/fixtures/pull_requests.json
269
277
  - spec/fixtures/pull_requests_comments.json
270
278
  - spec/fixtures/pull_update.json
279
+ - spec/fixtures/punch_card_stats.json
271
280
  - spec/fixtures/readme.json
272
281
  - spec/fixtures/ref.json
273
282
  - spec/fixtures/ref_create.json
@@ -302,6 +311,8 @@ files:
302
311
  - spec/fixtures/thread_subscription_update.json
303
312
  - spec/fixtures/tree.json
304
313
  - spec/fixtures/tree_create.json
314
+ - spec/fixtures/update_content.json
315
+ - spec/fixtures/updated_file.txt
305
316
  - spec/fixtures/user.json
306
317
  - spec/fixtures/user_events.json
307
318
  - spec/fixtures/user_issues.json
@@ -335,13 +346,14 @@ files:
335
346
  - spec/octokit/client/refs_spec.rb
336
347
  - spec/octokit/client/repositories_spec.rb
337
348
  - spec/octokit/client/say_spec.rb
349
+ - spec/octokit/client/stats_spec.rb
338
350
  - spec/octokit/client/statuses_spec.rb
339
351
  - spec/octokit/client/users_spec.rb
340
352
  - spec/octokit/client_spec.rb
341
353
  - spec/octokit/gist_spec.rb
342
354
  - spec/octokit/repository_spec.rb
343
355
  - spec/octokit_spec.rb
344
- homepage: https://github.com/pengwynn/octokit
356
+ homepage: https://github.com/octokit/octokit.rb
345
357
  licenses:
346
358
  - MIT
347
359
  post_install_message:
@@ -359,7 +371,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
359
371
  requirements:
360
372
  - - ! '>='
361
373
  - !ruby/object:Gem::Version
362
- version: 1.3.6
374
+ version: 1.3.5
363
375
  requirements: []
364
376
  rubyforge_project:
365
377
  rubygems_version: 1.8.23
@@ -375,10 +387,12 @@ test_files:
375
387
  - spec/fixtures/blob.json
376
388
  - spec/fixtures/blob_create.json
377
389
  - spec/fixtures/branches.json
390
+ - spec/fixtures/code_frequency_stats.json
378
391
  - spec/fixtures/collaborators.json
379
392
  - spec/fixtures/comment.json
380
393
  - spec/fixtures/comments.json
381
394
  - spec/fixtures/commit.json
395
+ - spec/fixtures/commit_activity_stats.json
382
396
  - spec/fixtures/commit_comment.json
383
397
  - spec/fixtures/commit_comment_create.json
384
398
  - spec/fixtures/commit_comment_update.json
@@ -387,7 +401,10 @@ test_files:
387
401
  - spec/fixtures/commits.json
388
402
  - spec/fixtures/compare.json
389
403
  - spec/fixtures/contents.json
404
+ - spec/fixtures/contributor_stats.json
390
405
  - spec/fixtures/contributors.json
406
+ - spec/fixtures/create_content.json
407
+ - spec/fixtures/delete_content.json
391
408
  - spec/fixtures/download.json
392
409
  - spec/fixtures/download_create.json
393
410
  - spec/fixtures/downloads.json
@@ -427,6 +444,7 @@ test_files:
427
444
  - spec/fixtures/merge.json
428
445
  - spec/fixtures/milestone.json
429
446
  - spec/fixtures/milestones.json
447
+ - spec/fixtures/new_file.txt
430
448
  - spec/fixtures/not_found.json
431
449
  - spec/fixtures/notification_thread.json
432
450
  - spec/fixtures/notifications.json
@@ -440,6 +458,7 @@ test_files:
440
458
  - spec/fixtures/organization_team_members.json
441
459
  - spec/fixtures/organization_team_repos.json
442
460
  - spec/fixtures/organizations.json
461
+ - spec/fixtures/participation_stats.json
443
462
  - spec/fixtures/public_events.json
444
463
  - spec/fixtures/public_gists.json
445
464
  - spec/fixtures/public_key.json
@@ -458,6 +477,7 @@ test_files:
458
477
  - spec/fixtures/pull_requests.json
459
478
  - spec/fixtures/pull_requests_comments.json
460
479
  - spec/fixtures/pull_update.json
480
+ - spec/fixtures/punch_card_stats.json
461
481
  - spec/fixtures/readme.json
462
482
  - spec/fixtures/ref.json
463
483
  - spec/fixtures/ref_create.json
@@ -492,6 +512,8 @@ test_files:
492
512
  - spec/fixtures/thread_subscription_update.json
493
513
  - spec/fixtures/tree.json
494
514
  - spec/fixtures/tree_create.json
515
+ - spec/fixtures/update_content.json
516
+ - spec/fixtures/updated_file.txt
495
517
  - spec/fixtures/user.json
496
518
  - spec/fixtures/user_events.json
497
519
  - spec/fixtures/user_issues.json
@@ -525,6 +547,7 @@ test_files:
525
547
  - spec/octokit/client/refs_spec.rb
526
548
  - spec/octokit/client/repositories_spec.rb
527
549
  - spec/octokit/client/say_spec.rb
550
+ - spec/octokit/client/stats_spec.rb
528
551
  - spec/octokit/client/statuses_spec.rb
529
552
  - spec/octokit/client/users_spec.rb
530
553
  - spec/octokit/client_spec.rb