Class: Octopi::User

Inherits:
Base
  • Object
show all
Includes:
Resource
Defined in:
lib/octopi/user.rb

Constant Summary

Constant Summary

Constants inherited from Base

Base::VALID

Instance Attribute Summary collapse

Attributes inherited from Base

#api

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Resource

for, included

Methods inherited from Base

#error=, #initialize, #property, #save

Constructor Details

This class inherits a constructor from Octopi::Base

Instance Attribute Details

#actionsObject

Returns the value of attribute actions



4
5
6
# File 'lib/octopi/user.rb', line 4

def actions
  @actions
end

#blogObject

Returns the value of attribute blog



4
5
6
# File 'lib/octopi/user.rb', line 4

def blog
  @blog
end

#collaboratorsObject

Returns the value of attribute collaborators



4
5
6
# File 'lib/octopi/user.rb', line 4

def collaborators
  @collaborators
end

#companyObject

Returns the value of attribute company



4
5
6
# File 'lib/octopi/user.rb', line 4

def company
  @company
end

#createdObject

Returns the value of attribute created



4
5
6
# File 'lib/octopi/user.rb', line 4

def created
  @created
end

#created_atObject

Returns the value of attribute created_at



4
5
6
# File 'lib/octopi/user.rb', line 4

def created_at
  @created_at
end

#disk_usageObject

Returns the value of attribute disk_usage



4
5
6
# File 'lib/octopi/user.rb', line 4

def disk_usage
  @disk_usage
end

#emailObject

Returns the value of attribute email



4
5
6
# File 'lib/octopi/user.rb', line 4

def email
  @email
end

#followersObject

Gets a list of followers. Returns an array of logins.



95
96
97
# File 'lib/octopi/user.rb', line 95

def followers
  @followers
end

#followers_countObject

Returns the value of attribute followers_count



4
5
6
# File 'lib/octopi/user.rb', line 4

def followers_count
  @followers_count
end

#followingObject

Gets a list of people this user is following. Returns an array of logins.



108
109
110
# File 'lib/octopi/user.rb', line 108

def following
  @following
end

#following_countObject

Returns the value of attribute following_count



4
5
6
# File 'lib/octopi/user.rb', line 4

def following_count
  @following_count
end

#fullnameObject

Returns the value of attribute fullname



4
5
6
# File 'lib/octopi/user.rb', line 4

def fullname
  @fullname
end

#gravatar_idObject

Returns the value of attribute gravatar_id



4
5
6
# File 'lib/octopi/user.rb', line 4

def gravatar_id
  @gravatar_id
end

#idObject

Returns the value of attribute id



4
5
6
# File 'lib/octopi/user.rb', line 4

def id
  @id
end

#languageObject

Returns the value of attribute language



4
5
6
# File 'lib/octopi/user.rb', line 4

def language
  @language
end

#locationObject

Returns the value of attribute location



4
5
6
# File 'lib/octopi/user.rb', line 4

def location
  @location
end

#loginObject

Returns the value of attribute login



4
5
6
# File 'lib/octopi/user.rb', line 4

def 
  @login
end

#nameObject

Returns the value of attribute name



4
5
6
# File 'lib/octopi/user.rb', line 4

def name
  @name
end

#owned_private_repo_countObject

Returns the value of attribute owned_private_repo_count



4
5
6
# File 'lib/octopi/user.rb', line 4

def owned_private_repo_count
  @owned_private_repo_count
end

#planObject

Returns the value of attribute plan



4
5
6
# File 'lib/octopi/user.rb', line 4

def plan
  @plan
end

#private_gist_countObject

Returns the value of attribute private_gist_count



4
5
6
# File 'lib/octopi/user.rb', line 4

def private_gist_count
  @private_gist_count
end

#private_repo_countObject

Returns the value of attribute private_repo_count



4
5
6
# File 'lib/octopi/user.rb', line 4

def private_repo_count
  @private_repo_count
end

#public_gist_countObject

Returns the value of attribute public_gist_count



