module Travis::Api::App::Responders # This XML responder is used if the resource is a Repository, or a collection # of Repositories. # It returns XML data conforming to Multiple Project Summary Reporting Standard, # as explained in http://confluence.public.thoughtworks.org/display/CI/Multiple+Project+Summary+Reporting+Standard class Xml < Base TEMPLATE_ERB = ERB.new <<-EOF <% @resource.each do |repository| %> <% next if build(repository).nil? %> <% end %> EOF STATUS = { default: 'Unknown', passed: 'Success', failed: 'Failure', errored: 'Error', canceled: 'Canceled', } ACTIVITY = { default: 'Sleeping', started: 'Building' } def apply? @resource = Array(resource) super && @resource.first.is_a?(Repository) end instrument_method def apply super TEMPLATE_ERB.result(binding) end def branch params[:branch] end def build(repository) if branch.present? repository.last_completed_build(branch) else repository.last_build end end private def content_type 'application/xml;charset=utf-8' end end end