class Glman::Repos::UsersRepo
Constants
- PER_PAGE
Attributes
gitlab_url[R]
private_token[R]
Public Class Methods
new(opts={})
click to toggle source
# File lib/glman/repos/users_repo.rb, line 9 def initialize(opts={}) @gitlab_url = opts.fetch(:url) @private_token = opts.fetch(:private_token) end
Public Instance Methods
find(opts={})
click to toggle source
# File lib/glman/repos/users_repo.rb, line 21 def find(opts={}) opts = Hash[opts.map{ |k, v| [k.to_s, v] }] all.each do |user| return user if user.eql?(user.merge(opts)) end nil end
get(id)
click to toggle source
# File lib/glman/repos/users_repo.rb, line 17 def get(id) JSON.parse(client.get(url(id)).body) end
list()
click to toggle source
# File lib/glman/repos/users_repo.rb, line 13 def list all end
Private Instance Methods
all()
click to toggle source
# File lib/glman/repos/users_repo.rb, line 32 def all JSON.parse(client.get(url).body) end
client()
click to toggle source
# File lib/glman/repos/users_repo.rb, line 41 def client @client ||= HTTPClient.new end
url(id=nil)
click to toggle source
# File lib/glman/repos/users_repo.rb, line 36 def url(id=nil) url = [gitlab_url, 'api', 'v3', 'users', id, "?private_token=#{private_token}&per_page=#{PER_PAGE}"].compact.join('/') URI.join(url) end