blob: 98cb3733ac6a69e336c9e1d592e139214a93817a (
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
|
module Gentoo
class PackagesGenerator < Jekyll::Generator
XML = '_data/packages.xml'
def generate(site)
xml = Nokogiri::XML(File.open(XML))
# atom is mainly one namespace
xml.remove_namespaces!
site.data['packages'] ||= { 'updates' => [] }
xml.xpath('/feed/entry').each do |item|
item_data = {}
item.children.each do |tag|
case tag.name
when 'title'
if tag.text =~ /^([^(]*) \((.*)\)$/
item_data['atom'] = $1.strip
item_data['atom_c'], item_data['atom_p'] = item_data['atom'].split('/', 2)
item_data['description'] = $2
end
when 'link'
item_data['uri'] = tag['href']
end
end
site.data['packages']['updates'] << item_data
end
end
end
end
|