Use here-doc for Atom feed template
Rather than unnaturally re-reading __FILE__ and splitting, use a here-doc to clarify the intent. (Should also consider splitting it to a file.)
This commit is contained in:
parent
3fa96de682
commit
148f2477e8
|
@ -2,7 +2,43 @@ module Travis::Api::App::Responders
|
|||
require 'securerandom'
|
||||
|
||||
class Atom < Base
|
||||
ATOM_FEED_ERB = ERB.new(File.read(__FILE__).split("__END__").last.strip)
|
||||
ATOM_FEED_ERB = ERB.new <<-EOF
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||
|
||||
<title><%= @builds.first.repository.slug %> Builds</title>
|
||||
<link href="<%= endpoint.url %>" type="application/atom+xml" rel = "self" />
|
||||
<id>urn:uuid:<%= SecureRandom.uuid %></id>
|
||||
<rights>Copyright (c) <%= DateTime.now.strftime("%Y") %> Travis CI GmbH</rights>
|
||||
<updated><%= DateTime.now.strftime %></updated>
|
||||
|
||||
<% @builds.each do |build| %>
|
||||
<entry>
|
||||
<title><%= build.repository.slug %> Build #<%= build.number %></title>
|
||||
<link href="<%= endpoint.url %>" />
|
||||
<id>urn:uuid:<%= SecureRandom.uuid %></id>
|
||||
<updated><%= build.finished_at || build.started_at %></updated>
|
||||
<summary type="html">
|
||||
<p>
|
||||
<%= build.commit.message %> (<%= 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>
|
||||
</summary>
|
||||
<author>
|
||||
<name><%= build.commit.committer_name %></name>
|
||||
</author>
|
||||
</entry>
|
||||
<% end %>
|
||||
|
||||
</feed>
|
||||
EOF
|
||||
|
||||
def apply?
|
||||
if resource.is_a?(ActiveRecord::Relation) && resource.first.is_a?(Build)
|
||||
|
@ -25,39 +61,3 @@ module Travis::Api::App::Responders
|
|||
|
||||
end
|
||||
end
|
||||
|
||||
__END__
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||
|
||||
<title><%= @builds.first.repository.slug %> Builds</title>
|
||||
<link href="<%= endpoint.url %>" rel = "self" />
|
||||
<id>urn:uuid:<%= SecureRandom.uuid %></id>
|
||||
<updated><%= DateTime.now.strftime %></updated>
|
||||
|
||||
<% @builds.each do |build| %>
|
||||
<entry>
|
||||
<title><%= build.repository.slug %> Build #<%= build.number %></title>
|
||||
<link href="" />
|
||||
<id>urn:uuid:<%= SecureRandom.uuid %></id>
|
||||
<updated><%= build.finished_at || build.started_at %></updated>
|
||||
<summary type="html">
|
||||
<p>
|
||||
<%= build.commit.message %> (<%= 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>
|
||||
</summary>
|
||||
<author>
|
||||
<name><%= build.commit.committer_name %></name>
|
||||
</author>
|
||||
</entry>
|
||||
<% end %>
|
||||
|
||||
</feed>
|
Loading…
Reference in New Issue
Block a user