Class: GitHub::Repo

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/github_api/repo.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.get(information) ⇒ Object



6
7
8
9
10
11
# File 'lib/github_api/repo.rb', line 6

def self.get(information)
  #FIXME: permalink column must be present, comparing url's is surely not the most efficient way for the db
  GitHub::Repo.find_or_create_by_url(
    GitHub::Base.parse_attributes(:repo_get,
      YAML::load(GitHub::Browser.get("/repos/show/#{information}"))['repository']))
end

Instance Method Details

#owner=(user) ⇒ Object



14
15
16
17
18
19
# File 'lib/github_api/repo.rb', line 14

def owner=(user)
  self.owner_id = GitHub::User.(user).id if user.class == String
  if user.class == GitHub::User
    self.owner_id = user.id
  end
end

#parent=(permalink) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/github_api/repo.rb', line 21

def parent=(permalink)
  owner = GitHub::User. 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


29
30
31
# File 'lib/github_api/repo.rb', line 29

def permalink
  "#{owner.}/#{name}"
end