Class: CommitPresenter
- Inherits:
-
Object
show all
- Includes:
- UrlHelper
- Defined in:
- app/presenters/commit_presenter.rb
Instance Method Summary
collapse
Methods included from UrlHelper
#edit_release_path, #edit_release_url, #feature_path, #github_commit_range_url, #github_commit_url, #github_project_url, #github_url?, #goldmine_case_number_url, #link_to_project_feature, #new_release_url, #release_path, #release_url, #releases_path
Constructor Details
Returns a new instance of CommitPresenter.
4
5
6
|
# File 'app/presenters/commit_presenter.rb', line 4
def initialize(commits)
@commits = OneOrMany.new(commits)
end
|
Instance Method Details
#as_json(*args) ⇒ Object
8
9
10
|
# File 'app/presenters/commit_presenter.rb', line 8
def as_json(*args)
@commits.map(&method(:commit_to_json))
end
|
#commit_to_json(commit) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/presenters/commit_presenter.rb', line 12
def commit_to_json(commit)
hash = {
id: commit.id,
sha: commit.sha,
message: commit.summary,
project: commit.project.slug,
linkTo: github_commit_url(commit.project, commit.sha), committer: {
name: commit.committer,
email: commit.committer_email } }
release = commit.releases.earliest
if release
hash[:createdAt] = release.created_at
hash[:environment] = release.environment_name
end
hash
end
|
#verbose ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'app/presenters/commit_presenter.rb', line 35
def verbose
@commits.map do |commit|
commit_to_json(commit).merge({
tag: commit.tags.first,
hours: commit.hours_worked,
tickets: commit.ticket_numbers,
unreachable: commit.unreachable,
releases: commit.releases.map { |release| {
environment: release.environment_name,
createdAt: release.created_at } },
committers: commit.committers.map { |committer| {
id: committer.id,
email: committer.email,
name: committer.name } } })
end
end
|