On 6/14/06, Kouhei Sutou <kou / cozmixng.org> wrote:
> In <9e7db9110606140759y89c73bet614a9b1708de4186 / mail.gmail.com>
>   "Re: [ANN] rubyrss-1.0" on Wed, 14 Jun 2006 23:59:25 +0900,
>   "Austin Ziegler" <halostatue / gmail.com> wrote:
>> Inasmuch as it is possible, I really think that the RSS libraries
>> should implement a generic RSS-style description framework and then
>> have version-specific generators.
>
> rss/maker standard distributed library may have features
> what you want. What you want features are showed by the
> following code?
>
>   def setup_maker(maker)
>     maker.channel.XXX = XXX
>     ...
>     item = maker.items.new_item
>     # We can set content:encoded whenever specified version
>     # is "0.91", "1.0" or "2.0". If specified version is
>     # "0.91" or "2.0", the value is just ignored.
>     item.content_encoded = XXX
>     ...
>   end
>
>   ["0.91", "1.0", "2.0"].each do |version|
>     rss = RSS::Maker.make(version) do |maker|
>       setup_maker(maker)
>     end
>     File.open("#{veresion}.xml", "w") do |f|
>       f.print(rss.to_s)
>     end
>   end

I'm thinking more something like:

  rss = RSS.new do |r|
    r.channel.XXX = XXX
	...
	r.items.new_item do |i|
	  i.content_encoded = YYY
	end
	...
  end

  %w(0.91 1.0 2.0).each do |version|
    File.open("#{version}.xml", "w") do |f|
	  f.print(rss.to_xml(version))
	end
  end

The difference is that you create three "external" objects to satisfy
0.91, 1.0, and 2.0. I would create one "external" object and create
other objects on-the-fly. This might be:

  class RSS
    def to_xml(version = nil)
	  version ||= @default_version
	  rss.to_version(version).to_xml
	end
  end

Similarly, it would be nice to have something like:

  rss = RSS.from_file("0.91.xml")
  File.open("2.0.xml") { |f| f.print rss.to_xml("2.0") }

> I may not understand what you mean. Can I satisfy you?

Probably not, but that's because I'm not really looking to use an RSS
class to generate RSS these days; I really have become convinced that
templates are the right answer.

The above, however, is the direction I was headed when I was working on
an RSS library, and I still think that it's the right direction. I
shouldn't have to care what *version* I'm in until I output and if I
specify a version on object creation, it should be advisory only (or the
default output version, as shown above).

-austin
-- 
Austin Ziegler * halostatue / gmail.com * http://www.halostatue.ca/
               * austin / halostatue.ca * http://www.halostatue.ca/feed/
               * austin / zieglers.ca