require 'date' def entry(line) valid = (/=>.* (?\d\d\d\d-\d\d-\d\d) (?.*)/ =~ line) return date, title if valid end def genAtomEntry(line) (date, title) = entry line unless date.nil? or title.nil? '<entry>'\ '<updated>' + date + 'T12:00:00Z</updated>'\ '<title>' + title + ''\ 'gemini://flume.space/gemlog/' + date + '.gmi'\ ''\ '' end end def genAtomFeed(lines) ''\ ''\ 'mpm\'s gemlog'\ ''\ ''\ 'genfeed.rb'\ 'gemini://flume.space/'\ 'mpm'\ '' + DateTime.now.to_s + ''\ + lines.map {|x| genAtomEntry x}.join("") + '' end File.open('atom.xml', 'w') do |f| f.write genAtomFeed(File.open('index.gmi', 'r').readlines) end