I'm not really creating a rails app, but may integrate this with rails down the road.
I've adapted rss2mysql.rb from: Practical Ruby Gems http://www.apress.com/book/view/9781590598115 Chapter 10, parsing feeds but am tweaking everything. Currently I have a rakefile, but am a bit unclear about what sort of tasks go in there. For instance, grabbing rss data from the interwebs could be a task, so maybe it should go in the rake file? Also, the rake file should have provisions to add/drop tables? I started to put some of the db interactions into the rakefile, and then thought that maybe everything in this file (script?) belongs in a rakefile. Where do you draw the line? thu...@arrakis:~/rb$ thu...@arrakis:~/rb$ cat rss2mysql.rb require 'rubygems' require 'active_record' require 'feed_tools' require 'yaml' db = YAML.load_file("database.yml") ActiveRecord::Base.establish_connection( :adapter => db["adapter"], :host => db["host"], :username => db["username"], :password => db["password"], :database => db["database"]) class Item < ActiveRecord::Base end unless Item.table_exists? ActiveRecord::Schema.define do create_table :items do |t| t.column :title, :string t.column :content, :string t.column :source, :string t.column :url, :string t.column :timestamp, :timestamp t.column :keyword_id, :integer t.column :guid, :string t.column :html, :string end end end puts "connected" #feed = FeedTools::Feed.open('http://www.slashdot.org/index.rss') feed = FeedTools::Feed.open('www.amazon.com/rss/tag/blu-ray/new') feed.items.each do |feed_item| if not (Item.find_by_title(feed_item.title) \ or Item.find_by_url(feed_item.link) \ or Item.find_by_guid(feed_item.guid)) puts "processing item '#{feed_item.title}' - new" Items.new do |newitem| newitem.title=feed_item.title.gsub(/<[^>]*>/, '') newitem.guid=feed_item.guid if feed_item.publisher.name newitem.source=feed_item.publisher.name end newitem.url=feed_item.link newitem.content=feed_item.description newitem.timestamp=feed_item.published newitem.save end else puts "processing item '#{feed_item.title}' - old" end end thu...@arrakis:~/rb$ Also, what sort of IDE is popular for ruby? Eclipse? thanks, Thufir --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---