Class: Octopi::User

Included Modules

Octopi::Resource

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.

email [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

VALID

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

error=, property, save

Public Class Method Details

find

public find(username)

Finds a single user identified by the given username

Example:

  user = User.find("fcoury")
  puts user. # should return 'fcoury'
[View source]


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

public find_all(username)

Finds all users whose username matches a given string

Example:

  User.find_all("oe") # Matches joe, moe and monroe
[View source]


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

public create_repository(name, opts = {})
[View source]


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

public keys

Returns a list of Key objects containing all SSH Public Keys this user currently has. Requires authentication.

Meta Tags

Raises:

[APIError]
[View source]


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=

public plan=(attributes = {})

Sets the attribute plan

Meta Tags

[View source]


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

def plan=(attributes={})
  @plan = Plan.new(attributes)
end

repositories

public 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.

[View source]


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

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

repository

public repository(options = {})

Searches for user Repository identified by name

[View source]


48
49
50
51
52
# File 'lib/octopi/user.rb', line 48

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

to_s

public 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.

[View source]


93
94
95
# File 'lib/octopi/user.rb', line 93

def to_s
  
end

user_property

public user_property(property, deep)
[View source]


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, ).each_pair do |k,v|
    return v unless deep
    
    v.each { |u| users << User.find(u) } 
  end
  
  users
end
Generated on Friday, July 31 2009 at 05:01:56 PM by YARD 0.2.3.2 (ruby-1.8.6).