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

Instance Method Details

#add_email(email, options = {}) ⇒ Object



68
69
70
# File 'lib/octokit/client/users.rb', line 68

def add_email(email, options={})
  post("user/email/add", options.merge({:email => email}))['emails']
end

#add_key(title, key, options = {}) ⇒ Object



56
57
58
# File 'lib/octokit/client/users.rb', line 56

def add_key(title, key, options={})
  post("user/key/add", options.merge({:title => title, :key => key}))['public_keys']
end

#emails(options = {}) ⇒ Object



64
65
66
# File 'lib/octokit/client/users.rb', line 64

def emails(options={})
  get("user/emails", options)['emails']
end

#follow!(user, options = {}) ⇒ Object Also known as: follow



38
39
40
# File 'lib/octokit/client/users.rb', line 38

def follow!(user, options={})
  post("user/follow/#{user}", options)['users']
end

#followers(user = login, options = {}) ⇒ Object



22
23
24
# File 'lib/octokit/client/users.rb', line 22

def followers(user=, options={})
  get("user/show/#{user}/followers", options)['users']
end

#following(user = login, options = {}) ⇒ Object



26
27
28
# File 'lib/octokit/client/users.rb', line 26

def following(user=, options={})
  get("user/show/#{user}/following", options)['users']
end

#follows?(*args) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
36
# File 'lib/octokit/client/users.rb', line 30

def follows?(*args)
  target = args.pop
  user = args.first
  user ||= 
  return if user.nil?
  following(user).include?(target)
end

#keys(options = {}) ⇒ Object



52
53
54
# File 'lib/octokit/client/users.rb', line 52

def keys(options={})
  get("user/keys", options)['public_keys']
end

#remove_email(email, options = {}) ⇒ Object



72
73
74
# File 'lib/octokit/client/users.rb', line 72

def remove_email(email, options={})
  post("user/email/remove", options.merge({:email => email}))['emails']
end

#remove_key(id, options = {}) ⇒ Object



60
61
62
# File 'lib/octokit/client/users.rb', line 60

def remove_key(id, options={})
  post("user/key/remove", options.merge({:id => id}))['public_keys']
end

#search_users(search, options = {}) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/octokit/client/users.rb', line 6

def search_users(search, options={})
  if search.match(EMAIL_RE)
    get("user/email/#{search}", options)['user']
  else
    get("user/search/#{search}", options)['users']
  end
end

#unfollow!(user, options = {}) ⇒ Object Also known as: unfollow



43
44
45
# File 'lib/octokit/client/users.rb', line 43

def unfollow!(user, options={})
  post("user/unfollow/#{user}", options)['users']
end

#update_user(values, options = {}) ⇒ Object



18
19
20
# File 'lib/octokit/client/users.rb', line 18

def update_user(values, options={})
  post("user/show/#{}", options.merge({:values => values}))['user']
end

#user(username = nil, options = {}) ⇒ Object



14
15
16
# File 'lib/octokit/client/users.rb', line 14

def user(username=nil, options={})
  get(["user/show", username].compact.join('/'), options)['user']
end

#watched(user = login, options = {}) ⇒ Object



48
49
50
# File 'lib/octokit/client/users.rb', line 48

def watched(user=, options={})
  get("repos/watched/#{user}", options)['repositories']
end