Forum: Ruby rubyrss-1.0

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Sergey T. (Guest)
on 2006-06-09 20:51
(Received via mailing list)
Dear Ruby community,

I'm glad to announce initial release of RubyRSS tool.
http://rubyforge.org/projects/rubyrss/

WHAT IS A RUBYRSS

Elegant as Ruby RSS parser and generator intended to help you bring
together Ruby and RSS in your project. Features include creation of
custom (x)HTML news blocks from remote RSS feeds, generation of
RSS-feeds using templates, and more.

HOW TO PARSE RSS-FEED

require "rubyrss"

rss = RubyRSS.new "http://www.games-mix.com/rss-feed.xml"
rss.parse


HOW TO GENERATE RSS-FEED

require "rubyrss"

rss = RubyRSS.new "rss-feed.xml"
rss.title = "Sample RSS-feed"
rss.link = "http://www.rubyrss.com"
rss.desc = "Sample RSS-feed generated by RubyRSS"
rss.date = Time.now.gmtime
1.upto(10) { |i|
  rss.items << RubyRSS::Item.new(
    "title-" + i.to_s,
    "#" + String(i),
    "description-#{i}",
    Time.now.gmtime
  )
}
rss.generate "rss2.0"

I'll be happy to hear your feedback.
Ezra Z. (Guest)
on 2006-06-10 00:21
(Received via mailing list)
Hi!

On Jun 9, 2006, at 9:50 AM, Sergey T. wrote:

> Dear Ruby community,
>
> I'm glad to announce initial release of RubyRSS tool.
> http://rubyforge.org/projects/rubyrss/
>
>
<snip>
> I'll be happy to hear your feedback.
>
> --
> Sincerely,
> Sergey T.
> http://dairon.net
>
>


Hey Sergey-

	Looks like a nice little package. But I think you overlooked one
thing. You need to mention in your README that your library requires
simple-rss  from rubyforge to be installed before your library will
work.


Cheers-
-Ezra
Sergey T. (Guest)
on 2006-06-10 06:35
(Received via mailing list)
Dear Ezra,

Thank you. I've added following info to README:

RubyRSS depends on SimpleRSS library. To install it you can
use following command:

> gem install simple-rss --remote

--
Sincerely,
Sergey T.
http://dairon.net


Original message (10.06.2006, 3:20) follows.

> Hey Sergey-

> 	Looks like a nice little package. But I think you overlooked one
> thing. You need to mention in your README that your library requires
> simple-rss  from rubyforge to be installed before your library will
> work.
Eric H. (Guest)
on 2006-06-11 08:54
(Received via mailing list)
On Jun 9, 2006, at 7:34 PM, Sergey T. wrote:

> use following command:
>
>  gem install simple-rss --remote

No.  Use rubygems' dependency feature.

--
Eric H. - removed_email_address@domain.invalid - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
Kouhei S. (Guest)
on 2006-06-11 20:26
(Received via mailing list)
Hi,

In <removed_email_address@domain.invalid>
  "[ANN] rubyrss-1.0" on Sat, 10 Jun 2006 01:50:00 +0900,
  Sergey T. <removed_email_address@domain.invalid> wrote:

>   rss.items << RubyRSS::Item.new(
>     "title-" + i.to_s,
>     "#" + String(i),
>     "description-#{i}",
>     Time.now.gmtime
>   )
> }
> rss.generate "rss2.0"


We can use RSS Maker standard distributed library:

  require 'rss/maker'

  rss = RSS::Maker.make("2.0") do |maker|
    maker.channel.title = "Sample RSS-feed"
    maker.channel.link = "http://www.rubyrss.com"
    maker.channel.description = "Smaple RSS-feed generated by RubyRSS"
    maker.channel.date = Time.now.gmtime
    1.upto(10) do |i|
      item = maker.items.new_item
      item.title = "title-#{i}"
      item.link = "##{i}"
      item.description = "description-#{i}"
      item.date = Time.now.gmtime
    end
  end

  File.open("rss-feed.xml", "w") do |f|
    f.print(rss.to_s)
  end


Thanks,
Austin Z. (Guest)
on 2006-06-14 19:01
(Received via mailing list)
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.

This is something that I was working on a few years ago, but I have
long-since decided that when I get back to working on Ruwiki, RSS will
be templatized. It's far easier to deal with templates than a full-on
RSS library.

-austin
Kouhei S. (Guest)
on 2006-06-14 20:08
(Received via mailing list)
Hi,

In <removed_email_address@domain.invalid>
  "Re: [ANN] rubyrss-1.0" on Wed, 14 Jun 2006 23:59:25 +0900,
  "Austin Z." <removed_email_address@domain.invalid> 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 may not understand what you mean. Can I satisfy you?


Thanks,
Austin Z. (Guest)
on 2006-06-14 20:31
(Received via mailing list)
On 6/14/06, Kouhei S. <removed_email_address@domain.invalid> wrote:
>
>
>   ["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
Kouhei S. (Guest)
on 2006-06-15 16:18
(Received via mailing list)
Hi,

In <removed_email_address@domain.invalid>
  "Re: [ANN] rubyrss-1.0" on Thu, 15 Jun 2006 01:29:29 +0900,
  "Austin Z." <removed_email_address@domain.invalid> wrote:

> 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

It seems good that items.new_item do ... end style. I'll
add codes that support your style to RSS Maker.

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

I see. I probably understand your idea. What about the
following idea:

  require 'rss'

  module RSS
    module RootElementMixin
      def to_xml(version=nil)
        if version.nil? or version == @rss_version
          to_s
        else
          RSS::Maker.make(version) do |maker|
            setup_maker(maker)
          end.to_s
        end
      end
    end
  end

  rss = RSS::Maker.make(...) do
    ...
  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


> 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") }

Now, we can write like the following:

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


If the above RSS::RootElementMixin#to_xml satisfies you,
I'll commit those changes to Ruby's CVS.


Thanks,
Austin Z. (Guest)
on 2006-06-15 16:32
(Received via mailing list)
On 6/15/06, Kouhei S. <removed_email_address@domain.invalid> wrote:
> If the above RSS::RootElementMixin#to_xml satisfies you,
> I'll commit those changes to Ruby's CVS.

I think it'd work. It'll save having to deal with the conversion and
extra objects until they are absolutely needed.

-austin
This topic is locked and can not be replied to.