octokit 1.11.0 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
1
1
  # CHANGELOG
2
2
 
3
+ * [1.12.0 - September 4,2012](https://github.com/pengwynn/octokit/compare/v1.11.0...v1.12.0)
3
4
  * [1.11.0 - August 29, 2012](https://github.com/pengwynn/octokit/compare/v1.10.0...v1.11.0)
4
5
  * [1.10.0 - August 8, 2012](https://github.com/pengwynn/octokit/compare/v1.9.4...v1.10.0)
5
6
  * [1.9.4 - August 6, 2012](https://github.com/pengwynn/octokit/compare/v1.9.3...v1.9.4)
@@ -15,5 +15,16 @@ module Octokit
15
15
  def oauthed?
16
16
  !oauth_token.nil?
17
17
  end
18
+
19
+ def unauthed_rate_limited?
20
+ client_id && client_secret
21
+ end
22
+
23
+ def unauthed_rate_limit_params
24
+ {
25
+ :client_id => client_id,
26
+ :client_secret => client_secret
27
+ }
28
+ end
18
29
  end
19
30
  end
@@ -23,6 +23,7 @@ require 'octokit/client/refs'
23
23
  require 'octokit/client/contents'
24
24
  require 'octokit/client/markdown'
25
25
  require 'octokit/client/emojis'
26
+ require 'octokit/client/statuses'
26
27
 
27
28
  module Octokit
28
29
  class Client
@@ -58,5 +59,6 @@ module Octokit
58
59
  include Octokit::Client::Contents
59
60
  include Octokit::Client::Markdown
60
61
  include Octokit::Client::Emojis
62
+ include Octokit::Client::Statuses
61
63
  end
62
64
  end
@@ -0,0 +1,29 @@
1
+ module Octokit
2
+ class Client
3
+ module Statuses
4
+
5
+ # List all statuses for a given commit
6
+ #
7
+ # @param repo [String, Repository, Hash] A GitHub repository
8
+ # @param sha [String] The SHA1 for the commit
9
+ # @return [Array] A list of statuses
10
+ # @see http://developer.github.com/v3/repos/status
11
+ def statuses(repo, sha, options={})
12
+ get("repos/#{Repository.new(repo)}/statuses/#{sha}", options, 3)
13
+ end
14
+ alias :list_statuses :statuses
15
+
16
+ # Create status for a commit
17
+ #
18
+ # @param repo [String, Repository, Hash] A GitHub repository
19
+ # @param sha [String] The SHA1 for the commit
20
+ # @param state [String] The state: pending, success, failure, error
21
+ # @return [Hash] A status
22
+ # @see http://developer.github.com/v3/repos/status
23
+ def create_status(repo, sha, state, options={})
24
+ options.merge!(:state => state)
25
+ post("repos/#{Repository.new(repo)}/statuses/#{sha}", options, 3)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -12,6 +12,8 @@ module Octokit
12
12
  :password,
13
13
  :proxy,
14
14
  :oauth_token,
15
+ :client_id,
16
+ :client_secret,
15
17
  :user_agent,
16
18
  :auto_traversal,
17
19
  :per_page].freeze
@@ -54,6 +56,8 @@ module Octokit
54
56
  self.password = nil
55
57
  self.proxy = nil
56
58
  self.oauth_token = nil
59
+ self.client_id = nil
60
+ self.client_secret = nil
57
61
  self.user_agent = DEFAULT_USER_AGENT
58
62
  self.auto_traversal = DEFAULT_AUTO_TRAVERSAL
59
63
  end
@@ -19,6 +19,7 @@ module Octokit
19
19
  }
20
20
 
21
21
  options.merge!(:params => {:access_token => oauth_token}) if oauthed? && !authenticated?
22
+ options.merge!(:params => unauthed_rate_limit_params) if !oauthed? && !authenticated? && unauthed_rate_limited?
22
23
 
23
24
  # TODO: Don't build on every request
24
25
  connection = Faraday.new(options) do |builder|
@@ -1,3 +1,3 @@
1
1
  module Octokit
2
- VERSION = "1.11.0" unless defined?(Octokit::VERSION)
2
+ VERSION = "1.12.0" unless defined?(Octokit::VERSION)
3
3
  end
@@ -0,0 +1,16 @@
1
+ {
2
+ "target_url": "http://wynnnetherland.com",
3
+ "created_at": "2012-08-31T19:43:44Z",
4
+ "creator": {
5
+ "avatar_url": "https://secure.gravatar.com/avatar/7e19cd5486b5d6dc1ef90e671ba52ae0?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png",
6
+ "gravatar_id": "7e19cd5486b5d6dc1ef90e671ba52ae0",
7
+ "login": "pengwynn",
8
+ "url": "https://api.github.com/users/pengwynn",
9
+ "id": 865
10
+ },
11
+ "description": null,
12
+ "updated_at": "2012-08-31T19:43:44Z",
13
+ "url": "https://api.github.com/repos/pengwynn/api-sandbox/statuses/195422",
14
+ "id": 195422,
15
+ "state": "success"
16
+ }
@@ -0,0 +1,34 @@
1
+ [
2
+ {
3
+ "target_url": "http://travis-ci.org/pengwynn/octokit/builds/2092930",
4
+ "created_at": "2012-08-11T06:49:10Z",
5
+ "creator": {
6
+ "avatar_url": "https://secure.gravatar.com/avatar/7e19cd5486b5d6dc1ef90e671ba52ae0?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png",
7
+ "gravatar_id": "7e19cd5486b5d6dc1ef90e671ba52ae0",
8
+ "login": "pengwynn",
9
+ "url": "https://api.github.com/users/pengwynn",
10
+ "id": 865
11
+ },
12
+ "description": "The Travis build failed",
13
+ "updated_at": "2012-08-11T06:49:10Z",
14
+ "url": "https://api.github.com/repos/pengwynn/octokit/statuses/64171",
15
+ "id": 64171,
16
+ "state": "failure"
17
+ },
18
+ {
19
+ "target_url": "http://travis-ci.org/pengwynn/octokit/builds/2092930",
20
+ "created_at": "2012-08-11T06:48:35Z",
21
+ "creator": {
22
+ "avatar_url": "https://secure.gravatar.com/avatar/7e19cd5486b5d6dc1ef90e671ba52ae0?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png",
23
+ "gravatar_id": "7e19cd5486b5d6dc1ef90e671ba52ae0",
24
+ "login": "pengwynn",
25
+ "url": "https://api.github.com/users/pengwynn",
26
+ "id": 865
27
+ },
28
+ "description": "The Travis build is in progress",
29
+ "updated_at": "2012-08-11T06:48:35Z",
30
+ "url": "https://api.github.com/repos/pengwynn/octokit/statuses/64167",
31
+ "id": 64167,
32
+ "state": "pending"
33
+ }
34
+ ]
@@ -0,0 +1,35 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ describe Octokit::Client::Statuses do
5
+
6
+ before do
7
+ @client = Octokit::Client.new(:login => 'sferik')
8
+ end
9
+
10
+ describe '.statuses' do
11
+
12
+ it 'should list commit statuses' do
13
+ stub_get('https://api.github.com/repos/pengwynn/octokit/statuses/7d069dedd4cb56bf57760688657abd0e6b5a28b8').
14
+ to_return(:body => fixture('v3/statuses.json'))
15
+ statuses = @client.statuses('pengwynn/octokit', '7d069dedd4cb56bf57760688657abd0e6b5a28b8')
16
+ statuses.first.target_url.should == 'http://travis-ci.org/pengwynn/octokit/builds/2092930'
17
+ end
18
+
19
+ end
20
+
21
+ describe '.create_status' do
22
+
23
+ it 'should create status' do
24
+ stub_post('https://api.github.com/repos/pengwynn/octokit/statuses/7d069dedd4cb56bf57760688657abd0e6b5a28b8').
25
+ to_return(:body => fixture('v3/status.json'))
26
+ info = {
27
+ :target_url => 'http://wynnnetherland.com'
28
+ }
29
+ status = @client.create_status('pengwynn/octokit', '7d069dedd4cb56bf57760688657abd0e6b5a28b8', 'success', info)
30
+ status.target_url.should == 'http://wynnnetherland.com'
31
+ end
32
+
33
+ end
34
+
35
+ end
@@ -62,6 +62,32 @@ describe Octokit::Client do
62
62
 
63
63
  end
64
64
 
65
+ describe "unauthed rate limit" do
66
+
67
+ before(:each) do
68
+ Octokit.client_id = "OU812"
69
+ Octokit.client_secret = "P4N4MA"
70
+
71
+ stub_request(:get, "https://api.github.com/rate_limit?client_id=OU812&client_secret=P4N4MA").
72
+ to_return(:status => 200, :body => '', :headers =>
73
+ { 'X-RateLimit-Limit' => 62500, 'X-RateLimit-Remaining' => 62500})
74
+ @client = Octokit::Client.new()
75
+ end
76
+
77
+ after(:each) do
78
+ Octokit.reset
79
+ end
80
+
81
+ it "should get the ratelimit-limit from the header" do
82
+ @client.ratelimit.should == 62500
83
+ end
84
+
85
+ it "should get the ratelimit-remaining using header" do
86
+ @client.ratelimit_remaining.should == 62500
87
+ end
88
+
89
+ end
90
+
65
91
  describe "api_endpoint" do
66
92
 
67
93
  after(:each) 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.11.0
4
+ version: 1.12.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: 2012-08-30 00:00:00.000000000 Z
14
+ date: 2012-09-04 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: addressable
@@ -246,6 +246,7 @@ files:
246
246
  - lib/octokit/client/pulls.rb
247
247
  - lib/octokit/client/refs.rb
248
248
  - lib/octokit/client/repositories.rb
249
+ - lib/octokit/client/statuses.rb
249
250
  - lib/octokit/client/users.rb
250
251
  - lib/octokit/configuration.rb
251
252
  - lib/octokit/connection.rb
@@ -327,6 +328,8 @@ files:
327
328
  - spec/fixtures/v3/repositories.json
328
329
  - spec/fixtures/v3/repository.json
329
330
  - spec/fixtures/v3/starred_gists.json
331
+ - spec/fixtures/v3/status.json
332
+ - spec/fixtures/v3/statuses.json
330
333
  - spec/fixtures/v3/tags.json
331
334
  - spec/fixtures/v3/team.json
332
335
  - spec/fixtures/v3/teams.json
@@ -356,6 +359,7 @@ files:
356
359
  - spec/octokit/client/pulls_spec.rb
357
360
  - spec/octokit/client/refs_spec.rb
358
361
  - spec/octokit/client/repositories_spec.rb
362
+ - spec/octokit/client/statuses_spec.rb
359
363
  - spec/octokit/client/users_spec.rb
360
364
  - spec/octokit/client_spec.rb
361
365
  - spec/octokit/gist_spec.rb
@@ -458,6 +462,8 @@ test_files:
458
462
  - spec/fixtures/v3/repositories.json
459
463
  - spec/fixtures/v3/repository.json
460
464
  - spec/fixtures/v3/starred_gists.json
465
+ - spec/fixtures/v3/status.json
466
+ - spec/fixtures/v3/statuses.json
461
467
  - spec/fixtures/v3/tags.json
462
468
  - spec/fixtures/v3/team.json
463
469
  - spec/fixtures/v3/teams.json
@@ -487,6 +493,7 @@ test_files:
487
493
  - spec/octokit/client/pulls_spec.rb
488
494
  - spec/octokit/client/refs_spec.rb
489
495
  - spec/octokit/client/repositories_spec.rb
496
+ - spec/octokit/client/statuses_spec.rb
490
497
  - spec/octokit/client/users_spec.rb
491
498
  - spec/octokit/client_spec.rb
492
499
  - spec/octokit/gist_spec.rb