Class: Vnews::Folder

Inherits:
Object
  • Object
show all
Defined in:
lib/vnews/folder.rb

Class Method Summary collapse

Class Method Details

.update_folder(folder) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/vnews/folder.rb', line 6

def self.update_folder(folder)
  if folder.strip == "Starred"
    puts "Sorry, you can't update the starred folder."
    return
  else
    require 'vnews/display'
    folder = Vnews::Display.strip_item_count(folder)
    puts "Updating folder: #{folder.inspect}"
    Vnews.sql_client.feeds_in_folder(folder.strip).each do |feed|
      begin
        Timeout::timeout(Vnews::TIMEOUT) do 
          feed_url, f, folder = *Vnews::Feed.fetch_feed(feed, folder)
          Vnews::Feed.save_feed feed_url, f, folder
        end
      rescue Timeout::Error
        puts "TIMEOUT ERROR: #{feed_url}"
      end
    end
    puts "\nDone"
  end
end