Class: Ci::ArtifactBlob
- Inherits:
-
Object
show all
- Includes:
- BlobLike
- Defined in:
- app/models/ci/artifact_blob.rb
Constant Summary
collapse
- EXTENSIONS_SERVED_BY_PAGES =
%w[.html .htm .txt .json .xml .log].freeze
Gitlab::BlobHelper::MEGABYTE
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from BlobLike
#binary_in_repo?, #load_all_data!, #name, #path, #truncated?
#_mime_type, #binary_in_repo?, #binary_mime_type?, #content_type, #detect_encoding, #empty?, #encoded_newlines_re, #encoding, #extname, #image?, #known_extension?, #large?, #lines, #mime_type, #ruby_encoding, #text_in_repo?, #viewable?
#clear_memoization, #strong_memoize, #strong_memoized?
Constructor Details
Returns a new instance of ArtifactBlob.
11
12
13
|
# File 'app/models/ci/artifact_blob.rb', line 11
def initialize(entry)
@entry = entry
end
|
Instance Attribute Details
#entry ⇒ Object
Returns the value of attribute entry
9
10
11
|
# File 'app/models/ci/artifact_blob.rb', line 9
def entry
@entry
end
|
Instance Method Details
#data ⇒ Object
26
27
28
|
# File 'app/models/ci/artifact_blob.rb', line 26
def data
"Build artifact #{path}"
end
|
#external_link?(job) ⇒ Boolean
52
53
54
55
56
57
|
# File 'app/models/ci/artifact_blob.rb', line 52
def external_link?(job)
pages_config.enabled &&
pages_config.artifacts_server &&
EXTENSIONS_SERVED_BY_PAGES.include?(File.extname(name)) &&
(pages_config.access_control || job.project.public?)
end
|
#external_storage ⇒ Object
34
35
36
|
# File 'app/models/ci/artifact_blob.rb', line 34
def external_storage
:build_artifact
end
|
#external_url(project, job) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'app/models/ci/artifact_blob.rb', line 38
def external_url(project, job)
return unless external_link?(job)
url_project_path = project.full_path.partition('/').last
artifact_path = [
'-', url_project_path, '-',
'jobs', job.id,
'artifacts', path
].join('/')
"#{project.pages_group_url}/#{artifact_path}"
end
|
#id ⇒ Object
17
18
19
|
# File 'app/models/ci/artifact_blob.rb', line 17
def id
Digest::SHA1.hexdigest(path)
end
|
#mode ⇒ Object
30
31
32
|
# File 'app/models/ci/artifact_blob.rb', line 30
def mode
entry.metadata[:mode]
end
|
#size ⇒ Object
Also known as:
external_size
21
22
23
|
# File 'app/models/ci/artifact_blob.rb', line 21
def size
entry.metadata[:size]
end
|