Class: Gitwrap::User

Inherits:
OpenStruct
  • Object
show all
Includes:
HTTParty
Defined in:
lib/gitwrap/users.rb

Class Method Summary collapse

Class Method Details

.fetch_all_users(id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/gitwrap/users.rb', line 15

def self.fetch_all_users(id)
  response = get("/users?since=#{id}")
  if response.success?
    response = response.parsed_response
    response.each { |user| $users << new(user) }
  else
    raise_exception(response.code, response.body)
  end
  $users
end

.fetch_single_user(username) ⇒ Object



10
11
12
13
# File 'lib/gitwrap/users.rb', line 10

def self.fetch_single_user(username)
  response = get("/users/#{username}")
  if response.success? then user = new(response) else raise_exception(response.code, response.body) end
end

.fetch_users_by_language(language) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/gitwrap/users.rb', line 26

def self.fetch_users_by_language(language)
  response = get("/search/users?q=language:#{language}&per_page=100")
  if response.success?
    response = response["items"]
    response.each {|user| $users << new(user)}
  else
    raise_exception(response.code, response.body)
  end
  $users
end

.fetch_users_by_location(location) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/gitwrap/users.rb', line 37

def self.fetch_users_by_location(location)
  response = get("/search/users?q=location:#{location}&per_page=100")
  if response.success?
    response = response["items"]
    response.each { |user| $users << new(user) }
  else
    raise_exception(response.code, response.body)
  end
  $users
end

.fetch_users_by_location_and_language(location, language) ⇒ Object



48
49
50
51
52
53
54
55
56
57
# File 'lib/gitwrap/users.rb', line 48

def self.fetch_users_by_location_and_language(location, language)
  response = get("/search/users?q=location:#{location}+language:#{language}&per_page=100")
  if response.success?
    response = response["items"]
    response.each { |user| $users << new(user) }
  else
    raise_exception(response.code, response.body)
  end
  $users
end