class Repobrowse::GitAtom::Body

Public Class Methods

new(rd, r, repo, ref, path) click to toggle source
# File lib/repobrowse/git_atom.rb, line 17
    def initialize(rd, r, repo, ref, path)
      @rd = rd
      title = xt(+"#{repo.name} #{ref} #{path || '/'}")
      subtitle = xt(repo.driver.description.dup)
      @url = "#{r.base_url}#{r.script_name}/#{repo.name}"
      # read the first entry to ensure we have something
      updated = +''
      tmp = entry_begin(updated) or r404(r)

      @buf = +<<~EOF
        <?xml version="1.0"?><feed
        xmlns="http://www.w3.org/2005/Atom"><title>#{
        title}</title><subtitle>#{
        subtitle}</subtitle><link
        rel="alternate"
        type="text/html"
        href=#{xa(@url.dup)}
        /><id>#{
          xt("#@url/log/" + ref)
        }</id><updated>#{updated}</updated>
      EOF

      @buf << tmp
    end

Public Instance Methods

close() click to toggle source
# File lib/repobrowse/git_atom.rb, line 93
def close
  @rd.close
end
each() { |tmp| ... } click to toggle source
# File lib/repobrowse/git_atom.rb, line 72
def each
  entry_end = '</pre></div></content></entry>'
  tmp = @buf
  @buf = nil
  yield tmp
  tmp.clear
  tmp = entry_body
  yield tmp
  tmp.clear
  yield entry_end
  while tmp = entry_begin
    yield tmp
    tmp.clear
    tmp = entry_body
    yield tmp
    tmp.clear
    yield entry_end
  end
  yield '</feed>'
end
entry_begin(updated = +'') click to toggle source
# File lib/repobrowse/git_atom.rb, line 42
    def entry_begin(updated = +'')
      x40 = @rd.gets(chomp: true) or return
      +<<~EOF
        <entry><title>#{ # %s
          xt(@rd.gets(chomp: true))
        }</title><updated>#{ # %ct
          updated.replace(Time.at(@rd.gets.to_i).strftime(DATEFMT))
        }</updated><author><name>#{ # %an
          xt(@rd.gets(chomp: true))
        }</name><email>#{ # %ae
          xt(@rd.gets(chomp: true))
        }</email></author><published>#{ # %at
          Time.at(@rd.gets.to_i).strftime(DATEFMT)
        }</published><link
        rel="alternate"
        type="text/html"
        href=#{xa("#@url/" + x40)
        }/><id>#{x40}</id><content
        type="xhtml"><div
        xmlns="http://www.w3.org/1999/xhtml"><pre
        style="white-space:pre-wrap">
      EOF
    end
entry_body() click to toggle source
# File lib/repobrowse/git_atom.rb, line 66
def entry_body
  tmp = @rd.gets("\0\n", chomp: true)
  tmp.strip!
  xt(tmp)
end