Skip to content

Instantly share code, notes, and snippets.

@julien51
Created April 27, 2009 04:51
Show Gist options
  • Save julien51/102336 to your computer and use it in GitHub Desktop.
Save julien51/102336 to your computer and use it in GitHub Desktop.
require "rubygems"
require "eventmachine"
require "lib/babylon.rb"
Babylon.views["view.xml.builder"] = <<-EOXML
xml.iq(:to => @from, :type => :result, :id => @iq_id) do |iq|
iq.pubsub(:xmlns => "http://jabber.org/protocol/pubsub") do |pubsub|
pubsub.publish(:node => @feed_url) do |publish|
@entries.each do |e|
publish.item(:id => e[:unique_id])
end
end
end
end
@subscribers.each do |subscriber|
xml.message(:to => subscriber[:jid]) do |message|
message.event(:xmlns => "http://jabber.org/protocol/pubsub#event") do |event|
event.items("node" => @feed_url) do |items|
@entries.each do |e|
items.item do |item|
item.entry(:xmlns => 'http://www.w3.org/2005/Atom') do |entry|
entry.title(e[:title])
entry.summary(e[:summary])
entry.link(:rel =>'alternate', :type => 'text/html', :href => "http://superfeedr.com/entries/e[:id]")
entry.published(e[:published])
entry.id_(e[:unique_id])
end
end
end
end
end
end
end
EOXML
loop do
Babylon.logger.info "MEMORY: #{Integer(`ps -o rss= -p #{Process.pid}`)}"
view = Babylon::Base::View.new("view.xml.builder", {:from => "me", :feed_url => "http://...", :subscribers => [{:jid => "toto"}, {:jid => "titi"}], :entries => [{:unique_id => "123", :title => "salut chamo", :summary => "ca farte?", :id => "9", :published => "23:34:56"}, {:unique_id => "1213", :title => "resalut chamo", :summary => "cazda azeae azefarte?", :id => "19", :published => "1221323:34:56"}, {:unique_id => "12mam3", :title => "azdazdazd azdnazd azdazd azdazdsalut chamo", :summary => "caazdazdma lpakzepaze pae maze farte?", :id => "65", :published => "mamapal23:34:56"}]})
view.evaluate
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment