Class: Repository
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Repository
- Includes:
- ServiceHook
- Defined in:
- lib/travis/model/repository.rb,
lib/travis/model/repository/service_hook.rb
Defined Under Namespace
Modules: ServiceHook
Class Method Summary collapse
- .active_by_name ⇒ Object
- .by_owner_name(owner_name) ⇒ Object
- .by_slug(slug) ⇒ Object
- .find_by(params) ⇒ Object
- .recent ⇒ Object
- .search(query) ⇒ Object
- .timeline ⇒ Object
Instance Method Summary collapse
Methods included from ServiceHook
Class Method Details
.active_by_name ⇒ Object
53 54 55 |
# File 'lib/travis/model/repository.rb', line 53 def active_by_name Hash[select([:active, :name]).map { |repository| [repository.name, repository.active] }] end |
.by_owner_name(owner_name) ⇒ Object
33 34 35 |
# File 'lib/travis/model/repository.rb', line 33 def by_owner_name(owner_name) where(:owner_name => owner_name) end |
.by_slug(slug) ⇒ Object
37 38 39 |
# File 'lib/travis/model/repository.rb', line 37 def by_slug(slug) where(:owner_name => slug.split('/').first, :name => slug.split('/').last) end |
.find_by(params) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/travis/model/repository.rb', line 45 def find_by(params) if id = params[:id] || params[:repository_id] self.find(id) else self.where(params.slice(:name, :owner_name)).first end end |
.recent ⇒ Object
29 30 31 |
# File 'lib/travis/model/repository.rb', line 29 def recent limit(20) end |
.search(query) ⇒ Object
41 42 43 |
# File 'lib/travis/model/repository.rb', line 41 def search(query) where('repositories.name ~* ? OR repositories.owner_name ~* ?', query, query) end |
.timeline ⇒ Object
25 26 27 |
# File 'lib/travis/model/repository.rb', line 25 def timeline where(arel_table[:last_build_started_at].not_eq(nil)).order(arel_table[:last_build_started_at].desc) end |
Instance Method Details
#last_build_status(params = {}) ⇒ Object
58 59 60 61 |
# File 'lib/travis/model/repository.rb', line 58 def last_build_status(params = {}) params = params.symbolize_keys.slice(*Build.matrix_keys_for(params)) params.blank? ? read_attribute(:last_build_status) : builds.last_status_on(params) end |
#slug ⇒ Object
63 64 65 |
# File 'lib/travis/model/repository.rb', line 63 def slug @slug ||= [owner_name, name].join('/') end |