summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlnu <lnu@f70e237a-67f3-0310-a06c-d2b8a7116972>2005-04-05 14:40:15 +0000
committerlnu <lnu@f70e237a-67f3-0310-a06c-d2b8a7116972>2005-04-05 14:40:15 +0000
commitedd60fa2d3c972932da7be1605fec2674069c31b (patch)
treea29b21e1022d5d36c065bf558bbe44eee36f611d
parent3417edeaabcb2e23bb0d13d984e353385d183f82 (diff)
downloadfeed2imap-edd60fa2d3c972932da7be1605fec2674069c31b.tar.gz
feed2imap-edd60fa2d3c972932da7be1605fec2674069c31b.tar.bz2
feed2imap-edd60fa2d3c972932da7be1605fec2674069c31b.zip
git-svn-id: svn+ssh://svn.gna.org/svn/feed2imap/trunk/feed2imap@11 f70e237a-67f3-0310-a06c-d2b8a7116972
-rw-r--r--lib/feed2imap/config.rb1
-rw-r--r--lib/feed2imap/feed2imap.rb25
2 files changed, 17 insertions, 9 deletions
diff --git a/lib/feed2imap/config.rb b/lib/feed2imap/config.rb
index 002db3e..a784b91 100644
--- a/lib/feed2imap/config.rb
+++ b/lib/feed2imap/config.rb
@@ -70,6 +70,7 @@ end
# A configured feed. simple data container.
class ConfigFeed
attr_reader :name, :url, :imapaccount, :folder
+ attr_accessor :body
def initialize(name, url, imapaccount, folder)
@name, @url, @imapaccount, @folder = name, url, imapaccount, folder
diff --git a/lib/feed2imap/feed2imap.rb b/lib/feed2imap/feed2imap.rb
index 92cab8f..3131587 100644
--- a/lib/feed2imap/feed2imap.rb
+++ b/lib/feed2imap/feed2imap.rb
@@ -69,22 +69,26 @@ class Feed2Imap
exit(1)
end
end
- # for each feed, fetch, upload to IMAP and cache
+ # check that IMAP folders exist
+ @logger.info("Checking IMAP folders")
@config.feeds.each do |f|
- @logger.info("Processing #{f.url}")
begin
- # check that folder exist
f.imapaccount.create_folder(f.folder) if not f.imapaccount.folder_exist?(f.folder)
rescue
@logger.fatal("Error while creating IMAP folder #{f.folder}: #{$!}")
exit(1)
end
+ end
+ # for each feed, fetch, upload to IMAP and cache
+ @logger.info("Fetching feeds")
+ @config.feeds.each do |f|
+ @logger.info("Processing #{f.name}")
begin
- body = HTTPFetcher::fetch(f.url, @cache.get_last_check(f.name))
+ f.body = HTTPFetcher::fetch(f.url, @cache.get_last_check(f.name))
# dump if requested
if @config.dumpdir
fname = @config.dumpdir + '/' + f.name + '-' + Time::now.xmlschema
- File::open(fname, 'w') { |file| file.puts body }
+ File::open(fname, 'w') { |file| file.puts f.body }
end
rescue Timeout::Error
@logger.fatal("Timeout::Error while fetching #{f.url}: #{$!}")
@@ -93,17 +97,20 @@ class Feed2Imap
@logger.fatal("Error while fetching #{f.url}: #{$!}")
next
end
- next if body.nil? # means 304
+ end
+ @logger.info("Parsing and uploading")
+ @config.feeds.each do |f|
+ next if f.body.nil? # means 304
begin
- channel = Channel::new(body)
+ channel = Channel::new(f.body)
rescue
- @logger.fatal("Error while parsing #{f.url}: #{$!}")
+ @logger.fatal("Error while parsing #{f.name}: #{$!}")
next
end
begin
newitems, updateditems = @cache.get_new_items(f.name, channel.items)
rescue
- @logger.fatal("Exception caught when selecting new items for #{f.url}: #{$!}")
+ @logger.fatal("Exception caught when selecting new items for #{f.name}: #{$!}")
puts $!.backtrace
next
end
hers/feed2imap.git/commit/test/ts_feed2imap.rb?h=ruby22&id=88cafc4e8838d5969486101e0bd96aafd7581fa1&follow=1'>Remove deprecated 'test suite' fileAntonio Terceiro1-12/+0 I want to always run all tests 2015-01-13Rakefile: re-indentAntonio Terceiro1-35/+35 2015-01-13Rakefile: run tests in verbose modeAntonio Terceiro1-1/+2 2014-10-071.2.3 releaseAntonio Terceiro1-1/+1 2014-10-07Fix cleanup of maildirsAntonio Terceiro3-1/+16 Thanks to Sylvain L. Sauvage for the bug report 2014-05-18feed2imap-test: reuse cache dir/protect configAntonio Terceiro1-1/+1 this reduces the noise in the output and helps testing feed updates 2014-02-13feed2imap-test: can now take a feed URL as argumentAntonio Terceiro1-3/+22 2014-02-13update .gitignoreAntonio Terceiro1-0/+2 2014-02-13fix dependency on ruby-feedparserAntonio Terceiro1-1/+1 2014-02-05Release 1.2.2Antonio Terceiro2-2/+2 2014-02-05config: fix regression with arrays as targetAntonio Terceiro2-1/+17 2013-08-28Fix teardown method nameAntonio Terceiro1-1/+1