Class: GitHub::Repo
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- GitHub::Repo
- Defined in:
- lib/github-api-client/repo.rb
Class Method Summary collapse
Instance Method Summary collapse
- #fetch(*things) ⇒ Object
- #fork? ⇒ Boolean
- #get ⇒ Object
- #organization_login=(organization) ⇒ Object
- #owner_login=(user) ⇒ Object
- #parent=(permalink) ⇒ Object
- #permalink ⇒ Object
-
#permalink=(anything) ⇒ Object
For future, when sql will be find_or_create_by_permalink.
Class Method Details
.get(information) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/github-api-client/repo.rb', line 15 def self.get(information) #FIXME: permalink column must be present, comparing url's is surely not the most efficient way for the db conditions = {:name => information.split('/').last, :owner_id => GitHub::User.find_or_create_by_login(information.split('/').first).id} if r = GitHub::Repo.where(conditions).first r.get else r = GitHub::Repo.new(conditions).get end end |
Instance Method Details
#fetch(*things) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/github-api-client/repo.rb', line 25 def fetch(*things) things.each do |thing| case thing when :self then get when :watchers then get_watchers end end self end |
#fork? ⇒ Boolean
85 86 87 |
# File 'lib/github-api-client/repo.rb', line 85 def fork? b_fork end |
#get ⇒ Object
8 9 10 11 12 13 |
# File 'lib/github-api-client/repo.rb', line 8 def get self.update_attributes GitHub::Base.parse_attributes(:repo_get, YAML::load( GitHub::Browser.get("/repos/show/#{self.permalink}"))['repository']) self end |
#organization_login=(organization) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/github-api-client/repo.rb', line 60 def organization_login=(organization) if organization self.b_org = true self.organization = Organization.find_or_create_by_login(organization) end end |
#owner_login=(user) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/github-api-client/repo.rb', line 53 def owner_login=(user) if user self.b_org = false self.owner = GitHub::User.find_or_create_by_login(user) end end |
#parent=(permalink) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/github-api-client/repo.rb', line 67 def parent=(permalink) owner = GitHub::User.find_or_create_by_login permalink.split('/').first name = permalink.split('/').last repo = GitHub::Repo.where(:owner_id => owner.id, :name => name).first repo ||= GitHub::Repo.create(:owner_id => owner.id, :name => name) self.parent_id = repo.id end |
#permalink ⇒ Object
75 76 77 78 |
# File 'lib/github-api-client/repo.rb', line 75 def permalink o = owner.presence || organization.presence "#{o.login}/#{name}" end |
#permalink=(anything) ⇒ Object
For future, when sql will be find_or_create_by_permalink
81 82 83 |
# File 'lib/github-api-client/repo.rb', line 81 def permalink=(anything) @permalink = permalink end |