2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
class BlobEntity < Grape::Entity
|
|
|
|
include RequestAwareEntity
|
|
|
|
|
|
|
|
expose :id, :path, :name, :mode
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
expose :readable_text?, as: :readable_text
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
expose :icon do |blob|
|
|
|
|
IconsHelper.file_type_icon_class('file', blob.mode, blob.name)
|
|
|
|
end
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
expose :url, if: -> (*) { request.respond_to?(:ref) } do |blob|
|
2017-09-10 17:25:29 +05:30
|
|
|
project_blob_path(request.project, File.join(request.ref, blob.path))
|
|
|
|
end
|
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
|
|
|
BlobEntity.prepend_if_ee('EE::BlobEntity')
|