y.zz...
Installing RDoc documentation for feedtools-x.y.zz...
You also need to create a database named company_pr and edit the establish_
connection line at the top of the following loader script. (However, note that this code
will automatically load a config/database.yml file if it exists, so if you run this application
from the Rails application directory you??™ll create later, you don??™t need to edit the
establish_connection line.)
Now create the loader script, as shown in Listing 11-1.
Listing 11-1. RSS Loader (rss_loader.rb)
require 'feed_tools'
require 'active_record'
require 'uri'
CHAPTER 11 n TRACKING THE NEWS WITH GOOGLE NEWS 217
(puts "usage: #{$0} query"; exit) unless ARGV.length==1
# If there's a config/database.yml file - like you'd find in a Rails app,
# read from that . . .
if File.exists?('./config/database.yml')
require 'yaml'
ActiveRecord::Base.establish_connection(
YAML.load(File.read('config/database.yml'))['development'])
else
# . . . otherwise, connect to the default settings.
Pages:
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312