Class: Gitrob::Github::Organization
- Inherits:
-
Object
- Object
- Gitrob::Github::Organization
- Defined in:
- lib/gitrob/github/organization.rb
Instance Attribute Summary collapse
-
#http_client ⇒ Object
readonly
Returns the value of attribute http_client.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #avatar_url ⇒ Object
- #display_name ⇒ Object
- #email ⇒ Object
-
#initialize(name, http_client) ⇒ Organization
constructor
A new instance of Organization.
- #location ⇒ Object
- #login ⇒ Object
- #members ⇒ Object
- #repositories ⇒ Object
- #save_to_database! ⇒ Object
- #to_model ⇒ Object
- #url ⇒ Object
- #website ⇒ Object
Constructor Details
#initialize(name, http_client) ⇒ Organization
Returns a new instance of Organization.
6 7 8 |
# File 'lib/gitrob/github/organization.rb', line 6 def initialize(name, http_client) @name, @http_client = name, http_client end |
Instance Attribute Details
#http_client ⇒ Object (readonly)
Returns the value of attribute http_client.
4 5 6 |
# File 'lib/gitrob/github/organization.rb', line 4 def http_client @http_client end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/gitrob/github/organization.rb', line 4 def name @name end |
Instance Method Details
#avatar_url ⇒ Object
34 35 36 |
# File 'lib/gitrob/github/organization.rb', line 34 def avatar_url info['avatar_url'] end |
#display_name ⇒ Object
10 11 12 |
# File 'lib/gitrob/github/organization.rb', line 10 def display_name info['name'].to_s.empty? ? info['login'] : info['name'] end |
#email ⇒ Object
26 27 28 |
# File 'lib/gitrob/github/organization.rb', line 26 def email info['email'] end |
#location ⇒ Object
22 23 24 |
# File 'lib/gitrob/github/organization.rb', line 22 def location info['location'] end |
#login ⇒ Object
14 15 16 |
# File 'lib/gitrob/github/organization.rb', line 14 def login info['login'] end |
#members ⇒ Object
50 51 52 |
# File 'lib/gitrob/github/organization.rb', line 50 def members() @members ||= recursive_members end |
#repositories ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/gitrob/github/organization.rb', line 38 def repositories if !@repositories @repositories = [] response = JSON.parse(http_client.do_get("/orgs/#{name}/repos").body) response.each do |repo| next if repo['fork'] @repositories << Repository.new(name, repo['name'], http_client) end end @repositories end |
#save_to_database! ⇒ Object
66 67 68 |
# File 'lib/gitrob/github/organization.rb', line 66 def save_to_database! self.to_model.tap { |m| m.save } end |
#to_model ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/gitrob/github/organization.rb', line 54 def to_model Gitrob::Organization.new( :name => self.display_name, :login => self.login, :website => self.website, :location => self.location, :email => self.email, :avatar_url => self.avatar_url, :url => self.url ) end |
#url ⇒ Object
30 31 32 |
# File 'lib/gitrob/github/organization.rb', line 30 def url "https://github.com/#{name}" end |
#website ⇒ Object
18 19 20 |
# File 'lib/gitrob/github/organization.rb', line 18 def website info['blog'] end |