Sha256: d8ba86d7e6a6dc48517fa0d7778beb6df44d6add35209d659cb6265059127090
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true require 'xommelier/atom' require 'xommelier/atom/threading' require 'active_support/core_ext' include Xommelier::Atom # Reading a feed feed = 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 = Feed.new feed.id = 'http://example.com/blog' feed.title = 'Example.com blog' feed.complete = History::Complete.new entry = feed.entry = Entry.new( id: 'http://example.com/blog/2012/03/05', title: 'Happy Xommelier\'s day!', updated: 5.days.ago ).tap do |entry| entry.link = Link.new(href: entry.id, rel: 'alternate', type: 'text/html') entry.links << Link.new(href: "#{entry.id}/comments.atom", rel: 'replies', type: 'application/atom+xml', count: 5) end # Add Comments 5.times do |i| feed.entries << 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 = Threading::InReplyTo.new(ref: entry.id, href: entry.link.href) end end puts feed.to_xml
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
xommelier-0.1.35 | example/atom.rb |