Sha256: 0a9212443379151f2bafed770bf4da122d43fb8c2e67fbf621e62100739de7d1

Contents?: true

Size: 1.26 KB

Versions: 13

Compression:

Stored size: 1.26 KB

Contents

require 'xommelier/atom'
require 'xommelier/atom/threading'
require 'active_support/core_ext'

# Reading a feed
feed = Xommelier::Atom::Feed.parse(open('spec/fixtures/feed.atom.xml'))
puts feed.id, feed.title, feed.updated

feed.entries do |entry|
  puts entry.id, entry.title, entry.published, entry.updated
  puts entry.content || entry.summary
end

# Building a feed
feed = Xommelier::Atom::Feed.new
feed.id = 'http://example.com/blog'
feed.title = 'Example.com blog'
feed.complete = Xommelier::Atom::History::Complete.new

entry = feed.entry = Xommelier::Atom::Entry.new(
  id: 'http://example.com/blog/2012/03/05',
  title: 'Happy Xommelier\'s day!',
  updated: 5.days.ago
).tap do |entry|
  entry.link = Xommelier::Atom::Link.new(href: entry.id, rel: 'alternate', type: 'text/html')
  entry.links << Xommelier::Atom::Link.new(href: "#{entry.id}/comments.atom", rel: 'replies', type: 'application/atom+xml', count: 5)
end

# Add Comments
5.times do |i|
  feed.entries << Xommelier::Atom::Entry.new(
    id: "http://example.com/blog/2012/03/05#comment_#{i}",
    title: ('Hooray! ' * (i + 1)).strip,
    updated: (5 - i).days.ago
  ).tap do |comment|
    comment.in_reply_to = Xommelier::Atom::Threading::InReplyTo.new(ref: entry.id, href: entry.link.href)
  end
end

puts feed.to_xml

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
xommelier-0.1.32 examples/atom.rb
xommelier-0.1.31 examples/atom.rb
xommelier-0.1.30 examples/atom.rb
xommelier-0.1.29 examples/atom.rb
xommelier-0.1.28 examples/atom.rb
xommelier-0.1.27 examples/atom.rb
xommelier-0.1.26 examples/atom.rb
xommelier-0.1.25 examples/atom.rb
xommelier-0.1.24 examples/atom.rb
xommelier-0.1.23 examples/atom.rb
xommelier-0.1.22 examples/atom.rb
xommelier-0.1.21 examples/atom.rb
xommelier-0.1.20 examples/atom.rb