Skip to content

Instantly share code, notes, and snippets.

@rgarner
rgarner / rss_aware_atom_feed_helper.rb
Created June 14, 2011 08:02
RSS-aware ATOM feed helper
##
# RSS-aware patched helper. See http://www.zephyros-systems.co.uk/blog/?p=179
#
require 'set'
module ActionView
# = Action View Atom Feed Helpers
module Helpers #:nodoc:
module AtomFeedHelper
# Adds easy defaults to writing Atom feeds with the Builder template engine (this does not work on ERb or any other
@rgarner
rgarner / gist:856304
Created March 5, 2011 11:35
dm-many-to-many weirdness
class Calendar
include DataMapper::Resource
has n, :events
property :id, Serial
property :slug, Slug
property :title, String
property :published, Boolean
property :created_at, DateTime
end
def consolidate(*issue_uris)
result = Nokogiri::XML.parse '<issues />'
issue_uris.each do |uri|
fetch_doc(uri).css('issue').each do |issue|
if issue.comments.content.to_i > 0 then
issue.comments.unlink
comments_doc = fetch_doc("#{@comments_base}/#{issue.number.content}")
comments_doc.comments.parent = issue
end