4
5
6
# File 'lib/octopi/user.rb', line 4

def public_gist_count
  @public_gist_count
end

#public_repo_countObject

Returns the value of attribute public_repo_count



4
5
6
# File 'lib/octopi/user.rb', line 4

def public_repo_count
  @public_repo_count
end

#pushedObject

Returns the value of attribute pushed



4
5
6
# File 'lib/octopi/user.rb', line 4

def pushed
  @pushed
end

#reposObject

Returns the value of attribute repos



4
5
6
# File 'lib/octopi/user.rb', line 4

def repos
  @repos
end

#scoreObject

Returns the value of attribute score



4
5
6
# File 'lib/octopi/user.rb', line 4

def score
  @score
end

#total_private_repo_countObject

Returns the value of attribute total_private_repo_count



4
5
6
# File 'lib/octopi/user.rb', line 4

def total_private_repo_count
  @total_private_repo_count
end

#typeObject

Returns the value of attribute type



4
5
6
# File 'lib/octopi/user.rb', line 4

def type
  @type
end

#usernameObject

Returns the value of attribute username



4
5
6
# File 'lib/octopi/user.rb', line 4

def username
  @username
end

Class Method Details

.find(username) ⇒ Object

Finds a single user identified by the given username

Example:

user = User.find("fcoury")
puts user. # should return 'fcoury'


29
30
31
32
# File 'lib/octopi/user.rb', line 29

def self.find(username)
  self.validate_args(username => :user)
  super username
end

.find_all(username) ⇒ Object Also known as: search

Finds all users whose username matches a given string

Example:

User.find_all("oe") # Matches joe, moe and monroe


51
52
53
54
# File 'lib/octopi/user.rb', line 51

def self.find_all(username)
  self.validate_args(username => :user)
  super username
end

.find_by_email(email) ⇒ Object

Finds the user with this email.

Example:

user = User.find_by_email("test@example.com")
puts user.email # should return 'test@example.com'


40
41
42
43
# File 'lib/octopi/user.rb', line 40

def self.find_by_email(email)
  response = Api.api.get("/user/email/:email", {:email => email})
  User.new(response["user"])
end

Instance Method Details

#create_repository(name, options = {}) ⇒ Object



79
80
81
82
# File 'lib/octopi/user.rb', line 79

def create_repository(name, options = {})
  self.class.validate_args(name => :repo)
  Repository.create(self, name, options)
end

#followers!Object

Gets a list of followers. Returns an array of user objects. If user has a large number of followers you may be rate limited by the API.



102
103
104
# File 'lib/octopi/user.rb', line 102

def followers!
  user_property("followers", true)
end

#following!Object

Gets a list of people this user is following. Returns an array of user objectrs. If user has a large number of people whom they follow, you may be rate limited by the API.



115
116
117
# File 'lib/octopi/user.rb', line 115

def following!
  user_property("following", true)
end

#repositoriesObject

Returns a collection of Repository objects, containing all repositories of the user.

If user is the current authenticated user, some additional information will be provided for the Repositories.



66
67
68
69
70
# File 'lib/octopi/user.rb', line 66

def repositories
  rs = RepositorySet.new(Repository.find(:user => self.))
  rs.user = self
  rs
end

#repository(options = {}) ⇒ Object

Searches for user Repository identified by name



73
74
75
76
77
# File 'lib/octopi/user.rb', line 73

def repository(options={})
  options = { :name => options } if options.is_a?(String)
  self.class.ensure_hash(options)
  Repository.find({ :user =>  }.merge!(options))
end

#to_sObject

If a user object is passed into a method, we can use this. It'll also work if we pass in just the login.



122
123
124
# File 'lib/octopi/user.rb', line 122

def to_s
  
end

#watchingObject



84
85
86
87
88
89
90
# File 'lib/octopi/user.rb', line 84

def watching
  repositories = []
  Api.api.get("/repos/watched/#{}")["repositories"].each do |repo|
    repositories << Repository.new(repo)
  end
  repositories
end