class Artifact
Public Class Methods
new(job)
click to toggle source
# File lib/buildkiq/artifact.rb, line 5 def initialize(job) @s3_client = Aws::S3::Client.new @job = job end
Public Instance Methods
find_by(path)
click to toggle source
# File lib/buildkiq/artifact.rb, line 14 def find_by(path) io = if packaging_zip? fetch_zip_file.find_by_name(path) else fetch_s3_object("/#{path}") end io.read end
upload_success?()
click to toggle source
# File lib/buildkiq/artifact.rb, line 10 def upload_success? @job.artifact_upload_success? end
Private Instance Methods
bucket_name()
click to toggle source
# File lib/buildkiq/artifact.rb, line 38 def bucket_name @bucket_name ||= @job.build.artifacts.location.split(":::").last.split("/").first end
fetch_s3_object(path = "")
click to toggle source
# File lib/buildkiq/artifact.rb, line 34 def fetch_s3_object(path = "") @s3_client.get_object(bucket: bucket_name, key: "#{file_key}#{path}").body end
fetch_zip_file()
click to toggle source
# File lib/buildkiq/artifact.rb, line 30 def fetch_zip_file @zip_reader ||= Buildkiq::ZipReader.new(fetch_s3_object) end
file_key()
click to toggle source
# File lib/buildkiq/artifact.rb, line 42 def file_key @file_key ||= @job.build.artifacts.location.split(":::").last.split("/")[1..-1].join("/") end
packaging_zip?()
click to toggle source
# File lib/buildkiq/artifact.rb, line 26 def packaging_zip? @job.project.artifacts.packaging == "ZIP" end