module Travis::Api::App::Responders require 'date' class Atom < Base ATOM_FEED_ERB = ERB.new <<-EOF <%= resource.first.repository.slug %> Builds repo:<%= resource.first.repository.id %> Copyright (c) <%= DateTime.now.strftime("%Y") %> Travis CI GmbH <%= DateTime.now.rfc3339 %> <% resource.each do |build| %> <%= build.repository.slug %> Build #<%= build.number %> " /> repo:<%= build.repository.id %>:build:<%= build.id %> <%= ::DateTime.parse(build.updated_at.to_s).rfc3339 %> <p> <%= build.commit.message.encode(:xml => :text) %> (<%= build.commit.committer_name %>) <br/><br/> State: <%= build.state %> <br/> Started at: <%= build.started_at ? build.started_at : 'not started' %> <br/> Finished at: <%= build.finished_at ? build.finished_at : build.started_at ? 'still running' : 'not started' %> </p> <%= build.commit.committer_name %> <% end %> EOF def apply? super && resource.is_a?(ActiveRecord::Relation) && resource.first.is_a?(Build) end instrument_method def apply super ATOM_FEED_ERB.result(binding) end private def content_type 'application/atom+xml;charset=utf-8' end end end