github_api 0.4.11 → 0.5.0.rc1
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 +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,102 +1,114 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
3
|
module Github
|
|
4
|
-
class Repos
|
|
5
|
-
module PubSubHubbub
|
|
4
|
+
class Repos::PubSubHubbub < API
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
6
|
+
# Subscribe to existing topic/event through pubsubhubbub
|
|
7
|
+
#
|
|
8
|
+
# = Parameters
|
|
9
|
+
# * topic - Required string - The URI of the GitHub repository to subscribe to. The path must be in the format of /:user/:repo/events/:event.
|
|
10
|
+
# * callback - Required string - The URI to receive the updates to the topic.
|
|
11
|
+
#
|
|
12
|
+
# = Examples
|
|
13
|
+
# github = Github.new :oauth_token => '...'
|
|
14
|
+
# github.repos.pubsubhubbub.subscribe
|
|
15
|
+
# 'https://github.com/:user/:repo/events/push',
|
|
16
|
+
# 'github://Email?address=peter-murach@gmail.com',
|
|
17
|
+
# :verify => 'sync',
|
|
18
|
+
# :secret => '...'
|
|
19
|
+
#
|
|
20
|
+
def subscribe(topic, callback, params={})
|
|
21
|
+
_validate_presence_of topic, callback
|
|
22
|
+
_normalize_params_keys(params)
|
|
23
|
+
_merge_action!("subscribe", topic, callback, params)
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
post_request("/hub", params)
|
|
26
|
+
end
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
# Unsubscribe from existing topic/event through pubsubhubbub
|
|
29
|
+
#
|
|
30
|
+
# = Parameters
|
|
31
|
+
# * topic - Required string - The URI of the GitHub repository to unsubscribe from. The path must be in the format of /:user/:repo/events/:event.
|
|
32
|
+
# * callback - Required string - The URI to unsubscribe the topic from.
|
|
33
|
+
#
|
|
34
|
+
# = Examples
|
|
35
|
+
# github = Github.new :oauth_token => '...'
|
|
36
|
+
# github.repos.pubsubhubbub.unsubscribe
|
|
37
|
+
# 'https://github.com/:user/:repo/events/push',
|
|
38
|
+
# 'github://Email?address=peter-murach@gmail.com',
|
|
39
|
+
# :verify => 'sync',
|
|
40
|
+
# :secret => '...'
|
|
41
|
+
#
|
|
42
|
+
def unsubscribe(topic, callback, params={})
|
|
43
|
+
_validate_presence_of topic, callback
|
|
44
|
+
_normalize_params_keys(params)
|
|
45
|
+
_merge_action!("unsubscribe", topic, callback, params)
|
|
35
46
|
|
|
36
|
-
|
|
37
|
-
|
|
47
|
+
post_request("/hub", params)
|
|
48
|
+
end
|
|
38
49
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
50
|
+
# Subscribe repository to service hook through pubsubhubbub
|
|
51
|
+
#
|
|
52
|
+
# = Parameters
|
|
53
|
+
# * repo-name - Required string,
|
|
54
|
+
# * service-name - Required string
|
|
55
|
+
# * <tt>:event</tt> - Required hash key for the type of event. The default event is <tt>push</tt>
|
|
56
|
+
#
|
|
57
|
+
# = Examples
|
|
58
|
+
# github = Github.new :oauth_token => '...'
|
|
59
|
+
# github.repos.pubsubhubbub.subscribe_service 'user-name', 'repo-name', 'campfire',
|
|
60
|
+
# :subdomain => 'github',
|
|
61
|
+
# :room => 'Commits',
|
|
62
|
+
# :token => 'abc123',
|
|
63
|
+
# :event => 'watch'
|
|
64
|
+
#
|
|
65
|
+
def subscribe_service(user_name, repo_name, service_name, params={})
|
|
66
|
+
_validate_presence_of user_name, repo_name, service_name
|
|
67
|
+
_normalize_params_keys(params)
|
|
68
|
+
event = params.delete('event') || 'push'
|
|
69
|
+
topic = "https://github.com/#{user_name}/#{repo_name}/events/#{event}"
|
|
70
|
+
callback = "github://#{service_name}?#{params.serialize}"
|
|
60
71
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
72
|
+
subscribe(topic, callback)
|
|
73
|
+
end
|
|
74
|
+
alias :subscribe_repository :subscribe_service
|
|
75
|
+
alias :subscribe_repo :subscribe_service
|
|
64
76
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
# Subscribe repository to service hook through pubsubhubbub
|
|
78
|
+
#
|
|
79
|
+
# = Parameters
|
|
80
|
+
# * repo-name - Required string,
|
|
81
|
+
# * service-name - Required string
|
|
82
|
+
# * <tt>:event</tt> - Optional hash key for the type of event. The default event is <tt>push</tt>
|
|
83
|
+
#
|
|
84
|
+
# = Examples
|
|
85
|
+
# github = Github.new :oauth_token => '...'
|
|
86
|
+
# github.repos.pubsubhubbub.unsubscribe_service 'user-name', 'repo-name', 'campfire'
|
|
87
|
+
#
|
|
88
|
+
def unsubscribe_service(user_name, repo_name, service_name, params={})
|
|
89
|
+
_validate_presence_of user_name, repo_name, service_name
|
|
90
|
+
_normalize_params_keys(params)
|
|
91
|
+
event = params.delete('event') || 'push'
|
|
92
|
+
topic = "https://github.com/#{user_name}/#{repo_name}/events/#{event}"
|
|
93
|
+
callback = "github://#{service_name}"
|
|
82
94
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
95
|
+
unsubscribe(topic, callback)
|
|
96
|
+
end
|
|
97
|
+
alias :unsubscribe_repository :unsubscribe_service
|
|
98
|
+
alias :unsubscribe_repo :unsubscribe_service
|
|
86
99
|
|
|
87
|
-
|
|
100
|
+
private
|
|
88
101
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
def _merge_action!(action, topic, callback, params) # :nodoc:
|
|
103
|
+
options = {
|
|
104
|
+
"hub.mode" => action.to_s,
|
|
105
|
+
"hub.topic" => topic.to_s,
|
|
106
|
+
"hub.callback" => callback,
|
|
107
|
+
"hub.verify" => params.delete('verify') || 'sync',
|
|
108
|
+
"hub.secret" => params.delete('secret') || ''
|
|
109
|
+
}
|
|
110
|
+
params.merge! options
|
|
111
|
+
end
|
|
99
112
|
|
|
100
|
-
|
|
101
|
-
end # Repos
|
|
113
|
+
end # Repos::PubSubHubbub
|
|
102
114
|
end # Github
|
|
@@ -1,95 +1,93 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
3
|
module Github
|
|
4
|
-
class Repos
|
|
5
|
-
module Watching
|
|
4
|
+
class Repos::Watching < API
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
# List repo watchers
|
|
7
|
+
#
|
|
8
|
+
# = Examples
|
|
9
|
+
# github = Github.new :user => 'user-name', :repo => 'repo-name'
|
|
10
|
+
# github.repos.watching.watchers
|
|
11
|
+
# github.repos.watching.watchers { |watcher| ... }
|
|
12
|
+
#
|
|
13
|
+
def watchers(user_name, repo_name, params={})
|
|
14
|
+
_update_user_repo_params(user_name, repo_name)
|
|
15
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
|
16
|
+
_normalize_params_keys(params)
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
response = get_request("/repos/#{user}/#{repo}/watchers", params)
|
|
19
|
+
return response unless block_given?
|
|
20
|
+
response.each { |el| yield el }
|
|
21
|
+
end
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
23
|
+
# List repos being watched by a user
|
|
24
|
+
#
|
|
25
|
+
# = Examples
|
|
26
|
+
# github = Github.new
|
|
27
|
+
# github.repos.watching.watched :user => 'user-name'
|
|
28
|
+
#
|
|
29
|
+
# List repos being watched by the authenticated user
|
|
30
|
+
#
|
|
31
|
+
# = Examples
|
|
32
|
+
# github = Github.new :oauth_token => '...'
|
|
33
|
+
# github.repos.watching.watched
|
|
34
|
+
#
|
|
35
|
+
def watched(*args)
|
|
36
|
+
params = args.last.is_a?(Hash) ? args.pop : {}
|
|
37
|
+
_normalize_params_keys(params)
|
|
38
|
+
_merge_user_into_params!(params) unless params.has_key?('user')
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
end
|
|
46
|
-
return response unless block_given?
|
|
47
|
-
response.each { |el| yield el }
|
|
40
|
+
response = if (user_name = params.delete('user'))
|
|
41
|
+
get_request("/users/#{user_name}/watched", params)
|
|
42
|
+
else
|
|
43
|
+
get_request("/user/watched", params)
|
|
48
44
|
end
|
|
45
|
+
return response unless block_given?
|
|
46
|
+
response.each { |el| yield el }
|
|
47
|
+
end
|
|
49
48
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
49
|
+
# Check if you are watching a repository
|
|
50
|
+
#
|
|
51
|
+
# Returns <tt>true</tt> if this repo is watched by you, <tt>false</tt> otherwise
|
|
52
|
+
# = Examples
|
|
53
|
+
# github = Github.new
|
|
54
|
+
# github.repos.watching.watching? 'user-name', 'repo-name'
|
|
55
|
+
#
|
|
56
|
+
def watching?(user_name, repo_name, params={})
|
|
57
|
+
_validate_presence_of user_name, repo_name
|
|
58
|
+
_normalize_params_keys(params)
|
|
59
|
+
get_request("/user/watched/#{user_name}/#{repo_name}", params)
|
|
60
|
+
true
|
|
61
|
+
rescue Github::Error::NotFound
|
|
62
|
+
false
|
|
63
|
+
end
|
|
65
64
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
# Watch a repository
|
|
66
|
+
#
|
|
67
|
+
# You need to be authenticated to watch a repository
|
|
68
|
+
#
|
|
69
|
+
# = Examples
|
|
70
|
+
# github = Github.new
|
|
71
|
+
# github.repos.watching.start_watching 'user-name', 'repo-name'
|
|
72
|
+
#
|
|
73
|
+
def start_watching(user_name, repo_name, params={})
|
|
74
|
+
_validate_presence_of user_name, repo_name
|
|
75
|
+
_normalize_params_keys(params)
|
|
76
|
+
put_request("/user/watched/#{user_name}/#{repo_name}", params)
|
|
77
|
+
end
|
|
79
78
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
79
|
+
# Stop watching a repository
|
|
80
|
+
#
|
|
81
|
+
# You need to be authenticated to stop watching a repository.
|
|
82
|
+
# = Examples
|
|
83
|
+
# github = Github.new
|
|
84
|
+
# github.repos.watching.start_watching 'user-name', 'repo-name'
|
|
85
|
+
#
|
|
86
|
+
def stop_watching(user_name, repo_name, params={})
|
|
87
|
+
_validate_presence_of user_name, repo_name
|
|
88
|
+
_normalize_params_keys(params)
|
|
89
|
+
delete_request("/user/watched/#{user_name}/#{repo_name}", params)
|
|
90
|
+
end
|
|
92
91
|
|
|
93
|
-
|
|
94
|
-
end # Repos
|
|
92
|
+
end # Repos::Watching
|
|
95
93
|
end # Github
|
data/lib/github_api/request.rb
CHANGED
|
@@ -11,27 +11,23 @@ module Github
|
|
|
11
11
|
METHODS = [:get, :post, :put, :delete, :patch]
|
|
12
12
|
METHODS_WITH_BODIES = [ :post, :put, :patch ]
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
/repos\/.*\/.*\/comments/,
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
def get(path, params={}, options={})
|
|
14
|
+
def get_request(path, params={}, options={})
|
|
19
15
|
request(:get, path, params, options)
|
|
20
16
|
end
|
|
21
17
|
|
|
22
|
-
def
|
|
18
|
+
def patch_request(path, params={}, options={})
|
|
23
19
|
request(:patch, path, params, options)
|
|
24
20
|
end
|
|
25
21
|
|
|
26
|
-
def
|
|
22
|
+
def post_request(path, params={}, options={})
|
|
27
23
|
request(:post, path, params, options)
|
|
28
24
|
end
|
|
29
25
|
|
|
30
|
-
def
|
|
26
|
+
def put_request(path, params={}, options={})
|
|
31
27
|
request(:put, path, params, options)
|
|
32
28
|
end
|
|
33
29
|
|
|
34
|
-
def
|
|
30
|
+
def delete_request(path, params={}, options={})
|
|
35
31
|
request(:delete, path, params, options)
|
|
36
32
|
end
|
|
37
33
|
|
data/lib/github_api/users.rb
CHANGED
|
@@ -10,10 +10,6 @@ module Github
|
|
|
10
10
|
:Followers => 'followers',
|
|
11
11
|
:Keys => 'keys'
|
|
12
12
|
|
|
13
|
-
include Github::Users::Emails
|
|
14
|
-
include Github::Users::Followers
|
|
15
|
-
include Github::Users::Keys
|
|
16
|
-
|
|
17
13
|
VALID_USER_PARAMS_NAMES = %w[
|
|
18
14
|
name
|
|
19
15
|
email
|
|
@@ -29,27 +25,42 @@ module Github
|
|
|
29
25
|
super(options)
|
|
30
26
|
end
|
|
31
27
|
|
|
28
|
+
# Access to Users::Emails API
|
|
29
|
+
def emails
|
|
30
|
+
@emails ||= ApiFactory.new 'Users::Emails'
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Access to Users::Followers API
|
|
34
|
+
def followers
|
|
35
|
+
@followers ||= ApiFactory.new 'Users::Followers'
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Access to Users::Keys API
|
|
39
|
+
def keys
|
|
40
|
+
@keys ||= ApiFactory.new 'Users::Keys'
|
|
41
|
+
end
|
|
42
|
+
|
|
32
43
|
# Get a single unauthenticated user
|
|
33
44
|
#
|
|
34
45
|
# = Examples
|
|
35
|
-
#
|
|
36
|
-
#
|
|
46
|
+
# github = Github.new
|
|
47
|
+
# github.users.get 'user-name'
|
|
37
48
|
#
|
|
38
49
|
# Get the authenticated user
|
|
39
50
|
#
|
|
40
51
|
# = Examples
|
|
41
52
|
# @github = Github.new :oauth_token => '...'
|
|
42
|
-
# @github.users.
|
|
53
|
+
# @github.users.get
|
|
43
54
|
#
|
|
44
|
-
def
|
|
55
|
+
def get(user_name=nil, params={})
|
|
45
56
|
_normalize_params_keys(params)
|
|
46
57
|
if user_name
|
|
47
|
-
|
|
58
|
+
get_request("/users/#{user_name}", params)
|
|
48
59
|
else
|
|
49
|
-
|
|
60
|
+
get_request("/user", params)
|
|
50
61
|
end
|
|
51
62
|
end
|
|
52
|
-
alias :
|
|
63
|
+
alias :find :get
|
|
53
64
|
|
|
54
65
|
# Update the authenticated user
|
|
55
66
|
#
|
|
@@ -63,8 +74,8 @@ module Github
|
|
|
63
74
|
# * <tt>:bio</tt> - Optional string
|
|
64
75
|
#
|
|
65
76
|
# = Examples
|
|
66
|
-
#
|
|
67
|
-
#
|
|
77
|
+
# github = Github.new :oauth_token => '..'
|
|
78
|
+
# github.users.update
|
|
68
79
|
# "name" => "monalisa octocat",
|
|
69
80
|
# "email" => "octocat@github.com",
|
|
70
81
|
# "blog" => "https://github.com/blog",
|
|
@@ -73,12 +84,11 @@ module Github
|
|
|
73
84
|
# "hireable" => true,
|
|
74
85
|
# "bio" => "There once..."
|
|
75
86
|
#
|
|
76
|
-
def
|
|
87
|
+
def update(params={})
|
|
77
88
|
_normalize_params_keys(params)
|
|
78
89
|
_filter_params_keys(VALID_USER_PARAMS_NAMES, params)
|
|
79
|
-
|
|
90
|
+
patch_request("/user", params)
|
|
80
91
|
end
|
|
81
|
-
alias :update_authenticated_user :update_user
|
|
82
92
|
|
|
83
93
|
end # Users
|
|
84
94
|
end # Github
|