aboutsummaryrefslogtreecommitdiff
blob: 5991f45c62fadac9bfb2cbc5b0c58f94e65fd3c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
@feed_id ||= nil

atom_feed(id: atom_id(@feed_type, @feed_id, 'feed')) do |feed|
  feed.title @feed_title
  feed.updated !@changes.empty? ? @changes.first.created_at : Time.now

  feed.author do |author|
    author.name 'Gentoo Packages Database'
  end

  @changes.each do |change|
    atom = cp_to_atom change.category, change.package
    package = Package.find_by :atom, atom
    if package.nil?
      logger.warn "Package for change (#{change}) nil!"
      next
    end

    id = atom
    id += '-%s' % change.version if change[:version]
    id += '-%s' % change.arches.join(',') if change[:arches]

    feed.entry(
      change,
      id: atom_id(@feed_type, @feed_id, id),
      url: absolute_link_to_package(atom)) do |entry|
      entry.updated change.created_at.to_datetime.rfc3339

      case @feed_type
      when :added
        entry.title(t :feed_added_title,
                      atom: atom,
                      description: package.description)
        entry.content(t :feed_added_content,
                        atom: atom,
                        arches: package.latest_version.keywords.join(', '))
      when :updated
        entry.title(t :feed_updated_title,
                      atom: atom_add_version(atom, change.version),
                      description: package.description)
        entry.content(t :feed_updated_content,
                        atom: change.version)
      when :stable
        entry.title(t :feed_stable_title,
                      atom: atom_add_version(atom, change.version),
                      description: package.description)
        entry.content(t :feed_stable_content,
                        atom: atom,
                        arches: change.arches.join(', '))
      when :keyworded
        entry.title(t :feed_keyworded_title,
                      atom: atom_add_version(atom, change.version),
                      description: package.description)
        entry.content(t :feed_keyworded_content,
                        atom: atom,
                        arches: change.arches.join(', '))
      end
    end
  end
end