Class: GitHub::User
Instance Attribute Summary collapse
-
#collaborators ⇒ Object
Returns the value of attribute collaborators.
-
#company ⇒ Object
Returns the value of attribute company.
-
#created ⇒ Object
Returns the value of attribute created.
-
#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.
-
#fullname ⇒ Object
Returns the value of attribute fullname.
-
#homepage ⇒ Object
Returns the value of attribute homepage.
-
#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.
-
#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.
-
#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.
Class Method Summary collapse
-
.find(*args) ⇒ Object
- Find github user, accepts Hash with keys: :user/:username
- Github user name :repo/:repository/:project/:name
- Repo name :query/:search
-
Array of search terms as Strings or Symbols.
Instance Method Summary collapse
- #follow!(user) ⇒ Object
- #followers ⇒ Object
- #following ⇒ Object
-
#initialize(opts) ⇒ User
constructor
A new instance of User.
-
#unfollow!(user) ⇒ Object
api /user/unfollow/:user is not working properly atm, using http.
- #url ⇒ Object
Methods inherited from Base
aliases_for, base_uri, #get, get, post, #post, request, #set_attributes, set_resource, #to_s
Constructor Details
#initialize(opts) ⇒ User
Returns a new instance of User.
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/git_hub/user.rb', line 18 def initialize( opts ) @public_repo_count = opts.delete('repos') # TODO: find better way without modifying opts? @followers_count = opts.delete('followers') super if @login #need to correct attributes generated by /show/:user @name, @fullname = @login, @name @id = "user-#{@id}" end raise "Unable to initialize #{self.class} without name for #{opts}" unless @name @created = Time.parse(@created) unless @created.is_a?(Time) @pushed = Time.parse(@pushed) if @pushed && !@pushed.is_a?(Time) @type ||= "user" end |
Instance Attribute Details
#collaborators ⇒ Object
Returns the value of attribute collaborators.
8 9 10 |
# File 'lib/git_hub/user.rb', line 8 def collaborators @collaborators end |
#company ⇒ Object
Returns the value of attribute company.
8 9 10 |
# File 'lib/git_hub/user.rb', line 8 def company @company end |
#created ⇒ Object
Returns the value of attribute created.
8 9 10 |
# File 'lib/git_hub/user.rb', line 8 def created @created end |
#disk_usage ⇒ Object
Returns the value of attribute disk_usage.
8 9 10 |
# File 'lib/git_hub/user.rb', line 8 def disk_usage @disk_usage end |
#email ⇒ Object
Returns the value of attribute email.
8 9 10 |
# File 'lib/git_hub/user.rb', line 8 def email @email end |
#followers_count ⇒ Object
Returns the value of attribute followers_count.
8 9 10 |
# File 'lib/git_hub/user.rb', line 8 def followers_count @followers_count end |
#following_count ⇒ Object
Returns the value of attribute following_count.
8 9 10 |
# File 'lib/git_hub/user.rb', line 8 def following_count @following_count end |
#fullname ⇒ Object
Returns the value of attribute fullname.
8 9 10 |
# File 'lib/git_hub/user.rb', line 8 def fullname @fullname end |
#homepage ⇒ Object
Returns the value of attribute homepage.
8 9 10 |
# File 'lib/git_hub/user.rb', line 8 def homepage @homepage end |
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/git_hub/user.rb', line 8 def id @id end |
#language ⇒ Object
Returns the value of attribute language.
8 9 10 |
# File 'lib/git_hub/user.rb', line 8 def language @language end |
#location ⇒ Object
Returns the value of attribute location.
8 9 10 |
# File 'lib/git_hub/user.rb', line 8 def location @location end |
#login ⇒ Object
Returns the value of attribute login.
8 9 10 |
# File 'lib/git_hub/user.rb', line 8 def login @login end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/git_hub/user.rb', line 8 def name @name end |
#owned_private_repo_count ⇒ Object
Returns the value of attribute owned_private_repo_count.
8 9 10 |
# File 'lib/git_hub/user.rb', line 8 def owned_private_repo_count @owned_private_repo_count end |
#plan ⇒ Object
Returns the value of attribute plan.
8 9 10 |
# File 'lib/git_hub/user.rb', line 8 def plan @plan end |
#private_gist_count ⇒ Object
Returns the value of attribute private_gist_count.
8 9 10 |
# File 'lib/git_hub/user.rb', line 8 def private_gist_count @private_gist_count end |
#public_gist_count ⇒ Object
Returns the value of attribute public_gist_count.
8 9 10 |
# File 'lib/git_hub/user.rb', line 8 def public_gist_count @public_gist_count end |
#public_repo_count ⇒ Object
Returns the value of attribute public_repo_count.
8 9 10 |
# File 'lib/git_hub/user.rb', line 8 def public_repo_count @public_repo_count end |
#pushed ⇒ Object
Returns the value of attribute pushed.
8 9 10 |
# File 'lib/git_hub/user.rb', line 8 def pushed @pushed end |
#score ⇒ Object
Returns the value of attribute score.
8 9 10 |
# File 'lib/git_hub/user.rb', line 8 def score @score end |
#total_private_repo_count ⇒ Object
Returns the value of attribute total_private_repo_count.
8 9 10 |
# File 'lib/git_hub/user.rb', line 8 def total_private_repo_count @total_private_repo_count end |
#type ⇒ Object
Returns the value of attribute type.
8 9 10 |
# File 'lib/git_hub/user.rb', line 8 def type @type end |
Class Method Details
.find(*args) ⇒ Object
Find github user, accepts Hash with keys:
- :user/:username
-
Github user name
- :repo/:repository/:project/:name
-
Repo name
- :query/:search
-
Array of search terms as Strings or Symbols
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/git_hub/user.rb', line 40 def find( *args ) user, query = extract args, :user, :query path = if query "/search/#{query.map(&:to_s).join('+')}" elsif user "/show/#{user}" else raise "Unable to find #{self.class}(s) for #{opts}" end instantiate get(path) end |
Instance Method Details
#follow!(user) ⇒ Object
62 63 64 65 |
# File 'lib/git_hub/user.rb', line 62 def follow!( user ) API.ensure_auth post("/follow/#{user}")['users'].map {|user| User.find(:user => user )} end |
#followers ⇒ Object
53 54 55 56 |
# File 'lib/git_hub/user.rb', line 53 def followers res = get("/show/#{@name}/followers") res['users'].map {|user| User.find(:user => user )} end |
#following ⇒ Object
58 59 60 |
# File 'lib/git_hub/user.rb', line 58 def following get("/show/#{@name}/following")['users'].map {|user| User.find(:user => user )} end |
#unfollow!(user) ⇒ Object
api /user/unfollow/:user is not working properly atm, using http
67 68 69 70 71 72 |
# File 'lib/git_hub/user.rb', line 67 def unfollow!( user )# api /user/unfollow/:user is not working properly atm, using http API.ensure_auth res = get 'http://github.com/users/follow', 'target' => user raise "User Not Found #{user}" unless res.code == 302.to_s following end |
#url ⇒ Object
32 |
# File 'lib/git_hub/user.rb', line 32 def url; "http://github.com/#{@name}" end |