Repository activities page in Gitorious 3 UI
[gitorious:mainline.git] / app / presenters / repository_presenter.rb
1 # encoding: utf-8
2 #--
3 #   Copyright (C) 2012-2013 Gitorious AS
4 #
5 #   This program is free software: you can redistribute it and/or modify
6 #   it under the terms of the GNU Affero General Public License as published by
7 #   the Free Software Foundation, either version 3 of the License, or
8 #   (at your option) any later version.
9 #
10 #   This program is distributed in the hope that it will be useful,
11 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #   GNU Affero General Public License for more details.
14 #
15 #   You should have received a copy of the GNU Affero General Public License
16 #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 #++
18 require "presenters/project_presenter"
19
20 class RepositoryPresenter
21   def initialize(repository)
22     @repository = repository
23   end
24
25   def id; repository.id; end
26   def name; repository.name; end
27   def gitdir; repository.gitdir; end
28   def to_param; repository.to_param; end
29   def path_segment; repository.path_segment; end
30   def full_repository_path; repository.full_repository_path; end
31   def head_candidate_name; repository.head_candidate_name; end
32   def ready?; repository.ready?; end
33   def committerships; repository.committerships; end
34   def has_commits?; repository.has_commits?; end
35
36   def open_merge_request_count
37     repository.open_merge_requests.count
38   end
39
40   def slug
41     "#{project.slug}/#{name}"
42   end
43
44   def project
45     @project ||= ProjectPresenter.new(@repository.project)
46   end
47
48   private
49   def repository; @repository; end
50 end