travis-api/lib/travis/api/app/responders/image.rb
2012-12-09 15:16:50 +01:00

27 lines
521 B
Ruby

module Travis::Api::App::Responders
class Image < Base
def apply?
options[:format] == 'png'
end
def apply
headers['Expires'] = Time.now.utc.httpdate
halt send_file(filename, type: :png, disposition: :inline)
end
private
def filename
"#{root}/public/images/result/#{result}.png"
end
def result
Repository::StatusImage.new(resource, params[:branch]).result
end
def root
File.expand_path('.') # TODO wat.
end
end
end