Class: Octopi::User
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#actions ⇒ Object
Returns the value of attribute actions.
-
#blog ⇒ Object
Returns the value of attribute blog.
-
#collaborators ⇒ Object
Returns the value of attribute collaborators.
-
#company ⇒ Object
Returns the value of attribute company.
-
#created ⇒ Object
Returns the value of attribute created.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#disk_usage ⇒ Object
Returns the value of attribute disk_usage.
-
#email ⇒ Object
Returns the value of attribute email.
-
#followers ⇒ Object
Gets a list of followers.
-
#followers_count ⇒ Object
Returns the value of attribute followers_count.
-
#following ⇒ Object
Gets a list of people this user is following.
-
#following_count ⇒ Object
Returns the value of attribute following_count.
-
#fullname ⇒ Object
Returns the value of attribute fullname.
-
#gravatar_id ⇒ Object
Returns the value of attribute gravatar_id.
-
#id ⇒ Object
Returns the value of attribute id.
-
#language ⇒ Object
Returns the value of attribute language.
-
#location ⇒ Object
Returns the value of attribute location.
-
#login ⇒ Object
Returns the value of attribute login.
-
#name ⇒ Object
Returns the value of attribute name.
-
#owned_private_repo_count ⇒ Object
Returns the value of attribute owned_private_repo_count.
-
#plan ⇒ Object
Returns the value of attribute plan.
-
#private_gist_count ⇒ Object
Returns the value of attribute private_gist_count.
-
#private_repo_count ⇒ Object
Returns the value of attribute private_repo_count.
-
#public_gist_count ⇒ Object
Returns the value of attribute public_gist_count.
-
#public_repo_count ⇒ Object
Returns the value of attribute public_repo_count.
-
#pushed ⇒ Object
Returns the value of attribute pushed.
-
#repos ⇒ Object
Returns the value of attribute repos.
-
#score ⇒ Object
Returns the value of attribute score.
-
#total_private_repo_count ⇒ Object
Returns the value of attribute total_private_repo_count.
-
#type ⇒ Object
Returns the value of attribute type.
-
#username ⇒ Object
Returns the value of attribute username.
Attributes inherited from Base
Class Method Summary collapse
-
.find(username) ⇒ Object
Finds a single user identified by the given username.
-
.find_all(username) ⇒ Object
(also: search)
Finds all users whose username matches a given string.
-
.find_by_email(email) ⇒ Object
Finds the user with this email.
Instance Method Summary collapse
- #create_repository(name, options = {}) ⇒ Object
-
#followers! ⇒ Object
Gets a list of followers.
-
#following! ⇒ Object
Gets a list of people this user is following.
-
#repositories ⇒ Object
Returns a collection of Repository objects, containing all repositories of the user.
-
#repository(options = {}) ⇒ Object
Searches for user Repository identified by name.
-
#to_s ⇒ Object
If a user object is passed into a method, we can use this.
- #watching ⇒ Object
Methods included from Resource
Methods inherited from Base
#error=, #initialize, #property, #save
Constructor Details
This class inherits a constructor from Octopi::Base
Instance Attribute Details
#actions ⇒ Object
Returns the value of attribute actions.
4 5 6 |
# File 'lib/octopi/user.rb', line 4 def actions @actions end |
#blog ⇒ Object
Returns the value of attribute blog.
4 5 6 |
# File 'lib/octopi/user.rb', line 4 def blog @blog end |
#collaborators ⇒ Object
Returns the value of attribute collaborators.
4 5 6 |
# File 'lib/octopi/user.rb', line 4 def collaborators @collaborators end |
#company ⇒ Object
Returns the value of attribute company.
4 5 6 |
# File 'lib/octopi/user.rb', line 4 def company @company end |
#created ⇒ Object
Returns the value of attribute created.
4 5 6 |
# File 'lib/octopi/user.rb', line 4 def created @created end |
#created_at ⇒ Object
Returns the value of attribute created_at.
4 5 6 |
# File 'lib/octopi/user.rb', line 4 def created_at @created_at end |
#disk_usage ⇒ Object
Returns the value of attribute disk_usage.
4 5 6 |
# File 'lib/octopi/user.rb', line 4 def disk_usage @disk_usage end |
#email ⇒ Object
Returns the value of attribute email.
4 5 6 |
# File 'lib/octopi/user.rb', line 4 def email @email end |
#followers ⇒ Object
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_count ⇒ Object
Returns the value of attribute followers_count.
4 5 6 |
# File 'lib/octopi/user.rb', line 4 def followers_count @followers_count end |
#following ⇒ Object
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_count ⇒ Object
Returns the value of attribute following_count.
4 5 6 |
# File 'lib/octopi/user.rb', line 4 def following_count @following_count end |
#fullname ⇒ Object
Returns the value of attribute fullname.
4 5 6 |
# File 'lib/octopi/user.rb', line 4 def fullname @fullname end |
#gravatar_id ⇒ Object
Returns the value of attribute gravatar_id.
4 5 6 |
# File 'lib/octopi/user.rb', line 4 def gravatar_id @gravatar_id end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/octopi/user.rb', line 4 def id @id end |
#language ⇒ Object
Returns the value of attribute language.
4 5 6 |
# File 'lib/octopi/user.rb', line 4 def language @language end |
#location ⇒ Object
Returns the value of attribute location.
4 5 6 |
# File 'lib/octopi/user.rb', line 4 def location @location end |
#login ⇒ Object
Returns the value of attribute login.
4 5 6 |
# File 'lib/octopi/user.rb', line 4 def login @login end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/octopi/user.rb', line 4 def name @name end |
#owned_private_repo_count ⇒ Object
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 |
#plan ⇒ Object
Returns the value of attribute plan.
4 5 6 |
# File 'lib/octopi/user.rb', line 4 def plan @plan end |
#private_gist_count ⇒ Object
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_count ⇒ Object
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_count ⇒ Object
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_count ⇒ Object
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 |
#pushed ⇒ Object
Returns the value of attribute pushed.
4 5 6 |
# File 'lib/octopi/user.rb', line 4 def pushed @pushed end |
#repos ⇒ Object
Returns the value of attribute repos.
4 5 6 |
# File 'lib/octopi/user.rb', line 4 def repos @repos end |
#score ⇒ Object
Returns the value of attribute score.
4 5 6 |
# File 'lib/octopi/user.rb', line 4 def score @score end |
#total_private_repo_count ⇒ Object
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 |
#type ⇒ Object
Returns the value of attribute type.
4 5 6 |
# File 'lib/octopi/user.rb', line 4 def type @type end |
#username ⇒ Object
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.login # 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("[email protected]")
puts user.email # should return '[email protected]'
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, = {}) self.class.validate_args(name => :repo) Repository.create(self, name, ) 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 |
#repositories ⇒ Object
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.login)) 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(={}) = { :name => } if .is_a?(String) self.class.ensure_hash() Repository.find({ :user => login }.merge!()) end |
#to_s ⇒ Object
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 login end |
#watching ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/octopi/user.rb', line 84 def watching repositories = [] Api.api.get("/repos/watched/#{login}")["repositories"].each do |repo| repositories << Repository.new(repo) end repositories end |