lib/github_api/users.rb in github_api-0.4.11 vs lib/github_api/users.rb in github_api-0.5.0.rc1
- old
+ new
@@ -8,14 +8,10 @@
autoload_all 'github_api/users',
:Emails => 'emails',
:Followers => 'followers',
:Keys => 'keys'
- include Github::Users::Emails
- include Github::Users::Followers
- include Github::Users::Keys
-
VALID_USER_PARAMS_NAMES = %w[
name
email
blog
company
@@ -27,31 +23,46 @@
# Creates new Repos API
def initialize(options = {})
super(options)
end
+ # Access to Users::Emails API
+ def emails
+ @emails ||= ApiFactory.new 'Users::Emails'
+ end
+
+ # Access to Users::Followers API
+ def followers
+ @followers ||= ApiFactory.new 'Users::Followers'
+ end
+
+ # Access to Users::Keys API
+ def keys
+ @keys ||= ApiFactory.new 'Users::Keys'
+ end
+
# Get a single unauthenticated user
#
# = Examples
- # @github = Github.new
- # @github.users.get_user 'user-name'
+ # github = Github.new
+ # github.users.get 'user-name'
#
# Get the authenticated user
#
# = Examples
# @github = Github.new :oauth_token => '...'
- # @github.users.get_user
+ # @github.users.get
#
- def get_user(user_name=nil, params={})
+ def get(user_name=nil, params={})
_normalize_params_keys(params)
if user_name
- get("/users/#{user_name}", params)
+ get_request("/users/#{user_name}", params)
else
- get("/user", params)
+ get_request("/user", params)
end
end
- alias :get_auth_user :get_user
+ alias :find :get
# Update the authenticated user
#
# = Inputs
# * <tt>:name</tt> - Optional string
@@ -61,24 +72,23 @@
# * <tt>:location</tt> - Optional string
# * <tt>:hireable</tt> - Optional boolean
# * <tt>:bio</tt> - Optional string
#
# = Examples
- # @github = Github.new :oauth_token => '..'
- # @github.users.update_user
+ # github = Github.new :oauth_token => '..'
+ # github.users.update
# "name" => "monalisa octocat",
# "email" => "octocat@github.com",
# "blog" => "https://github.com/blog",
# "company" => "GitHub",
# "location" => "San Francisco",
# "hireable" => true,
# "bio" => "There once..."
#
- def update_user(params={})
+ def update(params={})
_normalize_params_keys(params)
_filter_params_keys(VALID_USER_PARAMS_NAMES, params)
- patch("/user", params)
+ patch_request("/user", params)
end
- alias :update_authenticated_user :update_user
end # Users
end # Github