2016-11-03 11:54:10 +00:00
|
|
|
class BuildEntity < Grape::Entity
|
|
|
|
include RequestAwareEntity
|
|
|
|
|
|
|
|
expose :id
|
|
|
|
expose :name
|
|
|
|
|
2016-11-17 15:08:05 +00:00
|
|
|
expose :build_path do |build|
|
|
|
|
path_to(:namespace_project_build, build)
|
2016-11-03 11:54:10 +00:00
|
|
|
end
|
|
|
|
|
2016-11-17 15:08:05 +00:00
|
|
|
expose :retry_path do |build|
|
|
|
|
path_to(:retry_namespace_project_build, build)
|
2016-11-03 12:35:57 +00:00
|
|
|
end
|
|
|
|
|
2017-02-28 15:48:39 +00:00
|
|
|
expose :play_path, if: ->(build, _) { build.playable? } do |build|
|
2016-11-17 15:08:05 +00:00
|
|
|
path_to(:play_namespace_project_build, build)
|
2016-11-03 12:35:57 +00:00
|
|
|
end
|
|
|
|
|
2016-11-29 10:57:16 +00:00
|
|
|
expose :created_at
|
|
|
|
expose :updated_at
|
2017-03-10 15:16:48 +00:00
|
|
|
expose :detailed_status, as: :status, with: StatusEntity
|
2017-02-27 19:17:21 +00:00
|
|
|
|
2016-11-03 12:35:57 +00:00
|
|
|
private
|
|
|
|
|
2017-03-03 06:59:25 +00:00
|
|
|
alias_method :build, :object
|
|
|
|
|
2016-11-17 15:08:05 +00:00
|
|
|
def path_to(route, build)
|
|
|
|
send("#{route}_path", build.project.namespace, build.project, build)
|
2016-11-03 11:54:10 +00:00
|
|
|
end
|
2017-03-03 06:59:25 +00:00
|
|
|
|
|
|
|
def detailed_status
|
|
|
|
build.detailed_status(request.user)
|
|
|
|
end
|
2016-11-03 11:54:10 +00:00
|
|
|
end
|