github_api 0.4.11 → 0.5.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +76 -72
- data/features/cassettes/gists/starred.yml +48 -0
- data/features/cassettes/pagination/repos/commits/list.yml +193 -0
- data/features/cassettes/pagination/repos/commits/next.yml +183 -0
- data/features/cassettes/pagination/repos/diff/next.yml +45 -0
- data/features/cassettes/pagination/repos/list.yml +176 -0
- data/features/cassettes/pagination/repos/list/next.yml +222 -0
- data/features/cassettes/pagination/repos/per_page/each_page.yml +45 -0
- data/features/cassettes/repos/list.yml +92 -0
- data/features/error_codes.feature +1 -1
- data/features/gists.feature +12 -3
- data/features/gists/comments.feature +3 -3
- data/features/github_api.feature +13 -2
- data/features/pagination.feature +40 -39
- data/features/repos.feature +2 -2
- data/features/step_definitions/common_steps.rb +12 -0
- data/features/step_definitions/github_api_steps.rb +12 -1
- data/lib/github_api.rb +1 -1
- data/lib/github_api/api.rb +4 -2
- data/lib/github_api/api_factory.rb +11 -5
- data/lib/github_api/authorizations.rb +23 -32
- data/lib/github_api/client.rb +1 -0
- data/lib/github_api/events.rb +38 -38
- data/lib/github_api/filter.rb +1 -1
- data/lib/github_api/gists.rb +47 -42
- data/lib/github_api/gists/comments.rb +77 -84
- data/lib/github_api/git_data.rb +25 -6
- data/lib/github_api/git_data/blobs.rb +48 -45
- data/lib/github_api/git_data/commits.rb +76 -73
- data/lib/github_api/git_data/references.rb +137 -118
- data/lib/github_api/git_data/tags.rb +74 -70
- data/lib/github_api/git_data/trees.rb +88 -85
- data/lib/github_api/issues.rb +43 -31
- data/lib/github_api/issues/comments.rb +116 -119
- data/lib/github_api/issues/events.rb +20 -19
- data/lib/github_api/issues/labels.rb +200 -197
- data/lib/github_api/issues/milestones.rb +137 -134
- data/lib/github_api/orgs.rb +27 -23
- data/lib/github_api/orgs/members.rb +105 -108
- data/lib/github_api/orgs/teams.rb +236 -237
- data/lib/github_api/paged_request.rb +1 -1
- data/lib/github_api/pull_requests.rb +40 -42
- data/lib/github_api/pull_requests/comments.rb +140 -143
- data/lib/github_api/repos.rb +101 -67
- data/lib/github_api/repos/collaborators.rb +64 -68
- data/lib/github_api/repos/commits.rb +50 -39
- data/lib/github_api/repos/downloads.rb +107 -110
- data/lib/github_api/repos/forks.rb +38 -39
- data/lib/github_api/repos/hooks.rb +161 -167
- data/lib/github_api/repos/keys.rb +86 -86
- data/lib/github_api/repos/pub_sub_hubbub.rb +99 -87
- data/lib/github_api/repos/watching.rb +80 -82
- data/lib/github_api/request.rb +5 -9
- data/lib/github_api/users.rb +26 -16
- data/lib/github_api/users/emails.rb +47 -47
- data/lib/github_api/users/followers.rb +85 -86
- data/lib/github_api/users/keys.rb +73 -75
- data/lib/github_api/validations.rb +25 -0
- data/lib/github_api/validations/format.rb +23 -0
- data/lib/github_api/validations/presence.rb +25 -0
- data/lib/github_api/validations/required.rb +21 -0
- data/lib/github_api/validations/token.rb +41 -0
- data/lib/github_api/version.rb +3 -3
- data/spec/fixtures/repos/commit_comparison.json +112 -0
- data/spec/github/api_factory_spec.rb +17 -1
- data/spec/github/authorizations_spec.rb +36 -34
- data/spec/github/gists/comments_spec.rb +39 -45
- data/spec/github/gists_spec.rb +50 -53
- data/spec/github/git_data/blobs_spec.rb +27 -20
- data/spec/github/git_data/commits_spec.rb +20 -19
- data/spec/github/git_data/references_spec.rb +83 -46
- data/spec/github/git_data/tags_spec.rb +16 -15
- data/spec/github/git_data/trees_spec.rb +20 -19
- data/spec/github/git_data_spec.rb +10 -1
- data/spec/github/issues/comments_spec.rb +78 -68
- data/spec/github/issues/events_spec.rb +42 -34
- data/spec/github/issues/labels_spec.rb +89 -101
- data/spec/github/issues/milestones_spec.rb +76 -54
- data/spec/github/issues_spec.rb +53 -57
- data/spec/github/orgs/members_spec.rb +64 -49
- data/spec/github/orgs/teams_spec.rb +112 -101
- data/spec/github/orgs_spec.rb +41 -31
- data/spec/github/paged_request_spec.rb +6 -5
- data/spec/github/pull_requests/comments_spec.rb +39 -44
- data/spec/github/pull_requests_spec.rb +32 -48
- data/spec/github/repos/collaborators_spec.rb +40 -29
- data/spec/github/repos/commits_spec.rb +108 -64
- data/spec/github/repos/downloads_spec.rb +46 -45
- data/spec/github/repos/forks_spec.rb +23 -24
- data/spec/github/repos/hooks_spec.rb +69 -71
- data/spec/github/repos/keys_spec.rb +39 -34
- data/spec/github/repos/pub_sub_hubbub_spec.rb +4 -4
- data/spec/github/repos/watching_spec.rb +31 -33
- data/spec/github/repos_spec.rb +74 -83
- data/spec/github/request_spec.rb +31 -2
- data/spec/github/users/emails_spec.rb +19 -17
- data/spec/github/users/followers_spec.rb +30 -28
- data/spec/github/users/keys_spec.rb +37 -33
- data/spec/github/users_spec.rb +124 -125
- data/spec/github/validations/format_spec.rb +42 -0
- data/spec/github/validations/presence_spec.rb +18 -0
- data/spec/github/validations/required_spec.rb +28 -0
- data/spec/github/validations/token_spec.rb +19 -0
- data/spec/github/validations_spec.rb +23 -0
- metadata +33 -10
- data/features/cassettes/pagination/repos.yml +0 -177
- data/features/cassettes/pagination/repos/next.yml +0 -177
- data/lib/github_api/validation.rb +0 -53
- data/spec/github/validation_spec.rb +0 -62
@@ -1,55 +1,55 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
module Github
|
4
|
-
class Users
|
5
|
-
module Emails
|
4
|
+
class Users::Emails < API
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
6
|
+
# List email addresses for the authenticated user
|
7
|
+
#
|
8
|
+
# = Examples
|
9
|
+
# github = Github.new :oauth_token => '...'
|
10
|
+
# github.users.emails.list
|
11
|
+
# github.users.emails.list { |email| ... }
|
12
|
+
#
|
13
|
+
def list(params={})
|
14
|
+
_normalize_params_keys(params)
|
15
|
+
response = get_request("/user/emails", params)
|
16
|
+
return response unless block_given?
|
17
|
+
response.each { |el| yield el }
|
18
|
+
end
|
19
|
+
alias :all :list
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
21
|
+
# Add email address(es) for the authenticated user
|
22
|
+
#
|
23
|
+
# = Inputs
|
24
|
+
# You can include a single email address or an array of addresses
|
25
|
+
#
|
26
|
+
# = Examples
|
27
|
+
# github = Github.new :oauth_token => '...'
|
28
|
+
# github.users.emails.add "octocat@github.com", "support@github.com"
|
29
|
+
#
|
30
|
+
def add(*args)
|
31
|
+
params = _extract_parameters(args)
|
32
|
+
_normalize_params_keys(params)
|
33
|
+
params['data'] = [args].flatten if args
|
34
|
+
post_request("/user/emails", params)
|
35
|
+
end
|
36
|
+
alias :<< :add
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
38
|
+
# Delete email address(es) for the authenticated user
|
39
|
+
#
|
40
|
+
# = Inputs
|
41
|
+
# You can include a single email address or an array of addresses
|
42
|
+
#
|
43
|
+
# = Examples
|
44
|
+
# github = Github.new :oauth_token => '...'
|
45
|
+
# github.users.emails.delete "octocat@github.com", "support@github.com"
|
46
|
+
#
|
47
|
+
def delete(*args)
|
48
|
+
params = _extract_parameters(args)
|
49
|
+
_normalize_params_keys(params)
|
50
|
+
params['data'] = [args].flatten
|
51
|
+
delete_request("/user/emails", params)
|
52
|
+
end
|
52
53
|
|
53
|
-
|
54
|
-
end # Users
|
54
|
+
end # Users::Emails
|
55
55
|
end # Github
|
@@ -1,98 +1,97 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
module Github
|
4
|
-
class Users
|
5
|
-
module Followers
|
4
|
+
class Users::Followers < API
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
28
|
-
return response unless block_given?
|
29
|
-
response.each { |el| yield el }
|
6
|
+
# List a user's followers
|
7
|
+
#
|
8
|
+
# = Examples
|
9
|
+
# github = Github.new
|
10
|
+
# github.users.followers.list 'user-name'
|
11
|
+
# github.users.followers.list 'user-name' { |user| ... }
|
12
|
+
#
|
13
|
+
# List the authenticated user's followers
|
14
|
+
#
|
15
|
+
# = Examples
|
16
|
+
# github = Github.new :oauth_token => '...'
|
17
|
+
# github.users.followers
|
18
|
+
# github.users.followers { |user| ... }
|
19
|
+
#
|
20
|
+
def list(user_name=nil, params={})
|
21
|
+
_normalize_params_keys(params)
|
22
|
+
response = if user_name
|
23
|
+
get_request("/users/#{user_name}/followers", params)
|
24
|
+
else
|
25
|
+
get_request("/user/followers", params)
|
30
26
|
end
|
27
|
+
return response unless block_given?
|
28
|
+
response.each { |el| yield el }
|
29
|
+
end
|
30
|
+
alias :all :list
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
53
|
-
return response unless block_given?
|
54
|
-
response.each { |el| yield el }
|
32
|
+
# List who a user is following
|
33
|
+
#
|
34
|
+
# = Examples
|
35
|
+
# github = Github.new
|
36
|
+
# github.users.followers.following 'user-name'
|
37
|
+
# github.users.followers.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.followers.following
|
45
|
+
#
|
46
|
+
def following(user_name=nil, params={})
|
47
|
+
_normalize_params_keys(params)
|
48
|
+
response = if user_name
|
49
|
+
get_request("/users/#{user_name}/following", params)
|
50
|
+
else
|
51
|
+
get_request("/user/following", params)
|
55
52
|
end
|
53
|
+
return response unless block_given?
|
54
|
+
response.each { |el| yield el }
|
55
|
+
end
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
57
|
+
# Check if you are following a user
|
58
|
+
#
|
59
|
+
# = Examples
|
60
|
+
# github = Github.new :oauth_token => '...'
|
61
|
+
# github.users.followers.following? 'user-name'
|
62
|
+
#
|
63
|
+
def following?(user_name, params={})
|
64
|
+
_validate_presence_of user_name
|
65
|
+
_normalize_params_keys(params)
|
66
|
+
get_request("/user/following/#{user_name}", params)
|
67
|
+
true
|
68
|
+
rescue Github::Error::NotFound
|
69
|
+
false
|
70
|
+
end
|
71
71
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
72
|
+
# Follow a user
|
73
|
+
#
|
74
|
+
# = Examples
|
75
|
+
# github = Github.new :oauth_token => '...'
|
76
|
+
# github.users.followers.follow 'user-name'
|
77
|
+
#
|
78
|
+
def follow(user_name, params={})
|
79
|
+
_validate_presence_of user_name
|
80
|
+
_normalize_params_keys(params)
|
81
|
+
put_request("/user/following/#{user_name}", params)
|
82
|
+
end
|
83
83
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
84
|
+
# Unfollow a user
|
85
|
+
#
|
86
|
+
# = Examples
|
87
|
+
# github = Github.new :oauth_token => '...'
|
88
|
+
# github.users.followers.unfollow 'user-name'
|
89
|
+
#
|
90
|
+
def unfollow(user_name, params={})
|
91
|
+
_validate_presence_of user_name
|
92
|
+
_normalize_params_keys(params)
|
93
|
+
delete_request("/user/following/#{user_name}", params)
|
94
|
+
end
|
95
95
|
|
96
|
-
|
97
|
-
end # Users
|
96
|
+
end # Users::Followers
|
98
97
|
end # Github
|
@@ -1,86 +1,84 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
module Github
|
4
|
-
class Users
|
5
|
-
module Keys
|
4
|
+
class Users::Keys < API
|
6
5
|
|
7
|
-
|
6
|
+
VALID_KEY_PARAM_NAMES = %w[ title key ].freeze
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
8
|
+
# List public keys for the authenticated user
|
9
|
+
#
|
10
|
+
# = Examples
|
11
|
+
# github = Github.new :oauth_token => '...'
|
12
|
+
# github.users.followers.list
|
13
|
+
# github.users.followers.list { |key| ... }
|
14
|
+
#
|
15
|
+
def list(params={})
|
16
|
+
_normalize_params_keys(params)
|
17
|
+
response = get_request("/user/keys", params)
|
18
|
+
return response unless block_given?
|
19
|
+
response.each { |el| yield el }
|
20
|
+
end
|
21
|
+
alias :all :list
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
23
|
+
# Get a single pulic key for the authenticated user
|
24
|
+
#
|
25
|
+
# = Examples
|
26
|
+
# github = Github.new :oauth_token => '...'
|
27
|
+
# github.users.followers.get 'key-id'
|
28
|
+
#
|
29
|
+
def get(key_id, params={})
|
30
|
+
_validate_presence_of key_id
|
31
|
+
_normalize_params_keys(params)
|
32
|
+
get_request("/user/keys/#{key_id}", params)
|
33
|
+
end
|
34
|
+
alias :find :get
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
36
|
+
# Create a public key for the authenticated user
|
37
|
+
#
|
38
|
+
# = Inputs
|
39
|
+
# * <tt>:title</tt> - Required string
|
40
|
+
# * <tt>:key</tt> - Required string. sha key
|
41
|
+
#
|
42
|
+
# = Examples
|
43
|
+
# github = Github.new :oauth_token => '...'
|
44
|
+
# github.users.followers.create "title" => "octocat@octomac",
|
45
|
+
# "key" => "ssh-rsa AAA..."
|
46
|
+
#
|
47
|
+
def create(params={})
|
48
|
+
_normalize_params_keys(params)
|
49
|
+
_filter_params_keys(VALID_KEY_PARAM_NAMES, params)
|
50
|
+
post_request("/user/keys", params)
|
51
|
+
end
|
53
52
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
53
|
+
# Update a public key for the authenticated user
|
54
|
+
#
|
55
|
+
# = Inputs
|
56
|
+
# * <tt>:title</tt> - Required string
|
57
|
+
# * <tt>:key</tt> - Required string. sha key
|
58
|
+
#
|
59
|
+
# = Examples
|
60
|
+
# github = Github.new :oauth_token => '...'
|
61
|
+
# github.users.followers.update 'key-id', "title" => "octocat@octomac",
|
62
|
+
# "key" => "ssh-rsa AAA..."
|
63
|
+
#
|
64
|
+
def update(key_id, params={})
|
65
|
+
_validate_presence_of key_id
|
66
|
+
_normalize_params_keys(params)
|
67
|
+
_filter_params_keys(VALID_KEY_PARAM_NAMES, params)
|
68
|
+
patch_request("/user/keys/#{key_id}", params)
|
69
|
+
end
|
71
70
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
71
|
+
# Delete a public key for the authenticated user
|
72
|
+
#
|
73
|
+
# = Examples
|
74
|
+
# github = Github.new :oauth_token => '...'
|
75
|
+
# github.users.followers.delete 'key-id'
|
76
|
+
#
|
77
|
+
def delete(key_id, params={})
|
78
|
+
_validate_presence_of key_id
|
79
|
+
_normalize_params_keys(params)
|
80
|
+
delete_request("/user/keys/#{key_id}", params)
|
81
|
+
end
|
83
82
|
|
84
|
-
|
85
|
-
end # Users
|
83
|
+
end # Users::Keys
|
86
84
|
end # Github
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Github
|
4
|
+
module Validations
|
5
|
+
extend AutoloadHelper
|
6
|
+
|
7
|
+
autoload_all 'github_api/validations',
|
8
|
+
:Presence => 'presence',
|
9
|
+
:Token => 'token',
|
10
|
+
:Format => 'format',
|
11
|
+
:Required => 'required'
|
12
|
+
|
13
|
+
include Presence
|
14
|
+
include Format
|
15
|
+
include Token
|
16
|
+
include Required
|
17
|
+
|
18
|
+
VALID_API_KEYS = [
|
19
|
+
'page',
|
20
|
+
'per_page',
|
21
|
+
'jsonp_callback'
|
22
|
+
]
|
23
|
+
|
24
|
+
end # Validation
|
25
|
+
end # Github
|