Module: Octokit::Client::Users
- Included in:
- Octokit::Client
- Defined in:
- lib/octokit/client/users.rb
Constant Summary collapse
- EMAIL_RE =
/[\w.!#\$%+-]+@[\w-]+(?:\.[\w-]+)+/
Instance Method Summary collapse
- #add_email(email, options = {}) ⇒ Object
- #add_key(title, key, options = {}) ⇒ Object
- #emails(options = {}) ⇒ Object
- #follow(user, options = {}) ⇒ Object
- #followers(user = login, options = {}) ⇒ Object
- #following(user = login, options = {}) ⇒ Object
- #follows?(*args) ⇒ Boolean
- #keys(options = {}) ⇒ Object
- #remove_email(email, options = {}) ⇒ Object
- #remove_key(id, options = {}) ⇒ Object
- #search_users(search, options = {}) ⇒ Object
- #unfollow(user, options = {}) ⇒ Object
-
#update_user(options) ⇒ Hashie::Mash
Update the authenticated user.
-
#user(user = nil) ⇒ Hashie::Mash
Get a single user.
- #watched(user = login, options = {}) ⇒ Object
Instance Method Details
#add_email(email, options = {}) ⇒ Object
88 89 90 |
# File 'lib/octokit/client/users.rb', line 88 def add_email(email, ={}) post("/api/v2/json/user/email/add", .merge({:email => email}))['emails'] end |
#add_key(title, key, options = {}) ⇒ Object
76 77 78 |
# File 'lib/octokit/client/users.rb', line 76 def add_key(title, key, ={}) post("/api/v2/json/user/key/add", .merge({:title => title, :key => key}))['public_keys'] end |
#emails(options = {}) ⇒ Object
84 85 86 |
# File 'lib/octokit/client/users.rb', line 84 def emails(={}) get("/api/v2/json/user/emails", )['emails'] end |
#follow(user, options = {}) ⇒ Object
60 61 62 |
# File 'lib/octokit/client/users.rb', line 60 def follow(user, ={}) post("/api/v2/json/user/follow/#{user}", )['users'] end |
#followers(user = login, options = {}) ⇒ Object
44 45 46 |
# File 'lib/octokit/client/users.rb', line 44 def followers(user=login, ={}) get("/api/v2/json/user/show/#{user}/followers", )['users'] end |
#following(user = login, options = {}) ⇒ Object
48 49 50 |
# File 'lib/octokit/client/users.rb', line 48 def following(user=login, ={}) get("/api/v2/json/user/show/#{user}/following", )['users'] end |
#follows?(*args) ⇒ Boolean
52 53 54 55 56 57 58 |
# File 'lib/octokit/client/users.rb', line 52 def follows?(*args) target = args.pop user = args.first user ||= login return if user.nil? following(user).include?(target) end |
#keys(options = {}) ⇒ Object
72 73 74 |
# File 'lib/octokit/client/users.rb', line 72 def keys(={}) get("/api/v2/json/user/keys", )['public_keys'] end |
#remove_email(email, options = {}) ⇒ Object
92 93 94 |
# File 'lib/octokit/client/users.rb', line 92 def remove_email(email, ={}) post("/api/v2/json/user/email/remove", .merge({:email => email}))['emails'] end |
#remove_key(id, options = {}) ⇒ Object
80 81 82 |
# File 'lib/octokit/client/users.rb', line 80 def remove_key(id, ={}) post("/api/v2/json/user/key/remove", .merge({:id => id}))['public_keys'] end |
#search_users(search, options = {}) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/octokit/client/users.rb', line 5 def search_users(search, ={}) if search.match(EMAIL_RE) get("/api/v2/json/user/email/#{search}", )['user'] else get("/api/v2/json/user/search/#{search}", )['users'] end end |
#unfollow(user, options = {}) ⇒ Object
64 65 66 |
# File 'lib/octokit/client/users.rb', line 64 def unfollow(user, ={}) post("/api/v2/json/user/unfollow/#{user}", )['users'] end |
#update_user(options) ⇒ Hashie::Mash
Update the authenticated user
40 41 42 |
# File 'lib/octokit/client/users.rb', line 40 def update_user() patch("/user", , 3) end |
#user(user = nil) ⇒ Hashie::Mash
Get a single user
19 20 21 22 23 24 25 |
# File 'lib/octokit/client/users.rb', line 19 def user(user=nil) if user get("/users/#{user}", {}, 3) else get("/user", {}, 3) end end |
#watched(user = login, options = {}) ⇒ Object
68 69 70 |
# File 'lib/octokit/client/users.rb', line 68 def watched(user=login, ={}) get("/api/v2/json/repos/watched/#{user}", )['repositories'] end |