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

- (Object) actions

Returns the value of attribute actions



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

def actions
  @actions
end

- (Object) blog

Returns the value of attribute blog



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

def blog
  @blog
end

- (Object) collaborators

Returns the value of attribute collaborators



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

def collaborators
  @collaborators
end

- (Object) company

Returns the value of attribute company



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

def company
  @company
end

- (Object) created

Returns the value of attribute created



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

def created
  @created
end

- (Object) created_at

Returns the value of attribute created_at



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

def created_at
  @created_at
end

- (Object) disk_usage

Returns the value of attribute disk_usage



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

def disk_usage
  @disk_usage
end

- (Object) email

Returns the value of attribute email



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

def email
  @email
end

- (Object) followers

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



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

def followers
  @followers
end

- (Object) followers_count

Returns the value of attribute followers_count



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

def followers_count
  @followers_count
end

- (Object) following

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

- (Object) following_count

Returns the value of attribute following_count



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

def following_count
  @following_count
end

- (Object) fullname

Returns the value of attribute fullname



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

def fullname
  @fullname
end

- (Object) gravatar_id

Returns the value of attribute gravatar_id



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

def gravatar_id
  @gravatar_id
end

- (Object) id

Returns the value of attribute id



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

def id
  @id
end

- (Object) language

Returns the value of attribute language



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

def language
  @language
end

- (Object) location

Returns the value of attribute location



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

def location
  @location
end

- (Object) login

Returns the value of attribute login



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

def 
  @login
end

- (Object) name

Returns the value of attribute name



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

def name
  @name
end

- (Object) owned_private_repo_count

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

- (Object) plan

Returns the value of attribute plan



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

def plan
  @plan
end

- (Object) private_gist_count

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

- (Object) private_repo_count

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

- (Object) public_gist_count

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

- (Object) public_repo_count

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

- (Object) pushed

Returns the value of attribute pushed



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

def pushed
  @pushed
end

- (Object) repos

Returns the value of attribute repos



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

def repos
  @repos
end

- (Object) score

Returns the value of attribute score



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

def score
  @score
end

- (Object) total_private_repo_count

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

- (Object) type

Returns the value of attribute type



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

def type
  @type
end

- (Object) username

Returns the value of attribute username



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

def username
  @username
end

Class Method Details

+ (Object) find(username)

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

+ (Object) find_all(username) 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

+ (Object) find_by_email(email)

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

- (Object) create_repository(name, options = {})



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

- (Object) followers!

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

- (Object) following!

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

- (Object) 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.



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

- (Object) repository(options = {})

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

- (Object) 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.



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

def to_s
  
end

- (Object) watching



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