Class: Octopi::User
- Octopi::Base
- Octopi::User
Included Modules
Attributes
Instance Attributes
blog | [RW] | public |
Sets the attribute blog. |
---|---|---|---|
collaborators | [RW] | public |
Sets the attribute collaborators. |
company | [RW] | public |
Sets the attribute company. |
created_at | [RW] | public |
Sets the attribute created_at. |
disk_usage | [RW] | public |
Sets the attribute disk_usage. |
[RW] | public |
Sets the attribute email. |
|
followers_count | [RW] | public |
Sets the attribute followers_count. |
following_count | [RW] | public |
Sets the attribute following_count. |
id | [RW] | public |
Sets the attribute id. |
location | [RW] | public |
Sets the attribute location. |
login | [RW] | public |
Sets the attribute login. |
name | [RW] | public |
Sets the attribute name. |
owned_private_repo_count | [RW] | public |
Sets the attribute owned_private_repo_count. |
plan | [RW] | public |
Sets the attribute plan. |
private_gist_count | [RW] | public |
Sets the attribute private_gist_count. |
private_repo_count | [RW] | public |
Sets the attribute private_repo_count. |
public_gist_count | [RW] | public |
Sets the attribute public_gist_count. |
public_repo_count | [RW] | public |
Sets the attribute public_repo_count. |
total_private_repo_count | [RW] | public |
Sets the attribute total_private_repo_count. |
Constants Inherited from Octopi::Base
Constructor Summary
This class inherits a constructor from Octopi::Base.
Public Visibility
Public Class Method Summary
find(username) |
Finds a single user identified by the given username. |
---|---|
find_all(username) |
Finds all users whose username matches a given string. |
Public Instance Method Summary
#create_repository(name, opts = {}) | |
---|---|
#keys |
Returns a list of Key objects containing all SSH Public Keys this user currently has. |
#plan=(attributes = {}) |
Sets the attribute plan.. |
#repositories |
Returns a collection of Repository objects, containing all repositories of the user. |
#repository(options = {}) |
Searches for user Repository identified by name. |
#to_s |
If a user object is passed into a method, we can use this. |
#user_property(property, deep) |
Public Instance Methods Inherited from Octopi::Base
Public Class Method Details
find
Finds a single user identified by the given username
Example:
user = User.find("fcoury") puts user.login # should return 'fcoury'
19 20 21 22 |
# File 'lib/octopi/user.rb', line 19 def self.find(username) self.validate_args(username => :user) super username end |
find_all
Finds all users whose username matches a given string
Example:
User.find_all("oe") # Matches joe, moe and monroe
30 31 32 33 |
# File 'lib/octopi/user.rb', line 30 def self.find_all(username) self.validate_args(username => :user) super username end |
Public Instance Method Details
create_repository
54 55 56 57 |
# File 'lib/octopi/user.rb', line 54 def create_repository(name, opts = {}) self.class.validate_args(name => :repo) Repository.create(self, name, opts) end |
keys
Returns a list of Key objects containing all SSH Public Keys this user currently has. Requires authentication.
61 62 63 64 65 66 67 |
# File 'lib/octopi/user.rb', line 61 def keys raise APIError, "To view keys, you must be authenticated" if Api.api.read_only? result = Api.api.get("/user/keys") return unless result and result["public_keys"] KeySet.new(result["public_keys"].inject([]) { |result, element| result << Key.new(element) }) end |
plan=
Sets the attribute plan
4 5 6 |
# File 'lib/octopi/user.rb', line 4 def plan=(attributes={}) @plan = Plan.new(attributes) end |
repositories
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.
41 42 43 44 45 |
# File 'lib/octopi/user.rb', line 41 def repositories rs = RepositorySet.new(Repository.find(:user => self.login)) rs.user = self rs end |
repository
Searches for user Repository identified by name
48 49 50 51 52 |
# File 'lib/octopi/user.rb', line 48 def repository(={}) = { :name => } if .is_a?(String) self.class.validate_hash() Repository.find({ :user => login }.merge!()) end |
to_s
If a user object is passed into a method, we can use this. It’ll also work if we pass in just the login.
93 94 95 |
# File 'lib/octopi/user.rb', line 93 def to_s login end |
user_property
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/octopi/user.rb', line 80 def user_property(property, deep) users = [] property(property, login).each_pair do |k,v| return v unless deep v.each { |u| users << User.find(u) } end users end |