github_api 0.9.0 → 0.9.1
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.
- data/README.md +50 -5
- data/features/cassettes/git_data/commits/get.yml +69 -0
- data/features/git_data/commmits.feature +14 -0
- data/lib/github_api.rb +1 -0
- data/lib/github_api/activity/events.rb +42 -33
- data/lib/github_api/activity/notifications.rb +22 -22
- data/lib/github_api/activity/starring.rb +16 -21
- data/lib/github_api/activity/watching.rb +16 -19
- data/lib/github_api/api.rb +51 -8
- data/lib/github_api/arguments.rb +155 -0
- data/lib/github_api/authorizations.rb +19 -20
- data/lib/github_api/configuration.rb +5 -0
- data/lib/github_api/emojis.rb +3 -3
- data/lib/github_api/error/validations.rb +2 -2
- data/lib/github_api/gists.rb +32 -42
- data/lib/github_api/gists/comments.rb +21 -23
- data/lib/github_api/git_data/blobs.rb +13 -16
- data/lib/github_api/git_data/commits.rb +12 -10
- data/lib/github_api/git_data/references.rb +24 -28
- data/lib/github_api/git_data/tags.rb +9 -11
- data/lib/github_api/git_data/trees.rb +10 -13
- data/lib/github_api/gitignore.rb +4 -6
- data/lib/github_api/issues.rb +24 -32
- data/lib/github_api/issues/assignees.rb +11 -8
- data/lib/github_api/issues/comments.rb +21 -26
- data/lib/github_api/issues/events.rb +7 -9
- data/lib/github_api/issues/labels.rb +39 -53
- data/lib/github_api/issues/milestones.rb +26 -33
- data/lib/github_api/markdown.rb +5 -6
- data/lib/github_api/meta.rb +3 -3
- data/lib/github_api/orgs.rb +10 -11
- data/lib/github_api/orgs/members.rb +18 -20
- data/lib/github_api/orgs/teams.rb +54 -58
- data/lib/github_api/pull_requests.rb +40 -54
- data/lib/github_api/pull_requests/comments.rb +19 -26
- data/lib/github_api/repos.rb +146 -101
- data/lib/github_api/repos/collaborators.rb +29 -30
- data/lib/github_api/repos/comments.rb +20 -25
- data/lib/github_api/repos/commits.rb +12 -14
- data/lib/github_api/repos/contents.rb +22 -14
- data/lib/github_api/repos/downloads.rb +19 -23
- data/lib/github_api/repos/forks.rb +6 -11
- data/lib/github_api/repos/hooks.rb +25 -34
- data/lib/github_api/repos/keys.rb +25 -27
- data/lib/github_api/repos/merging.rb +7 -6
- data/lib/github_api/repos/pub_sub_hubbub.rb +14 -18
- data/lib/github_api/repos/statuses.rb +13 -14
- data/lib/github_api/say.rb +1 -3
- data/lib/github_api/search.rb +12 -21
- data/lib/github_api/users.rb +10 -9
- data/lib/github_api/users/emails.rb +11 -9
- data/lib/github_api/users/followers.rb +25 -23
- data/lib/github_api/users/keys.rb +27 -29
- data/lib/github_api/version.rb +1 -1
- data/spec/github/activity/events/org_spec.rb +6 -6
- data/spec/github/activity/events/performed_spec.rb +1 -1
- data/spec/github/activity/events/received_spec.rb +1 -1
- data/spec/github/activity/events/user_org_spec.rb +4 -2
- data/spec/github/activity/notifications/create_spec.rb +1 -1
- data/spec/github/activity/notifications/delete_spec.rb +1 -1
- data/spec/github/activity/notifications/get_spec.rb +1 -1
- data/spec/github/activity/notifications/subscribed_spec.rb +1 -1
- data/spec/github/activity/starring/list_spec.rb +2 -0
- data/spec/github/activity/starring/starring_spec.rb +1 -1
- data/spec/github/activity/watching/list_spec.rb +2 -0
- data/spec/github/activity/watching/watching_spec.rb +1 -3
- data/spec/github/api/set_spec.rb +18 -4
- data/spec/github/api/with_spec.rb +28 -0
- data/spec/github/api_spec.rb +11 -33
- data/spec/github/arguments/parse_spec.rb +68 -0
- data/spec/github/authorizations/delete_spec.rb +1 -1
- data/spec/github/authorizations/get_spec.rb +1 -1
- data/spec/github/error/validations_spec.rb +3 -3
- data/spec/github/gists/comments/list_spec.rb +1 -1
- data/spec/github/gists/delete_spec.rb +1 -1
- data/spec/github/gists/fork_spec.rb +1 -1
- data/spec/github/gists/get_spec.rb +1 -1
- data/spec/github/gists/is_starred_spec.rb +2 -0
- data/spec/github/gists/star_spec.rb +1 -1
- data/spec/github/gists/unstar_spec.rb +1 -1
- data/spec/github/git_data/blobs/create_spec.rb +2 -0
- data/spec/github/git_data/blobs/get_spec.rb +1 -1
- data/spec/github/git_data/commits/create_spec.rb +2 -0
- data/spec/github/git_data/commits/get_spec.rb +3 -3
- data/spec/github/git_data/references/create_spec.rb +1 -1
- data/spec/github/git_data/references/delete_spec.rb +3 -1
- data/spec/github/git_data/tags/create_spec.rb +2 -0
- data/spec/github/gitignore/get_spec.rb +1 -1
- data/spec/github/issues/events/get_spec.rb +3 -1
- data/spec/github/issues/events/list_spec.rb +3 -1
- data/spec/github/issues/labels/add_spec.rb +6 -6
- data/spec/github/issues/labels/list_spec.rb +3 -1
- data/spec/github/issues/labels/replace_spec.rb +6 -7
- data/spec/github/issues/milestones/get_spec.rb +2 -0
- data/spec/github/normalizer_spec.rb +18 -6
- data/spec/github/orgs/members/conceal_spec.rb +6 -4
- data/spec/github/orgs/members/delete_spec.rb +2 -0
- data/spec/github/orgs/members/list_spec.rb +1 -1
- data/spec/github/orgs/members/member_spec.rb +3 -1
- data/spec/github/orgs/members/publicize_spec.rb +2 -0
- data/spec/github/orgs/teams/add_member_spec.rb +2 -0
- data/spec/github/orgs/teams/create_spec.rb +1 -1
- data/spec/github/orgs/teams/delete_spec.rb +1 -1
- data/spec/github/orgs/teams/edit_spec.rb +1 -1
- data/spec/github/orgs/teams/get_spec.rb +1 -1
- data/spec/github/orgs/teams/list_spec.rb +1 -1
- data/spec/github/orgs/teams/team_member_spec.rb +3 -1
- data/spec/github/parameter_filter_spec.rb +19 -58
- data/spec/github/pull_requests/comments/create_spec.rb +3 -1
- data/spec/github/pull_requests/comments/delete_spec.rb +1 -1
- data/spec/github/pull_requests/comments/edit_spec.rb +2 -0
- data/spec/github/pull_requests/comments/get_spec.rb +3 -1
- data/spec/github/pull_requests/comments/list_spec.rb +3 -1
- data/spec/github/pull_requests/commits_spec.rb +3 -3
- data/spec/github/pull_requests/create_spec.rb +4 -0
- data/spec/github/pull_requests/files_spec.rb +4 -0
- data/spec/github/pull_requests/get_spec.rb +3 -3
- data/spec/github/pull_requests/list_spec.rb +3 -3
- data/spec/github/pull_requests/merge_spec.rb +2 -0
- data/spec/github/pull_requests/merged_spec.rb +3 -1
- data/spec/github/pull_requests/update_spec.rb +4 -0
- data/spec/github/repos/collaborators/add_spec.rb +3 -1
- data/spec/github/repos/collaborators/get_spec.rb +1 -3
- data/spec/github/repos/collaborators/list_spec.rb +5 -1
- data/spec/github/repos/collaborators/remove_spec.rb +3 -1
- data/spec/github/repos/comments/create_spec.rb +4 -0
- data/spec/github/repos/comments/delete_spec.rb +2 -2
- data/spec/github/repos/comments/get_spec.rb +6 -2
- data/spec/github/repos/commits/compare_spec.rb +3 -3
- data/spec/github/repos/commits/get_spec.rb +3 -3
- data/spec/github/repos/commits/list_spec.rb +3 -3
- data/spec/github/repos/contents/archive_spec.rb +12 -0
- data/spec/github/repos/contents/get_spec.rb +5 -0
- data/spec/github/repos/contributors_spec.rb +7 -2
- data/spec/github/repos/downloads/create_spec.rb +4 -0
- data/spec/github/repos/downloads/delete_spec.rb +5 -1
- data/spec/github/repos/downloads/get_spec.rb +3 -1
- data/spec/github/repos/downloads/list_spec.rb +3 -1
- data/spec/github/repos/forks/create_spec.rb +2 -0
- data/spec/github/repos/forks/list_spec.rb +3 -1
- data/spec/github/repos/hooks/edit_spec.rb +1 -1
- data/spec/github/repos/keys/delete_spec.rb +1 -1
- data/spec/github/repos/keys/edit_spec.rb +2 -0
- data/spec/github/repos/keys/get_spec.rb +3 -1
- data/spec/github/repos/keys/list_spec.rb +4 -2
- data/spec/github/repos/list_spec.rb +6 -1
- data/spec/github/repos/pub_sub_hubbub/subscribe_service_spec.rb +27 -0
- data/spec/github/repos/pub_sub_hubbub/subscribe_spec.rb +51 -0
- data/spec/github/repos/pub_sub_hubbub/unsubscribe_service_spec.rb +21 -0
- data/spec/github/repos/pub_sub_hubbub/unsubscribe_spec.rb +58 -0
- data/spec/github/repos/statuses/create_spec.rb +2 -0
- data/spec/github/search_spec.rb +25 -10
- data/spec/github/users/followers/follow_spec.rb +1 -1
- data/spec/github/users/followers/is_following_spec.rb +1 -1
- data/spec/github/users/followers/unfollow_spec.rb +1 -1
- data/spec/github/users/keys/delete_spec.rb +1 -1
- data/spec/github/users/keys/get_spec.rb +1 -1
- data/spec/github/users/keys/update_spec.rb +1 -1
- data/spec/github/users/update_spec.rb +1 -1
- data/spec/integration/arguments_spec.rb +76 -0
- data/spec/{github → integration}/authorizations_spec.rb +0 -0
- metadata +44 -35
- data/spec/github/repos/pub_sub_hubbub_spec.rb +0 -78
|
@@ -12,10 +12,12 @@ module Github
|
|
|
12
12
|
# github.repos.keys.list 'user-name', 'repo-name'
|
|
13
13
|
# github.repos.keys.list 'user-name', 'repo-name' { |key| ... }
|
|
14
14
|
#
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
# keys = Github::Repos::Keys.new user: 'user-name', repo: 'repo-name'
|
|
16
|
+
# keys.list
|
|
17
|
+
#
|
|
18
|
+
def list(*args)
|
|
19
|
+
arguments(args, :required => [:user, :repo])
|
|
20
|
+
params = arguments.params
|
|
19
21
|
|
|
20
22
|
response = get_request("/repos/#{user}/#{repo}/keys", params)
|
|
21
23
|
return response unless block_given?
|
|
@@ -29,10 +31,9 @@ module Github
|
|
|
29
31
|
# github = Github.new
|
|
30
32
|
# github.repos.keys.get 'user-name', 'repo-name', 'key-id'
|
|
31
33
|
#
|
|
32
|
-
def get(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
normalize! params
|
|
34
|
+
def get(*args)
|
|
35
|
+
arguments(args, :required => [:user, :repo, :key_id])
|
|
36
|
+
params = arguments.params
|
|
36
37
|
|
|
37
38
|
get_request("/repos/#{user}/#{repo}/keys/#{key_id}", params)
|
|
38
39
|
end
|
|
@@ -50,14 +51,13 @@ module Github
|
|
|
50
51
|
# "title" => "octocat@octomac",
|
|
51
52
|
# "key" => "ssh-rsa AAA..."
|
|
52
53
|
#
|
|
53
|
-
def create(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
assert_required_keys(VALID_KEY_OPTIONS, params)
|
|
54
|
+
def create(*args)
|
|
55
|
+
arguments(args, :required => [:user, :repo]) do
|
|
56
|
+
sift VALID_KEY_OPTIONS
|
|
57
|
+
assert_required VALID_KEY_OPTIONS
|
|
58
|
+
end
|
|
59
59
|
|
|
60
|
-
post_request("/repos/#{user}/#{repo}/keys", params)
|
|
60
|
+
post_request("/repos/#{user}/#{repo}/keys", arguments.params)
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
# Edit a key
|
|
@@ -72,12 +72,11 @@ module Github
|
|
|
72
72
|
# "title" => "octocat@octomac",
|
|
73
73
|
# "key" => "ssh-rsa AAA..."
|
|
74
74
|
#
|
|
75
|
-
def edit(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
filter! VALID_KEY_OPTIONS, params
|
|
75
|
+
def edit(*args)
|
|
76
|
+
arguments(args, :required => [:user, :repo, :key_id]) do
|
|
77
|
+
sift VALID_KEY_OPTIONS
|
|
78
|
+
end
|
|
79
|
+
params = arguments.params
|
|
81
80
|
|
|
82
81
|
patch_request("/repos/#{user}/#{repo}/keys/#{key_id}", params)
|
|
83
82
|
end
|
|
@@ -85,13 +84,12 @@ module Github
|
|
|
85
84
|
# Delete key
|
|
86
85
|
#
|
|
87
86
|
# = Examples
|
|
88
|
-
#
|
|
89
|
-
#
|
|
87
|
+
# github = Github.new
|
|
88
|
+
# github.repos.keys.delete 'user-name', 'repo-name', 'key-id'
|
|
90
89
|
#
|
|
91
|
-
def delete(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
normalize! params
|
|
90
|
+
def delete(*args)
|
|
91
|
+
arguments(args, :required => [:user, :repo, :key_id])
|
|
92
|
+
params = arguments.params
|
|
95
93
|
|
|
96
94
|
delete_request("/repos/#{user}/#{repo}/keys/#{key_id}", params)
|
|
97
95
|
end
|
|
@@ -28,13 +28,14 @@ module Github
|
|
|
28
28
|
# "head": "cool_feature",
|
|
29
29
|
# "commit_message": "Shipped cool_feature!"
|
|
30
30
|
#
|
|
31
|
-
def merge(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
def merge(*args)
|
|
32
|
+
arguments(args, :required => [:user, :repo]) do
|
|
33
|
+
sift VALID_MERGE_PARAM_NAMES
|
|
34
|
+
assert_required REQUIRED_MERGE_PARAMS
|
|
35
|
+
end
|
|
36
|
+
params = arguments.params
|
|
36
37
|
|
|
37
|
-
post_request("/repos/#{
|
|
38
|
+
post_request("/repos/#{user}/#{repo}/merges", params)
|
|
38
39
|
end
|
|
39
40
|
|
|
40
41
|
end # Repos::Merging
|
|
@@ -22,9 +22,8 @@ module Github
|
|
|
22
22
|
# :verify => 'sync',
|
|
23
23
|
# :secret => '...'
|
|
24
24
|
#
|
|
25
|
-
def subscribe(
|
|
26
|
-
|
|
27
|
-
normalize! params
|
|
25
|
+
def subscribe(*args)
|
|
26
|
+
params = arguments(args, :required => [:topic, :callback]).params
|
|
28
27
|
_merge_action!("subscribe", topic, callback, params)
|
|
29
28
|
|
|
30
29
|
post_request("/hub", params, OPTIONS)
|
|
@@ -44,9 +43,8 @@ module Github
|
|
|
44
43
|
# :verify => 'sync',
|
|
45
44
|
# :secret => '...'
|
|
46
45
|
#
|
|
47
|
-
def unsubscribe(
|
|
48
|
-
|
|
49
|
-
normalize! params
|
|
46
|
+
def unsubscribe(*args)
|
|
47
|
+
params = arguments(args, :required => [:topic, :callback]).params
|
|
50
48
|
_merge_action!("unsubscribe", topic, callback, params)
|
|
51
49
|
|
|
52
50
|
post_request("/hub", params, OPTIONS)
|
|
@@ -67,12 +65,11 @@ module Github
|
|
|
67
65
|
# :token => 'abc123',
|
|
68
66
|
# :event => 'watch'
|
|
69
67
|
#
|
|
70
|
-
def subscribe_service(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
callback = "github://#{service_name}?#{params.serialize}"
|
|
68
|
+
def subscribe_service(*args)
|
|
69
|
+
params = arguments(args, :required => [:user, :repo, :service]).params
|
|
70
|
+
event = params.delete('event') || 'push'
|
|
71
|
+
topic = "#{site}/#{user}/#{repo}/events/#{event}"
|
|
72
|
+
callback = "github://#{service}?#{params.serialize}"
|
|
76
73
|
|
|
77
74
|
subscribe(topic, callback)
|
|
78
75
|
end
|
|
@@ -90,12 +87,11 @@ module Github
|
|
|
90
87
|
# github = Github.new :oauth_token => '...'
|
|
91
88
|
# github.repos.pubsubhubbub.unsubscribe_service 'user-name', 'repo-name', 'campfire'
|
|
92
89
|
#
|
|
93
|
-
def unsubscribe_service(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
callback = "github://#{service_name}"
|
|
90
|
+
def unsubscribe_service(*args)
|
|
91
|
+
params = arguments(args, :required => [:user, :repo, :service]).params
|
|
92
|
+
event = params.delete('event') || 'push'
|
|
93
|
+
topic = "#{site}/#{user}/#{repo}/events/#{event}"
|
|
94
|
+
callback = "github://#{service}"
|
|
99
95
|
|
|
100
96
|
unsubscribe(topic, callback)
|
|
101
97
|
end
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
3
|
module Github
|
|
4
|
+
|
|
5
|
+
# The Status API allows external services to mark commits with a success,
|
|
6
|
+
# failure, error, or pending state, which is then reflected in pull requests
|
|
7
|
+
# involving those commits.
|
|
4
8
|
class Repos::Statuses < API
|
|
5
|
-
# The Status API allows external services to mark commits with a success,
|
|
6
|
-
# failure, error, or pending state, which is then reflected in pull requests
|
|
7
|
-
# involving those commits.
|
|
8
9
|
|
|
9
10
|
VALID_STATUS_PARAM_NAMES = %w[
|
|
10
11
|
state
|
|
@@ -21,10 +22,9 @@ module Github
|
|
|
21
22
|
# github.repos.statuses.list 'user-name', 'repo-name', 'sha'
|
|
22
23
|
# github.repos.statuses.list 'user-name', 'repo-name', 'sha' { |status| ... }
|
|
23
24
|
#
|
|
24
|
-
def list(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
normalize! params
|
|
25
|
+
def list(*args)
|
|
26
|
+
arguments(args, :required => [:user, :repo, :sha])
|
|
27
|
+
params = arguments.params
|
|
28
28
|
|
|
29
29
|
response = get_request("/repos/#{user}/#{repo}/statuses/#{sha}", params)
|
|
30
30
|
return response unless block_given?
|
|
@@ -49,13 +49,12 @@ module Github
|
|
|
49
49
|
# "target_url" => "http://ci.example.com/johndoe/my-repo/builds/sha",
|
|
50
50
|
# "description" => "Successful build #3 from origin/master"
|
|
51
51
|
#
|
|
52
|
-
def create(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
assert_required_keys(REQUIRED_PARAMS, params)
|
|
52
|
+
def create(*args)
|
|
53
|
+
arguments(args, :required => [:user, :repo, :sha]) do
|
|
54
|
+
sift VALID_STATUS_PARAM_NAMES, :recursive => false
|
|
55
|
+
assert_required REQUIRED_PARAMS
|
|
56
|
+
end
|
|
57
|
+
params = arguments.params
|
|
59
58
|
|
|
60
59
|
post_request("/repos/#{user}/#{repo}/statuses/#{sha}", params)
|
|
61
60
|
end
|
data/lib/github_api/say.rb
CHANGED
|
@@ -12,9 +12,7 @@ module Github
|
|
|
12
12
|
# github.octocat.say "My custom string..."
|
|
13
13
|
#
|
|
14
14
|
def say(*args)
|
|
15
|
-
params = args.
|
|
16
|
-
normalize! params
|
|
17
|
-
|
|
15
|
+
params = arguments(*args).params
|
|
18
16
|
params[:s] = args.shift unless args.empty?
|
|
19
17
|
|
|
20
18
|
get_request('/octocat', params, :raw => true)
|
data/lib/github_api/search.rb
CHANGED
|
@@ -14,21 +14,14 @@ module Github
|
|
|
14
14
|
#
|
|
15
15
|
# = Examples
|
|
16
16
|
# github = Github.new
|
|
17
|
+
# github.search.issues 'owner', 'repo-name', 'open','api'
|
|
17
18
|
# github.search.issues owner: 'owner', repo: 'repo-name', state: 'open', keyword: 'api'
|
|
18
19
|
#
|
|
19
20
|
def issues(*args)
|
|
20
|
-
params = args.extract_options!
|
|
21
|
-
normalize! params
|
|
22
|
-
|
|
23
21
|
required = ['owner', 'repo', 'state', 'keyword']
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
options = required.inject({}) do |hash, key|
|
|
27
|
-
hash[key] = params.delete(key)
|
|
28
|
-
hash
|
|
29
|
-
end
|
|
22
|
+
arguments(args, :required => required)
|
|
30
23
|
|
|
31
|
-
get_request("/legacy/issues/search/#{
|
|
24
|
+
get_request("/legacy/issues/search/#{owner}/#{repo}/#{state}/#{escape(keyword)}", arguments.params)
|
|
32
25
|
end
|
|
33
26
|
|
|
34
27
|
# Search repositories
|
|
@@ -40,14 +33,13 @@ module Github
|
|
|
40
33
|
#
|
|
41
34
|
# = Examples
|
|
42
35
|
# github = Github.new
|
|
36
|
+
# github.search.repos 'api'
|
|
43
37
|
# github.search.repos keyword: 'api'
|
|
44
38
|
#
|
|
45
39
|
def repos(*args)
|
|
46
|
-
|
|
47
|
-
normalize! params
|
|
48
|
-
assert_required_keys %w[ keyword ], params
|
|
40
|
+
arguments(args, :required => [:keyword])
|
|
49
41
|
|
|
50
|
-
get_request("/legacy/repos/search/#{escape(
|
|
42
|
+
get_request("/legacy/repos/search/#{escape(keyword)}", arguments.params)
|
|
51
43
|
end
|
|
52
44
|
alias :repositories :repos
|
|
53
45
|
|
|
@@ -63,11 +55,9 @@ module Github
|
|
|
63
55
|
# github.search.users keyword: 'wycats'
|
|
64
56
|
#
|
|
65
57
|
def users(*args)
|
|
66
|
-
|
|
67
|
-
normalize! params
|
|
68
|
-
assert_required_keys %w[ keyword ], params
|
|
58
|
+
arguments(args, :required => [:keyword])
|
|
69
59
|
|
|
70
|
-
get_request("/legacy/user/search/#{escape(
|
|
60
|
+
get_request("/legacy/user/search/#{escape(keyword)}", arguments.params)
|
|
71
61
|
end
|
|
72
62
|
|
|
73
63
|
# Search email
|
|
@@ -83,9 +73,10 @@ module Github
|
|
|
83
73
|
# github.search.email email: 'wycats'
|
|
84
74
|
#
|
|
85
75
|
def email(*args)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
76
|
+
arguments(args) do
|
|
77
|
+
assert_required %w[ email ]
|
|
78
|
+
end
|
|
79
|
+
params = arguments.params
|
|
89
80
|
|
|
90
81
|
get_request("/legacy/user/email/#{params.delete('email')}", params)
|
|
91
82
|
end
|
data/lib/github_api/users.rb
CHANGED
|
@@ -47,10 +47,10 @@ module Github
|
|
|
47
47
|
# users = Github::Users.new
|
|
48
48
|
# users.list
|
|
49
49
|
#
|
|
50
|
-
def list(
|
|
51
|
-
|
|
50
|
+
def list(*args)
|
|
51
|
+
arguments(args)
|
|
52
52
|
|
|
53
|
-
response = get_request("/users", params)
|
|
53
|
+
response = get_request("/users", arguments.params)
|
|
54
54
|
return response unless block_given?
|
|
55
55
|
response.each { |el| yield el }
|
|
56
56
|
end
|
|
@@ -69,8 +69,8 @@ module Github
|
|
|
69
69
|
# github.users.get
|
|
70
70
|
#
|
|
71
71
|
def get(*args)
|
|
72
|
-
params = args.
|
|
73
|
-
|
|
72
|
+
params = arguments(args).params
|
|
73
|
+
|
|
74
74
|
if user_name = params.delete('user')
|
|
75
75
|
get_request("/users/#{user_name}", params)
|
|
76
76
|
else
|
|
@@ -102,10 +102,11 @@ module Github
|
|
|
102
102
|
# "bio" => "There once..."
|
|
103
103
|
#
|
|
104
104
|
def update(*args)
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
arguments(args) do
|
|
106
|
+
sift VALID_USER_PARAMS_NAMES
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
patch_request("/user", arguments.params)
|
|
109
110
|
end
|
|
110
111
|
|
|
111
112
|
end # Users
|
|
@@ -11,9 +11,9 @@ module Github
|
|
|
11
11
|
# github.users.emails.list
|
|
12
12
|
# github.users.emails.list { |email| ... }
|
|
13
13
|
#
|
|
14
|
-
def list(
|
|
15
|
-
|
|
16
|
-
response = get_request("/user/emails", params)
|
|
14
|
+
def list(*args)
|
|
15
|
+
arguments(args)
|
|
16
|
+
response = get_request("/user/emails", arguments.params)
|
|
17
17
|
return response unless block_given?
|
|
18
18
|
response.each { |el| yield el }
|
|
19
19
|
end
|
|
@@ -29,9 +29,10 @@ module Github
|
|
|
29
29
|
# github.users.emails.add "octocat@github.com", "support@github.com"
|
|
30
30
|
#
|
|
31
31
|
def add(*args)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
params['data'] =
|
|
32
|
+
arguments(args)
|
|
33
|
+
params = arguments.params
|
|
34
|
+
params['data'] = arguments.remaining unless arguments.remaining.empty?
|
|
35
|
+
|
|
35
36
|
post_request("/user/emails", params)
|
|
36
37
|
end
|
|
37
38
|
alias :<< :add
|
|
@@ -46,9 +47,10 @@ module Github
|
|
|
46
47
|
# github.users.emails.delete "octocat@github.com", "support@github.com"
|
|
47
48
|
#
|
|
48
49
|
def delete(*args)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
params['data'] =
|
|
50
|
+
arguments(args)
|
|
51
|
+
params = arguments.params
|
|
52
|
+
params['data'] = arguments.remaining unless arguments.remaining.empty?
|
|
53
|
+
|
|
52
54
|
delete_request("/user/emails", params)
|
|
53
55
|
end
|
|
54
56
|
|
|
@@ -13,13 +13,14 @@ module Github
|
|
|
13
13
|
# List the authenticated user's followers
|
|
14
14
|
#
|
|
15
15
|
# = Examples
|
|
16
|
-
# github = Github.new :
|
|
16
|
+
# github = Github.new oauth_token: '...'
|
|
17
17
|
# github.users.followers
|
|
18
18
|
# github.users.followers { |user| ... }
|
|
19
19
|
#
|
|
20
|
-
def list(
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
def list(*args)
|
|
21
|
+
params = arguments(args).params
|
|
22
|
+
|
|
23
|
+
response = if user_name = arguments.remaining.first
|
|
23
24
|
get_request("/users/#{user_name}/followers", params)
|
|
24
25
|
else
|
|
25
26
|
get_request("/user/followers", params)
|
|
@@ -40,12 +41,13 @@ module Github
|
|
|
40
41
|
#
|
|
41
42
|
# = Examples
|
|
42
43
|
#
|
|
43
|
-
# github = Github.new :
|
|
44
|
+
# github = Github.new oauth_token: '...'
|
|
44
45
|
# github.users.followers.following
|
|
45
46
|
#
|
|
46
|
-
def following(
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
def following(*args)
|
|
48
|
+
params = arguments(args).params
|
|
49
|
+
|
|
50
|
+
response = if user_name = arguments.remaining.first
|
|
49
51
|
get_request("/users/#{user_name}/following", params)
|
|
50
52
|
else
|
|
51
53
|
get_request("/user/following", params)
|
|
@@ -57,13 +59,13 @@ module Github
|
|
|
57
59
|
# Check if you are following a user
|
|
58
60
|
#
|
|
59
61
|
# = Examples
|
|
60
|
-
# github = Github.new :
|
|
62
|
+
# github = Github.new oauth_token: '...'
|
|
61
63
|
# github.users.followers.following? 'user-name'
|
|
64
|
+
# github.users.followers.following? user: 'user-name'
|
|
62
65
|
#
|
|
63
|
-
def following?(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
get_request("/user/following/#{user_name}", params)
|
|
66
|
+
def following?(*args)
|
|
67
|
+
arguments(args, :required => [:user])
|
|
68
|
+
get_request("/user/following/#{user}", arguments.params)
|
|
67
69
|
true
|
|
68
70
|
rescue Github::Error::NotFound
|
|
69
71
|
false
|
|
@@ -72,25 +74,25 @@ module Github
|
|
|
72
74
|
# Follow a user
|
|
73
75
|
#
|
|
74
76
|
# = Examples
|
|
75
|
-
# github = Github.new :
|
|
77
|
+
# github = Github.new oauth_token: '...'
|
|
76
78
|
# github.users.followers.follow 'user-name'
|
|
79
|
+
# github.users.followers.follow user: 'user-name'
|
|
77
80
|
#
|
|
78
|
-
def follow(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
put_request("/user/following/#{user_name}", params)
|
|
81
|
+
def follow(*args)
|
|
82
|
+
arguments(args, :required => [:user])
|
|
83
|
+
put_request("/user/following/#{user}", arguments.params)
|
|
82
84
|
end
|
|
83
85
|
|
|
84
86
|
# Unfollow a user
|
|
85
87
|
#
|
|
86
88
|
# = Examples
|
|
87
|
-
# github = Github.new :
|
|
89
|
+
# github = Github.new oauth_token: '...'
|
|
88
90
|
# github.users.followers.unfollow 'user-name'
|
|
91
|
+
# github.users.followers.unfollow user: 'user-name'
|
|
89
92
|
#
|
|
90
|
-
def unfollow(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
delete_request("/user/following/#{user_name}", params)
|
|
93
|
+
def unfollow(*args)
|
|
94
|
+
arguments(args, :required => [:user])
|
|
95
|
+
delete_request("/user/following/#{user}", arguments.params)
|
|
94
96
|
end
|
|
95
97
|
|
|
96
98
|
end # Users::Followers
|