Class: Fuselage::User
Instance Attribute Summary collapse
-
#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_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_count ⇒ Object
Returns the value of attribute followers_count.
-
#following_count ⇒ Object
Returns the value of attribute following_count.
-
#gravatar_id ⇒ Object
Returns the value of attribute gravatar_id.
-
#id ⇒ Object
Returns the value of attribute id.
-
#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.
-
#total_private_repo_count ⇒ Object
Returns the value of attribute total_private_repo_count.
Attributes inherited from Base
Class Method Summary collapse
- .current ⇒ Object
-
.find(username) ⇒ Object
Finds a single user identified by the given username.
- .get_access_token(client_id, client_secret, code) ⇒ Object
Instance Method Summary collapse
- #followers ⇒ Object
- #following ⇒ Object
-
#repositories(options = {}) ⇒ Object
Return repositories for user.
-
#to_s ⇒ Object
If a user object is passed into a method, we can use this.
Methods inherited from Base
delete_method, get, #initialize, post
Constructor Details
This class inherits a constructor from Fuselage::Base
Instance Attribute Details
#blog ⇒ Object
Returns the value of attribute blog.
4 5 6 |
# File 'lib/fuselage/user.rb', line 4 def blog @blog end |
#collaborators ⇒ Object
Returns the value of attribute collaborators.
4 5 6 |
# File 'lib/fuselage/user.rb', line 4 def collaborators @collaborators end |
#company ⇒ Object
Returns the value of attribute company.
4 5 6 |
# File 'lib/fuselage/user.rb', line 4 def company @company end |
#created_at ⇒ Object
Returns the value of attribute created_at.
4 5 6 |
# File 'lib/fuselage/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/fuselage/user.rb', line 4 def disk_usage @disk_usage end |
#email ⇒ Object
Returns the value of attribute email.
4 5 6 |
# File 'lib/fuselage/user.rb', line 4 def email @email end |
#followers_count ⇒ Object
Returns the value of attribute followers_count.
4 5 6 |
# File 'lib/fuselage/user.rb', line 4 def followers_count @followers_count end |
#following_count ⇒ Object
Returns the value of attribute following_count.
4 5 6 |
# File 'lib/fuselage/user.rb', line 4 def following_count @following_count end |
#gravatar_id ⇒ Object
Returns the value of attribute gravatar_id.
4 5 6 |
# File 'lib/fuselage/user.rb', line 4 def gravatar_id @gravatar_id end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/fuselage/user.rb', line 4 def id @id end |
#location ⇒ Object
Returns the value of attribute location.
4 5 6 |
# File 'lib/fuselage/user.rb', line 4 def location @location end |
#login ⇒ Object
Returns the value of attribute login.
4 5 6 |
# File 'lib/fuselage/user.rb', line 4 def login @login end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/fuselage/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/fuselage/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/fuselage/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/fuselage/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/fuselage/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/fuselage/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/fuselage/user.rb', line 4 def public_repo_count @public_repo_count end |
#total_private_repo_count ⇒ Object
Returns the value of attribute total_private_repo_count.
4 5 6 |
# File 'lib/fuselage/user.rb', line 4 def total_private_repo_count @total_private_repo_count end |
Class Method Details
.current ⇒ Object
21 22 23 24 |
# File 'lib/fuselage/user.rb', line 21 def self.current raise AuthenticationRequired unless Api.authenticated User.new(get('/user')) end |
.find(username) ⇒ Object
Finds a single user identified by the given username
Example:
user = User.find("fcoury")
puts user.login # should return 'fcoury'
32 33 34 |
# File 'lib/fuselage/user.rb', line 32 def self.find(username) User.new(get("/user/#{username}")) end |
.get_access_token(client_id, client_secret, code) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/fuselage/user.rb', line 12 def self.get_access_token(client_id, client_secret, code) responce = Api.api.post("https://github.com/login/oauth/access_token?client_id=#{client_id}&client_secret=#{client_secret}&code=#{code}") if responce.body != 'error=bad_verification_code' access_token = responce.body.match(/\Aaccess_token=(\S+)&/)[1] rescue nil return access_token end raise RegisterError end |
Instance Method Details
#followers ⇒ Object
48 49 50 51 52 53 |
# File 'lib/fuselage/user.rb', line 48 def followers raise AuthenticationRequired unless Api.authenticated followers = [] User.get('/user/followers').each { |u| followers << User.new(u) } followers end |
#following ⇒ Object
41 42 43 44 45 46 |
# File 'lib/fuselage/user.rb', line 41 def following raise AuthenticationRequired unless Api.authenticated following = [] User.get('/user/following').each { |u| following << User.new(u) } following end |
#repositories(options = {}) ⇒ Object
Return repositories for user.
Options -
:organization,
:type -> <:all, :public, :private, :member>
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/fuselage/user.rb', line 61 def repositories( = {}) = {:type => :all}.merge() raise AuthenticationRequired unless Api.authenticated repos = [] if [:organization].nil? User.get('/user/repos', {:type => [:type].to_s}).each { |r| repos << Repository.new(r) } else User.get("/orgs/#{[:organization]}/repos", {:type => [:type].to_s}).each { |r| repos << Repository.new(r) } end repos 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.
75 76 77 |
# File 'lib/fuselage/user.rb', line 75 def to_s login end |