# Rss-client-2.0.9

**URL:** <https://www.ruby-forum.com/t/rss-client-2-0-9/126682>\
**Category:** Ruby\
**Created:** [January 21, 2008, 11:05am UTC](https://www.ruby-forum.com/t/rss-client-2-0-9/126682 "2008-01-21T11:05:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stoyan\_Z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@Stoyan\_Z](https://www.ruby-forum.com/u/Stoyan_Z)\
**Post date:** [January 21, 2008, 11:05am UTC](https://www.ruby-forum.com/t/rss-client-2-0-9/126682/1 "2008-01-21T11:05:54Z")

</div>

ABOUT  
Fetching and parsing RSS feeds with easy. Ruby library (mixin) for  
adding RSS feeds download  
and parsing functionality. The RSS fetch command line utility, using  
the library is also included.

DEPENDS  
feed-normalizer for the RSS feeds parsing.

URIs  
Homepage: [http://rubyforge.org/projects/rss-client](http://rubyforge.org/projects/rss-client)  
Download: [http://rubyforge.org/frs/?group\_id=5309](http://rubyforge.org/frs/?group_id=5309)  
SVN: svn checkout [http://rss-client.rubyforge.org/svn/](http://rss-client.rubyforge.org/svn/)  
Mercurial: hg clone [Error 404: File Not Found | Assembla](http://hg.assembla.com/rss-client) rss-client

I’m using mostly mercurial, so you can follow the development on:

[Error 404: File Not Found | Assembla](http://trac-hg.assembla.com/rss-client/)

Only releases/gems will be posted to rubyforge. Some main milestones/  
bug fixes will be commited  
to the rubyforge SVN.

INSTALLATION

Normal Installation  
You can install rss-client with the following command:

$ ruby install.rb

from its distribution directory.

GEM Installation  
Download and install rss-client with the following:

$ gem install --remote rss-client

COMMAND LINE UTILITY USAGE  
$ rssclient [options] feed\_url

Options  
-h, --help Displays help message  
-V, --version Display the version, then exit  
-q, --quiet Output as little as possible, overrides verbose  
-v, --verbose Verbose output  
-p, --proxy Use proxy (format [http://user:pass@address](http://user:pass@address):port  
)  
-r, --raw Use raw RSS fetch (no error code processing)  
-g, --giveup Giveup on fetching after timeout (seconds)  
-f, --force Force fresh feed fetch (no 304 code processing)  
-s, --since Only changes from {since} seconds ago

Examples  
$ rssclient -q [http://example.com/atom.xml](http://example.com/atom.xml)  
$ rssclient -r -f [http://test:removed\_email\_address@domain.invalid/atom.xml](http://test:removed_email_address@domain.invalid/atom.xml)  
$ rssclient --verbose [http://example.com/atom.xml](http://example.com/atom.xml)  
$ rssclient --giveup 20 -f [http://example.com/atom.xml](http://example.com/atom.xml)  
$ rssclient --since 600 [http://example.com/atom.xml](http://example.com/atom.xml)  
$ rssclient -f -p [http://aa:bb@localhost:8088](http://aa:bb@localhost:8088)  
[http://example.com/atom.xml](http://example.com/atom.xml)

LIBRARY USAGE IN YOUR OWN RUBY CLASSES  
The main method the library exports is:

get\_feed(url, opts)

where,

url - string with the feed url  
opts - OpenStruct with options (see the example below)

The method returns the output from the FeedNormalizer.parse() on  
sucess and nil on failure/not modified.  
The raw feed is saved in @rssc\_raw for future processing  
The method handles:

- successful download (200) - @rssc\_raw have the original feed and  
the output from the method is the  
parsed one.
- not modidied (304) - returns nil and 304 in the @rssc\_raw.status
- redirects (301, 302) - automaticaly redirect to the new url and  
trying to fetch the feed again

Example  
require 'rss-client

class Feed  
include RSSClient

```
def fetch
  opts = OpenStruct.new
  opts.forceUpdate = false # set true to force the download (no

```

304 code handling)  
opts.giveup = 10 # on error giveup after 10 sec timeout

```
  rss = get_feed('http://rubyforge.org/export/

```

rss\_sfnews.php’,opts)  
return nil unless @rssc\_raw # download error  
return 304 if @rssc\_raw.status == 304 # feed not modified  
return nil unless rss # error in parsing

```
  # some title, items etc. processing
  self.title = rss.channel.title.to_s
  self.description = rss.channel.description.to_s
  rss.entries.each do |i|
    ...
  end
end

```

end

get\_feed() using get\_url(url, opts) method, which in turn is powered  
by HTTPAccess2::Client.  
get\_url() can be used for low-level connection debugging (the -r  
option in the command line  
utility). get\_url() example output for  
[http://rubyforge.org/export/rss\_sfnews.php:](http://rubyforge.org/export/rss_sfnews.php:)

$ rssclient -r [http://rubyforge.org/export/rss\_sfnews.php](http://rubyforge.org/export/rss_sfnews.php)  
Status code: 200  
Headers:

- Status: 200 OK
- Date: Mon, 21 Jan 2008 09:37:00 GMT
- Server: Apache
- X-Powered-By: PHP/4.4.8
- Vary: Accept-Encoding
- Connection: close
- Transfer-Encoding: chunked
- Content-Type: text/plain
- Content-Length: 0
- Content-Type: text/html; charset=us-ascii

CREDITS  
Hiroshi N. - For the http-access2 library.  
Todd W. - For the ruby command-line application skeleton

LICENSE  
rss-client is available under an MIT-style license.

And one question/problem: when installed with ‘ruby install.rb’ the ‘-  
h’ option properly displaying  
the help/usage. When installed via gems, ‘-h’ returns:

rssclient version 2.0.9  
This file was generated by RubyGems.

The application ‘rss-client’ is installed as part of a gem, and this  
file is here to facilitate running it.

---

<div class="post-metadata">

**Author:** ![Stoyan\_Z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@Stoyan\_Z](https://www.ruby-forum.com/u/Stoyan_Z)\
**Post date:** [January 22, 2008, 3:05am UTC](https://www.ruby-forum.com/t/rss-client-2-0-9/126682/2 "2008-01-22T03:05:13Z")

</div>

I tried to use the latest rss-client in a Rails app and I get the  
following error:

undefined method `new' for class`Class’  
RAILS\_ROOT: /home/998640e2/web/apple/config/…

Application Trace | Framework Trace | Full Trace  
/opt/local/lib/ruby/gems/1.8/gems/rss-client-2.0.9/lib/rss-client/http-access2/http.rb:393  
/opt/local/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem_original_require' /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’  
/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active\_support/dependencies.rb:495:in  
`require' /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:342:in`new\_constants\_in’  
/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active\_support/dependencies.rb:495:in  
`require' /opt/local/lib/ruby/gems/1.8/gems/rss-client-2.0.9/lib/rss-client/http-access2.rb:21 /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`gem\_original\_require’  
/opt/local/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`require' /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:495:in`require’  
/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active\_support/dependencies.rb:342:in  
`new_constants_in' /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:495:in`require’  
/opt/local/lib/ruby/gems/1.8/gems/rss-client-2.0.9/lib/rss-client.rb:3  
/opt/local/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem_original_require' /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’  
/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active\_support/dependencies.rb:495:in  
`require' /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:342:in`new\_constants\_in’  
/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active\_support/dependencies.rb:495:in  
`require' /home/998640e2/web/apple/app/controllers/rss_controller.rb:1 /opt/local/bin/mongrel_rails:16:in`load’  
/opt/local/bin/mongrel\_rails:16  
This error occurred while loading the following files:  
rss-client  
rss-client/http-access2  
rss-client/http-access2/http

I installed the gem as described. Ruby version 1.8.6

Any ideas?

Nick.

---

<div class="post-metadata">

**Author:** ![Stoyan\_Z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@Stoyan\_Z](https://www.ruby-forum.com/u/Stoyan_Z)\
**Post date:** [January 22, 2008, 4:21am UTC](https://www.ruby-forum.com/t/rss-client-2-0-9/126682/3 "2008-01-22T04:21:03Z")

</div>

On Jan 22, 11:05 am, Nick A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I tried to use the latest rss-client in a Rails app and I get the  
> following error:
> 
> undefined method `new' for class `Class’  
> RAILS\_ROOT: /home/998640e2/web/apple/config/…

I added an example rails application, using rss-client. Working for  
me. Untar, cd to it, rake db:migrate and start mongrel. Access to  
http://your\_url/feeds/ will give you the RubyGorge feed news.

[http://rubyforge.org/frs/download.php/31123/rssclient\_on\_rails.tgz](http://rubyforge.org/frs/download.php/31123/rssclient_on_rails.tgz)
