github_api 0.3.4 → 0.3.5
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.
- metadata +4 -140
- data/LICENSE.txt +0 -20
- data/README.rdoc +0 -228
- data/Rakefile +0 -52
- data/features/github_api.feature +0 -50
- data/features/step_definitions/github_api_steps.rb +0 -11
- data/features/support/env.rb +0 -13
- data/lib/github_api.rb +0 -73
- data/lib/github_api/api.rb +0 -175
- data/lib/github_api/api/utils.rb +0 -9
- data/lib/github_api/authorization.rb +0 -73
- data/lib/github_api/authorizations.rb +0 -119
- data/lib/github_api/cache_control.rb +0 -19
- data/lib/github_api/client.rb +0 -55
- data/lib/github_api/compatibility.rb +0 -23
- data/lib/github_api/configuration.rb +0 -96
- data/lib/github_api/connection.rb +0 -81
- data/lib/github_api/core_ext/array.rb +0 -14
- data/lib/github_api/core_ext/hash.rb +0 -42
- data/lib/github_api/error.rb +0 -35
- data/lib/github_api/events.rb +0 -202
- data/lib/github_api/gists.rb +0 -200
- data/lib/github_api/gists/comments.rb +0 -86
- data/lib/github_api/git_data.rb +0 -26
- data/lib/github_api/git_data/blobs.rb +0 -51
- data/lib/github_api/git_data/commits.rb +0 -78
- data/lib/github_api/git_data/references.rb +0 -113
- data/lib/github_api/git_data/tags.rb +0 -78
- data/lib/github_api/git_data/trees.rb +0 -89
- data/lib/github_api/issues.rb +0 -215
- data/lib/github_api/issues/comments.rb +0 -110
- data/lib/github_api/issues/events.rb +0 -50
- data/lib/github_api/issues/labels.rb +0 -191
- data/lib/github_api/issues/milestones.rb +0 -119
- data/lib/github_api/mime_type.rb +0 -55
- data/lib/github_api/orgs.rb +0 -95
- data/lib/github_api/orgs/members.rb +0 -120
- data/lib/github_api/orgs/teams.rb +0 -245
- data/lib/github_api/pull_requests.rb +0 -224
- data/lib/github_api/pull_requests/comments.rb +0 -144
- data/lib/github_api/repos.rb +0 -286
- data/lib/github_api/repos/collaborators.rb +0 -81
- data/lib/github_api/repos/commits.rb +0 -180
- data/lib/github_api/repos/downloads.rb +0 -155
- data/lib/github_api/repos/forks.rb +0 -48
- data/lib/github_api/repos/hooks.rb +0 -173
- data/lib/github_api/repos/keys.rb +0 -104
- data/lib/github_api/repos/pub_sub_hubbub.rb +0 -102
- data/lib/github_api/repos/watching.rb +0 -94
- data/lib/github_api/request.rb +0 -84
- data/lib/github_api/request/basic_auth.rb +0 -31
- data/lib/github_api/request/caching.rb +0 -33
- data/lib/github_api/request/oauth2.rb +0 -33
- data/lib/github_api/response.rb +0 -28
- data/lib/github_api/response/helpers.rb +0 -14
- data/lib/github_api/response/jsonize.rb +0 -26
- data/lib/github_api/response/mashify.rb +0 -24
- data/lib/github_api/response/raise_error.rb +0 -33
- data/lib/github_api/result.rb +0 -42
- data/lib/github_api/users.rb +0 -84
- data/lib/github_api/users/emails.rb +0 -49
- data/lib/github_api/users/followers.rb +0 -98
- data/lib/github_api/users/keys.rb +0 -84
- data/lib/github_api/version.rb +0 -12
- data/spec/README.rdoc +0 -22
- data/spec/coverage_adapter.rb +0 -14
- data/spec/fixtures/auths/authorization.json +0 -14
- data/spec/fixtures/auths/authorizations.json +0 -16
- data/spec/fixtures/events/events.json +0 -29
- data/spec/fixtures/issues/issue.json +0 -56
- data/spec/fixtures/issues/issues.json +0 -58
- data/spec/fixtures/orgs/members.json +0 -9
- data/spec/fixtures/orgs/org.json +0 -18
- data/spec/fixtures/orgs/orgs.json +0 -8
- data/spec/fixtures/orgs/team.json +0 -8
- data/spec/fixtures/orgs/team_repos.json +0 -29
- data/spec/fixtures/orgs/teams.json +0 -7
- data/spec/fixtures/repos/branches.json +0 -9
- data/spec/fixtures/repos/collaborators.json +0 -8
- data/spec/fixtures/repos/commit.json +0 -53
- data/spec/fixtures/repos/commit_comment.json +0 -16
- data/spec/fixtures/repos/commit_comments.json +0 -18
- data/spec/fixtures/repos/commits.json +0 -27
- data/spec/fixtures/repos/contributors.json +0 -8
- data/spec/fixtures/repos/download.json +0 -10
- data/spec/fixtures/repos/download_s3.json +0 -21
- data/spec/fixtures/repos/downloads.json +0 -12
- data/spec/fixtures/repos/fork.json +0 -27
- data/spec/fixtures/repos/forks.json +0 -29
- data/spec/fixtures/repos/hook.json +0 -15
- data/spec/fixtures/repos/hooks.json +0 -10
- data/spec/fixtures/repos/key.json +0 -6
- data/spec/fixtures/repos/keys.json +0 -8
- data/spec/fixtures/repos/languages.json +0 -4
- data/spec/fixtures/repos/repo.json +0 -90
- data/spec/fixtures/repos/repo_comments.json +0 -18
- data/spec/fixtures/repos/repos.json +0 -29
- data/spec/fixtures/repos/tags.json +0 -11
- data/spec/fixtures/repos/teams.json +0 -7
- data/spec/fixtures/repos/watched.json +0 -29
- data/spec/fixtures/repos/watchers.json +0 -8
- data/spec/fixtures/users/user.json +0 -32
- data/spec/github/api_spec.rb +0 -25
- data/spec/github/authorization_spec.rb +0 -176
- data/spec/github/authorizations_spec.rb +0 -242
- data/spec/github/client_spec.rb +0 -50
- data/spec/github/core_ext/hash_spec.rb +0 -44
- data/spec/github/events_spec.rb +0 -491
- data/spec/github/gists/comments_spec.rb +0 -5
- data/spec/github/gists_spec.rb +0 -5
- data/spec/github/git_data/blobs_spec.rb +0 -5
- data/spec/github/git_data/commits_spec.rb +0 -5
- data/spec/github/git_data/references_spec.rb +0 -5
- data/spec/github/git_data/tags_spec.rb +0 -5
- data/spec/github/git_data/trees_spec.rb +0 -5
- data/spec/github/git_data_spec.rb +0 -5
- data/spec/github/issues/comments_spec.rb +0 -5
- data/spec/github/issues/events_spec.rb +0 -5
- data/spec/github/issues/labels_spec.rb +0 -5
- data/spec/github/issues/milestones_spec.rb +0 -5
- data/spec/github/issues_spec.rb +0 -287
- data/spec/github/mime_type_spec.rb +0 -70
- data/spec/github/orgs/members_spec.rb +0 -275
- data/spec/github/orgs/teams_spec.rb +0 -563
- data/spec/github/orgs_spec.rb +0 -160
- data/spec/github/repos/collaborators_spec.rb +0 -169
- data/spec/github/repos/commits_spec.rb +0 -424
- data/spec/github/repos/downloads_spec.rb +0 -236
- data/spec/github/repos/forks_spec.rb +0 -103
- data/spec/github/repos/hooks_spec.rb +0 -307
- data/spec/github/repos/keys_spec.rb +0 -216
- data/spec/github/repos/pub_sub_hubbub_spec.rb +0 -83
- data/spec/github/repos/watching_spec.rb +0 -222
- data/spec/github/repos_spec.rb +0 -571
- data/spec/github/result_spec.rb +0 -43
- data/spec/github/users_spec.rb +0 -140
- data/spec/github_spec.rb +0 -109
- data/spec/spec_helper.rb +0 -86
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
require 'faraday'
|
|
4
|
-
|
|
5
|
-
module Github
|
|
6
|
-
module Request
|
|
7
|
-
class OAuth2 < Faraday::Middleware
|
|
8
|
-
dependency 'oauth2'
|
|
9
|
-
|
|
10
|
-
def call(env)
|
|
11
|
-
# puts "ENV: #{env.inspect}"
|
|
12
|
-
# puts "TOKEN : #{@token}"
|
|
13
|
-
# puts "APP: #{@app}"
|
|
14
|
-
|
|
15
|
-
# Extract parameters from the query
|
|
16
|
-
params = env[:url].query_values || {}
|
|
17
|
-
|
|
18
|
-
env[:url].query_values = { 'access_token' => @token }.merge(params)
|
|
19
|
-
|
|
20
|
-
token = env[:url].query_values['access_token']
|
|
21
|
-
|
|
22
|
-
env[:request_headers].merge!('Authorization' => "Token token=\"#{token}\"")
|
|
23
|
-
|
|
24
|
-
@app.call env
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def initialize(app, *args)
|
|
28
|
-
@app = app
|
|
29
|
-
@token = args.shift
|
|
30
|
-
end
|
|
31
|
-
end # OAuth2
|
|
32
|
-
end # Request
|
|
33
|
-
end # Github
|
data/lib/github_api/response.rb
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
require 'faraday'
|
|
4
|
-
|
|
5
|
-
module Github
|
|
6
|
-
# Contains methods and attributes that act on the response returned from the
|
|
7
|
-
# request
|
|
8
|
-
class Response < Faraday::Response::Middleware
|
|
9
|
-
CONTENT_TYPE = 'Content-Type'.freeze
|
|
10
|
-
|
|
11
|
-
class << self
|
|
12
|
-
attr_accessor :parser
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def self.define_parser(&block)
|
|
16
|
-
@parser = block
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def response_type(env)
|
|
20
|
-
env[:response_headers][CONTENT_TYPE].to_s
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def parse_response?(env)
|
|
24
|
-
env[:body].respond_to? :to_str
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
end # Response
|
|
28
|
-
end # Github
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
require 'faraday'
|
|
4
|
-
|
|
5
|
-
module Github
|
|
6
|
-
class Response::Jsonize < Response
|
|
7
|
-
dependency 'multi_json'
|
|
8
|
-
|
|
9
|
-
define_parser do |body|
|
|
10
|
-
::MultiJson.decode body
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def parse(body)
|
|
14
|
-
case body
|
|
15
|
-
when ''
|
|
16
|
-
nil
|
|
17
|
-
when 'true'
|
|
18
|
-
true
|
|
19
|
-
when 'false'
|
|
20
|
-
false
|
|
21
|
-
else
|
|
22
|
-
self.class.parser.call body
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end # Response::Jsonize
|
|
26
|
-
end # Github
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
require 'faraday'
|
|
4
|
-
|
|
5
|
-
module Github
|
|
6
|
-
class Response::Mashify < Response
|
|
7
|
-
dependency 'hashie/mash'
|
|
8
|
-
|
|
9
|
-
define_parser do |body|
|
|
10
|
-
::Hashie::Mash.new body
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def parse(body)
|
|
14
|
-
case body
|
|
15
|
-
when Hash
|
|
16
|
-
self.class.parser.call body
|
|
17
|
-
when Array
|
|
18
|
-
body.map { |item| item.is_a?(Hash) ? self.class.parser.call(item) : item }
|
|
19
|
-
else
|
|
20
|
-
body
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end # Response::Mashify
|
|
24
|
-
end # Github
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
require 'faraday'
|
|
4
|
-
require 'github_api/error'
|
|
5
|
-
|
|
6
|
-
module Github
|
|
7
|
-
class Response::RaiseError < Faraday::Response::Middleware
|
|
8
|
-
|
|
9
|
-
def on_complete(env)
|
|
10
|
-
case env[:status].to_i
|
|
11
|
-
when 400
|
|
12
|
-
raise Github::BadRequest.new(response_message(env), env[:response_headers])
|
|
13
|
-
when 401
|
|
14
|
-
raise Github::Unauthorised.new(response_message(env), env[:response_headers])
|
|
15
|
-
when 403
|
|
16
|
-
raise Github::Forbidden.new(response_message(env), env[:response_headers])
|
|
17
|
-
when 404
|
|
18
|
-
raise Github::ResourceNotFound.new(response_message(env), env[:response_headers])
|
|
19
|
-
when 500
|
|
20
|
-
raise Github::InternalServerError.new(response_message(env), env[:response_headers])
|
|
21
|
-
when 503
|
|
22
|
-
raise Github::ServiceUnavailable.new(response_message(env), env[:response_headers])
|
|
23
|
-
when 400...600
|
|
24
|
-
raise Github::Error.new(response_message(env), env[:response_headers])
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def response_message(env)
|
|
29
|
-
"#{env[:method].to_s.upcase} #{env[:url].to_s}: #{env[:status]}#{env[:body]}"
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
end # Response::RaiseError
|
|
33
|
-
end # Github
|
data/lib/github_api/result.rb
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
module Github
|
|
4
|
-
module Result
|
|
5
|
-
|
|
6
|
-
RATELIMIT = 'X-RateLimit-Remaining'.freeze
|
|
7
|
-
CONTENT_TYPE = 'Content-Type'.freeze
|
|
8
|
-
CONTENT_LENGTH = 'content-length'.freeze
|
|
9
|
-
|
|
10
|
-
attr_reader :env
|
|
11
|
-
|
|
12
|
-
# Requests are limited to API v3 to 5000 per hour.
|
|
13
|
-
def ratelimit
|
|
14
|
-
loaded? ? @env[:response_headers][RATELIMIT] : nil
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def content_type
|
|
18
|
-
loaded? ? @env[:response_headers][CONTENT_TYPE] : nil
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def content_length
|
|
22
|
-
loaded? ? @env[:response_headers][CONTENT_LENGTH] : nil
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def status
|
|
26
|
-
loaded? ? @env[:status] : nil
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def success?
|
|
30
|
-
(200..299).include? status
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def body
|
|
34
|
-
loaded? ? @env[:body] : nil
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def loaded?
|
|
38
|
-
!!env
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
end # Result
|
|
42
|
-
end # Github
|
data/lib/github_api/users.rb
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
module Github
|
|
4
|
-
class Users < API
|
|
5
|
-
extend AutoloadHelper
|
|
6
|
-
|
|
7
|
-
# Load all the modules after initializing Repos to avoid superclass mismatch
|
|
8
|
-
autoload_all 'github_api/users',
|
|
9
|
-
:Emails => 'emails',
|
|
10
|
-
:Followers => 'followers',
|
|
11
|
-
:Keys => 'keys'
|
|
12
|
-
|
|
13
|
-
include Github::Users::Emails
|
|
14
|
-
include Github::Users::Followers
|
|
15
|
-
include Github::Users::Keys
|
|
16
|
-
|
|
17
|
-
VALID_USER_PARAMS_NAMES = %w[
|
|
18
|
-
name
|
|
19
|
-
email
|
|
20
|
-
blog
|
|
21
|
-
company
|
|
22
|
-
location
|
|
23
|
-
hireable
|
|
24
|
-
bio
|
|
25
|
-
].freeze
|
|
26
|
-
|
|
27
|
-
# Creates new Repos API
|
|
28
|
-
def initialize(options = {})
|
|
29
|
-
super(options)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# Get a single unauthenticated user
|
|
33
|
-
#
|
|
34
|
-
# = Examples
|
|
35
|
-
# @github = Github.new
|
|
36
|
-
# @github.users.get_user 'user-name'
|
|
37
|
-
#
|
|
38
|
-
# Get the authenticated user
|
|
39
|
-
#
|
|
40
|
-
# = Examples
|
|
41
|
-
# @github = Github.new :oauth_token => '...'
|
|
42
|
-
# @github.users.get_user
|
|
43
|
-
#
|
|
44
|
-
def get_user(user_name=nil, params={})
|
|
45
|
-
_normalize_params_keys(params)
|
|
46
|
-
if user_name
|
|
47
|
-
get("/users/#{user_name}", params)
|
|
48
|
-
else
|
|
49
|
-
get("/user", params)
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
alias :get_auth_user :get_user
|
|
53
|
-
|
|
54
|
-
# Update the authenticated user
|
|
55
|
-
#
|
|
56
|
-
# = Inputs
|
|
57
|
-
# * <tt>:name</tt> - Optional string
|
|
58
|
-
# * <tt>:email</tt> - Optional string - publically visible email address
|
|
59
|
-
# * <tt>:blog</tt> - Optional string
|
|
60
|
-
# * <tt>:company</tt> - Optional string
|
|
61
|
-
# * <tt>:location</tt> - Optional string
|
|
62
|
-
# * <tt>:hireable</tt> - Optional boolean
|
|
63
|
-
# * <tt>:bio</tt> - Optional string
|
|
64
|
-
#
|
|
65
|
-
# = Examples
|
|
66
|
-
# @github = Github.new :oauth_token => '..'
|
|
67
|
-
# @github.users.update_user
|
|
68
|
-
# "name" => "monalisa octocat",
|
|
69
|
-
# "email" => "octocat@github.com",
|
|
70
|
-
# "blog" => "https://github.com/blog",
|
|
71
|
-
# "company" => "GitHub",
|
|
72
|
-
# "location" => "San Francisco",
|
|
73
|
-
# "hireable" => true,
|
|
74
|
-
# "bio" => "There once..."
|
|
75
|
-
#
|
|
76
|
-
def update_user(params={})
|
|
77
|
-
_normalize_params_keys(params)
|
|
78
|
-
_filter_params_keys(VALID_USER_PARAMS_NAMES, params)
|
|
79
|
-
patch("/user", params)
|
|
80
|
-
end
|
|
81
|
-
alias :update_authenticated_user :update_user
|
|
82
|
-
|
|
83
|
-
end # Users
|
|
84
|
-
end # Github
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
module Github
|
|
4
|
-
class Users
|
|
5
|
-
module Emails
|
|
6
|
-
|
|
7
|
-
# List email addresses for the authenticated user
|
|
8
|
-
#
|
|
9
|
-
# = Examples
|
|
10
|
-
# @github = Github.new :oauth_token => '...'
|
|
11
|
-
# @github.users.emails
|
|
12
|
-
#
|
|
13
|
-
def emails(params={})
|
|
14
|
-
get("/user/emails", params)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# Add email address(es) for the authenticated user
|
|
18
|
-
#
|
|
19
|
-
# = Inputs
|
|
20
|
-
# You can include a single email address or an array of addresses
|
|
21
|
-
#
|
|
22
|
-
# = Examples
|
|
23
|
-
# @github = Github.new :oauth_token => '...'
|
|
24
|
-
# @github.users.add_email "octocat@github.com", "support@github.com"
|
|
25
|
-
#
|
|
26
|
-
def add_email(*args)
|
|
27
|
-
params = _extract_parameters(args)
|
|
28
|
-
params['data'] = [args].flatten
|
|
29
|
-
post("/user/emails", params)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# Delete email address(es) for the authenticated user
|
|
33
|
-
#
|
|
34
|
-
# = Inputs
|
|
35
|
-
# You can include a single email address or an array of addresses
|
|
36
|
-
#
|
|
37
|
-
# = Examples
|
|
38
|
-
# @github = Github.new :oauth_token => '...'
|
|
39
|
-
# @github.users.delete_email "octocat@github.com", "support@github.com"
|
|
40
|
-
#
|
|
41
|
-
def add_email(*args)
|
|
42
|
-
params = _extract_parameters(args)
|
|
43
|
-
params['data'] = [args].flatten
|
|
44
|
-
delete("/user/emails", params)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
end # Emails
|
|
48
|
-
end # Users
|
|
49
|
-
end # Github
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
module Github
|
|
4
|
-
class Users
|
|
5
|
-
module Followers
|
|
6
|
-
|
|
7
|
-
# List a user's followers
|
|
8
|
-
#
|
|
9
|
-
# = Examples
|
|
10
|
-
# @github = Github.new
|
|
11
|
-
# @github.users.followers 'user-name'
|
|
12
|
-
# @github.users.followers 'user-name' { |user| ... }
|
|
13
|
-
#
|
|
14
|
-
# List the authenticated user's followers
|
|
15
|
-
#
|
|
16
|
-
# = Examples
|
|
17
|
-
# @github = Github.new :oauth_token => '...'
|
|
18
|
-
# @github.users.following
|
|
19
|
-
# @github.users.following { |user| ... }
|
|
20
|
-
#
|
|
21
|
-
def followers(user_name=nil, params={})
|
|
22
|
-
_normalize_params_keys(params)
|
|
23
|
-
response = if user_name
|
|
24
|
-
get("/users/#{user_name}/followers", params)
|
|
25
|
-
else
|
|
26
|
-
get("/user/followers", params)
|
|
27
|
-
end
|
|
28
|
-
return response unless block_given?
|
|
29
|
-
response.each { |el| yield el }
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# List who a user is following
|
|
33
|
-
#
|
|
34
|
-
# = Examples
|
|
35
|
-
# @github = Github.new
|
|
36
|
-
# @github.users.following 'user-name'
|
|
37
|
-
# @github.users.following 'user-name' { |user| ... }
|
|
38
|
-
#
|
|
39
|
-
# List who the authenicated user is following
|
|
40
|
-
#
|
|
41
|
-
# = Examples
|
|
42
|
-
#
|
|
43
|
-
# @github = Github.new :oauth_token => '...'
|
|
44
|
-
# @github.users.following
|
|
45
|
-
#
|
|
46
|
-
def following(user_name=nil, params={})
|
|
47
|
-
_normalize_params_keys(params)
|
|
48
|
-
response = if user_name
|
|
49
|
-
get("/users/#{user_name}/following", params)
|
|
50
|
-
else
|
|
51
|
-
get("/user/following", params)
|
|
52
|
-
end
|
|
53
|
-
return response unless block_given?
|
|
54
|
-
response.each { |el| yield el }
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
# Check if you are following a user
|
|
58
|
-
#
|
|
59
|
-
# = Examples
|
|
60
|
-
# @github = Github.new :oauth_token => '...'
|
|
61
|
-
# @github.users.following? 'user-name'
|
|
62
|
-
#
|
|
63
|
-
def following?(user_name, params={})
|
|
64
|
-
_validate_presence_of user_name
|
|
65
|
-
_normalize_params_keys(params)
|
|
66
|
-
get("/user/following/#{user_name}", params)
|
|
67
|
-
true
|
|
68
|
-
rescue Github::ResourceNotFound
|
|
69
|
-
false
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
# Follow a user
|
|
73
|
-
#
|
|
74
|
-
# = Examples
|
|
75
|
-
# @github = Github.new :oauth_token => '...'
|
|
76
|
-
# @github.users.follow 'user-name'
|
|
77
|
-
#
|
|
78
|
-
def follow(user_name, params={})
|
|
79
|
-
_validate_presence_of user_name
|
|
80
|
-
_normalize_params_keys(params)
|
|
81
|
-
put("/user/following/#{user_name}", params)
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
# Unfollow a user
|
|
85
|
-
#
|
|
86
|
-
# = Examples
|
|
87
|
-
# @github = Github.new :oauth_token => '...'
|
|
88
|
-
# @github.users.unfollow 'user-name'
|
|
89
|
-
#
|
|
90
|
-
def unfollow(user_name, params={})
|
|
91
|
-
_validate_presence_of user_name
|
|
92
|
-
_normalize_params_keys(params)
|
|
93
|
-
delete("/user/following/#{user_name}", params)
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
end # Followers
|
|
97
|
-
end # Users
|
|
98
|
-
end # Github
|