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



66
67
68
# File 'lib/octokit/client/users.rb', line 66

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

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



54
55
56
# File 'lib/octokit/client/users.rb', line 54

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

#emails(options = {}) ⇒ Object



62
63
64
# File 'lib/octokit/client/users.rb', line 62

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

#follow(user, options = {}) ⇒ Object



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



50
51
52
# File 'lib/octokit/client/users.rb', line 50

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

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



70
71
72
# File 'lib/octokit/client/users.rb', line 70

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

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



58
59
60
# File 'lib/octokit/client/users.rb', line 58

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



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

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



46
47
48
# File 'lib/octokit/client/users.rb', line 46

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