Class: Project

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/project.rb

Constant Summary collapse

UID_FORMAT =
/\A([a-z0-9\-\_\.]+)\:([a-z0-9\-\_\.]+)\/([a-z0-9\-\_\.]+)\Z/i

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_by_uid(uid) ⇒ Object


15
16
17
18
# File 'app/models/project.rb', line 15

def self.find_by_uid(uid)
  uid = "github:#{uid}" if uid !~ /\:/
  where(:uid => uid).first
end

Instance Method Details

#repo_nameObject

TODO: implement another way


35
36
37
# File 'app/models/project.rb', line 35

def repo_name
  @repo_name ||= InchCI::ProjectUID.new(uid).repo_name
end

#service_nameObject

TODO: implement another way


25
26
27
# File 'app/models/project.rb', line 25

def service_name
  @service_name ||= InchCI::ProjectUID.new(uid).service
end

#userObject


20
21
22
# File 'app/models/project.rb', line 20

def user
  User.where(:provider => service_name, :user_name => user_name).first
end

#user_nameObject

TODO: implement another way


30
31
32
# File 'app/models/project.rb', line 30

def user_name
  @user_name ||= InchCI::ProjectUID.new(uid).user_name
end