octokit 0.6.3 → 0.6.4

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 (53) hide show
  1. data/.travis.yml +1 -0
  2. data/CHANGELOG.md +18 -18
  3. data/README.md +5 -3
  4. data/Rakefile +2 -0
  5. data/lib/faraday/response/{raise_error.rb → raise_octokit_error.rb} +11 -2
  6. data/lib/octokit.rb +18 -46
  7. data/lib/octokit/authentication.rb +21 -0
  8. data/lib/octokit/client.rb +13 -6
  9. data/lib/octokit/client/commits.rb +2 -2
  10. data/lib/octokit/client/issues.rb +184 -21
  11. data/lib/octokit/client/milestones.rb +87 -0
  12. data/lib/octokit/client/network.rb +2 -4
  13. data/lib/octokit/client/objects.rb +6 -8
  14. data/lib/octokit/client/organizations.rb +18 -19
  15. data/lib/octokit/client/pub_sub_hubbub.rb +41 -0
  16. data/lib/octokit/client/pub_sub_hubbub/service_hooks.rb +41 -0
  17. data/lib/octokit/client/pulls.rb +12 -3
  18. data/lib/octokit/client/repositories.rb +28 -30
  19. data/lib/octokit/client/timelines.rb +3 -5
  20. data/lib/octokit/client/users.rb +40 -18
  21. data/lib/octokit/connection.rb +42 -0
  22. data/lib/octokit/error.rb +34 -0
  23. data/lib/octokit/request.rb +44 -0
  24. data/lib/octokit/version.rb +1 -1
  25. data/octokit.gemspec +33 -28
  26. data/puppeteer.jpg +0 -0
  27. data/spec/faraday/response_spec.rb +2 -1
  28. data/spec/fixtures/v2/commit.json +1 -1
  29. data/spec/fixtures/v3/comment.json +14 -0
  30. data/spec/fixtures/v3/comments.json +44 -0
  31. data/spec/fixtures/v3/label.json +5 -0
  32. data/spec/fixtures/v3/labels.json +17 -0
  33. data/spec/fixtures/v3/milestone.json +12 -0
  34. data/spec/fixtures/v3/milestones.json +28 -0
  35. data/spec/fixtures/v3/not_found.json +3 -0
  36. data/spec/fixtures/v3/user.json +20 -0
  37. data/spec/helper.rb +14 -11
  38. data/spec/octokit/client/commits_spec.rb +3 -3
  39. data/spec/octokit/client/issues_spec.rb +82 -44
  40. data/spec/octokit/client/milestones_spec.rb +67 -0
  41. data/spec/octokit/client/objects_spec.rb +6 -6
  42. data/spec/octokit/client/organizations_spec.rb +19 -19
  43. data/spec/octokit/client/pub_sub_hubbub/service_hooks_spec.rb +45 -0
  44. data/spec/octokit/client/pub_sub_hubbub_spec.rb +49 -0
  45. data/spec/octokit/client/pulls_spec.rb +15 -3
  46. data/spec/octokit/client/repositories_spec.rb +30 -30
  47. data/spec/octokit/client/users_spec.rb +26 -26
  48. data/spec/octokit/client_spec.rb +2 -2
  49. data/spec/octokit_spec.rb +12 -3
  50. metadata +147 -55
  51. data/lib/octokit/client/authentication.rb +0 -23
  52. data/lib/octokit/client/connection.rb +0 -33
  53. data/lib/octokit/client/request.rb +0 -42
@@ -1,23 +0,0 @@
1
- module Octokit
2
- class Client
3
- module Authentication
4
- def authentication
5
- if login && token
6
- {:login => "#{login}/token", :password => token}
7
- elsif login && password
8
- {:login => login, :password => password}
9
- else
10
- {}
11
- end
12
- end
13
-
14
- def authenticated?
15
- !authentication.empty?
16
- end
17
-
18
- def oauthed?
19
- !oauth_token.nil?
20
- end
21
- end
22
- end
23
- end
@@ -1,33 +0,0 @@
1
- require 'faraday_middleware'
2
- require 'faraday/response/raise_error'
3
-
4
- module Octokit
5
- class Client
6
- # @private
7
- module Connection
8
- private
9
-
10
- def connection(url, authenticate=true, raw=false)
11
- options = {
12
- :proxy => proxy,
13
- :ssl => {:verify => false},
14
- :url => url,
15
- }
16
-
17
- options.merge!(:params => { :access_token => oauth_token }) if oauthed? && !authenticated?
18
-
19
- con = Faraday::Connection.new(options) do |connection|
20
- connection.use Faraday::Request::UrlEncoded
21
- connection.use Faraday::Response::RaiseError
22
- unless raw
23
- connection.use Faraday::Response::Rashify
24
- connection.use Faraday::Response::ParseJson
25
- end
26
- connection.adapter(adapter)
27
- end
28
- con.basic_auth authentication[:login], authentication[:password] if authenticate and authenticated?
29
- con
30
- end
31
- end
32
- end
33
- end
@@ -1,42 +0,0 @@
1
- module Octokit
2
- class Client
3
- module Request
4
- def get(path, options={}, version=api_version, authenticate=true, raw=false)
5
- request(:get, path, options, version, authenticate, raw)
6
- end
7
-
8
- def post(path, options={}, version=api_version, authenticate=true, raw=false)
9
- request(:post, path, options, version, authenticate, raw)
10
- end
11
-
12
- def put(path, options={}, version=api_version, authenticate=true, raw=false)
13
- request(:put, path, options, version, authenticate, raw)
14
- end
15
-
16
- def delete(path, options={}, version=api_version, authenticate=true, raw=false)
17
- request(:delete, path, options, version, authenticate, raw)
18
- end
19
-
20
- private
21
-
22
- def request(method, path, options, version, authenticate, raw)
23
- if [1, 2].include? version
24
- url = "https://github.com/"
25
- elsif version >= 3
26
- url = "https://api.github.com/"
27
- end
28
- response = connection(url, authenticate, raw).send(method) do |request|
29
- case method
30
- when :get, :delete
31
- request.url(path, options)
32
- when :post, :put
33
- request.path = path
34
- request.body = options unless options.empty?
35
- end
36
- end
37
- raw ? response : response.body
38
- end
39
-
40
- end
41
- end
42
- end