Class: ImapFeeder
- Inherits:
-
Object
- Object
- ImapFeeder
- Defined in:
- lib/imap-feeder/version.rb,
lib/imap-feeder.rb
Overview
:nodoc:
Defined Under Namespace
Modules: VERSION
Instance Method Summary collapse
-
#initialize(server, store, config) ⇒ ImapFeeder
constructor
A new instance of ImapFeeder.
- #run ⇒ Object
Constructor Details
#initialize(server, store, config) ⇒ ImapFeeder
Returns a new instance of ImapFeeder.
12 13 14 15 16 |
# File 'lib/imap-feeder.rb', line 12 def initialize(server, store, config) @server = server @store = store @config = config end |
Instance Method Details
#run ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/imap-feeder.rb', line 18 def run $log.info "Started" feeds = YAML.load(@config) feeds.each do |feed| path = feed['feed']['path'] $log.info "Processing #{path}" create_folder(path) unless check_folder_exists(path) begin url = feed['feed']['url'] reader = FeedReader.new(url) rescue OpenURI::HTTPError => e $log.warn "Error retrieving #{url}: #{e.}" next rescue Exception => e $log.error "Unexpected error while retrieving #{path}: #{e.}" next end archive = get_archived(path) = reader.get_new(archive) unless .empty? $log.debug "already processed messages: '#{archive.join("', '")}'" (, path, reader.number_of_entries) end end $log.info "Finished" end |