#! /usr/bin/env ruby require 'rubygems' rescue nil require 'yaml' require 'erb' require 'bluecloth' require 'time' stream = YAML.load_stream(ARGF.read) channel = stream[0] items = stream[1..-1] include ERB::Util template = ERB.new < <%= h channel['title'] %> <%= h channel['link'] %> <%= h channel['description'] %> <%= h Time.now.rfc822 %> yaml2rss <%= h channel['webMaster'] %> <% for item in items do title, date, body = item.split("\n",3) date = Time.parse(date) body = BlueCloth.new(body).to_html %> <%= h title %> <%= h body %> <%= h date.rfc822 %> <%= h "\#{channel['link']}?date=\#{date.iso8601}" %> <% end %> EOF puts template.result(binding)