# * George Moschovitis # (c) 2005 Navel, all rights reserved. # $Id$ # WARNING: unfinished code, do NOT use yet. require 'nitro/builders/xml' module Nitro # Build Atom represenations of ruby object collections. # Utilize duck typing to grab the attributes to render. # Add this mixin to you classes to support Atom # syndication. module AtomBuilderMixin include XmlBuilderMixin # Build Atom syndication stream. # # === Options # # [+:description+] # Description of the feed. # [+:encoding+] # Character encoding. # [+:base+] # Base url of the feed. # [+:link+] # Link of the Feed. def build_atom(objects, options = {}) c = { :description => 'Syndication', :encoding => 'utf-8' }.update(options) c[:base] ||= c[:link] raise "Option ':base' cannot be infered!" unless c[:base] pi! :xml, :version => '1.0', :encoding => o[:encoding] feed(:version => '0.3') do for obj in objects entry do if obj.respond_to?(:author) author { name(obj.author) } end issued obj.create_time.xmlschema modified obj.update_time.xmlschema title obj.title if obj.respond_to?(:categories) for category in categories dc :subject => category.name end end end end end end end # Abstract class for the AtomBuilderMixin. class AtomBuilder < String include AtomBuilderMixin class << self def build(objects, options = {}) AtomBuilder.new.build_atom(objects, options) end end end end