diff --git a/Rakefile b/Rakefile index e3491cc..1b9ad00 100644 --- a/Rakefile +++ b/Rakefile @@ -10,58 +10,58 @@ PKG_VERSION = `ruby -Ilib -rfeed2imap/feed2imap -e 'print F2I_VERSION'` PKG_FILES = [ 'ChangeLog', 'README', 'COPYING', 'setup.rb', 'Rakefile'] Find.find('bin/', 'lib/', 'test/', 'data/') do |f| - if FileTest.directory?(f) and f =~ /\.svn/ - Find.prune - else - PKG_FILES << f - end + if FileTest.directory?(f) and f =~ /\.svn/ + Find.prune + else + PKG_FILES << f + end end Rake::TestTask.new do |t| - t.libs << "libs/feed2imap" - t.libs << "test" - t.test_files = FileList['test/tc_*.rb'] - ['test/tc_httpfetcher.rb'] + t.verbose = true + t.libs << "test" + t.test_files = FileList['test/tc_*.rb'] - ['test/tc_httpfetcher.rb'] end RDoc::Task.new do |rd| - rd.main = 'README' - rd.rdoc_files.include('lib/*.rb', 'lib/feed2imap/*.rb') - rd.options << '--all' + rd.main = 'README' + rd.rdoc_files.include('lib/*.rb', 'lib/feed2imap/*.rb') + rd.options << '--all' rd.options << '--diagram' rd.options << '--fileboxes' rd.options << '--inline-source' rd.options << '--line-numbers' - rd.rdoc_dir = 'rdoc' + rd.rdoc_dir = 'rdoc' end Rake::PackageTask.new(PKG_NAME, PKG_VERSION) do |p| - p.need_tar = true - p.need_zip = true - p.package_files = PKG_FILES + p.need_tar = true + p.need_zip = true + p.package_files = PKG_FILES end # "Gem" part of the Rakefile begin - require 'rubygems/package_task' + require 'rubygems/package_task' - spec = Gem::Specification.new do |s| - s.platform = Gem::Platform::RUBY - s.summary = "RSS/Atom feed aggregator" - s.name = PKG_NAME - s.version = PKG_VERSION - s.add_runtime_dependency 'ruby-feedparser', '>= 0.9' - s.require_path = 'lib' - s.executables = PKG_FILES.grep(%r{\Abin\/.}).map { |bin| - bin.gsub(%r{\Abin/}, '') - } - s.files = PKG_FILES - s.description = "RSS/Atom feed aggregator" - s.authors = ['Lucas Nussbaum'] - end + spec = Gem::Specification.new do |s| + s.platform = Gem::Platform::RUBY + s.summary = "RSS/Atom feed aggregator" + s.name = PKG_NAME + s.version = PKG_VERSION + s.add_runtime_dependency 'ruby-feedparser', '>= 0.9' + s.require_path = 'lib' + s.executables = PKG_FILES.grep(%r{\Abin\/.}).map { |bin| + bin.gsub(%r{\Abin/}, '') + } + s.files = PKG_FILES + s.description = "RSS/Atom feed aggregator" + s.authors = ['Lucas Nussbaum'] + end - Gem::PackageTask.new(spec) do |pkg| - pkg.need_zip = true - pkg.need_tar = true - end + Gem::PackageTask.new(spec) do |pkg| + pkg.need_zip = true + pkg.need_tar = true + end rescue LoadError puts "Will not generate gem." end diff --git a/lib/feed2imap/config.rb b/lib/feed2imap/config.rb index 693d2d6..3b77c15 100644 --- a/lib/feed2imap/config.rb +++ b/lib/feed2imap/config.rb @@ -68,6 +68,7 @@ @imap_accounts = ImapAccounts::new maildir_account = MaildirAccount::new @conf['feeds'].each do |f| + f['name'] = f['name'].to_s if f['disable'].nil? uri = URI::parse(Array(f['target']).join('')) path = URI::unescape(uri.path) diff --git a/lib/feed2imap/feed2imap.rb b/lib/feed2imap/feed2imap.rb index 64663c6..529c823 100644 --- a/lib/feed2imap/feed2imap.rb +++ b/lib/feed2imap/feed2imap.rb @@ -18,7 +18,7 @@ =end # Feed2Imap version -F2I_VERSION = '1.2.3' +F2I_VERSION = '1.2.4' F2I_WARNFETCHTIME = 10 require 'feed2imap/config' @@ -130,7 +130,7 @@ # thread-safe, and we need to get the right exitcode mutex.lock s = %x{#{feed.execurl}} - if $?.exitstatus != 0 + if $? && $?.exitstatus != 0 @logger.warn("Command for #{feed.name} exited with status #{$?.exitstatus} !") end mutex.unlock @@ -143,22 +143,25 @@ # thread-safe, and we need to get the right exitcode. mutex.lock # hack hack hack, avoid buffering problems - stdin, stdout, stderr = Open3::popen3(feed.filter) - inth = Thread::new do - stdin.puts s - stdin.close - end - output = nil - outh = Thread::new do - output = stdout.read - end - inth.join - outh.join - s = output - if $?.exitstatus != 0 - @logger.warn("Filter command for #{feed.name} exited with status #{$?.exitstatus}. Output might be corrupted !") - end - mutex.unlock + begin + stdin, stdout, stderr = Open3::popen3(feed.filter) + inth = Thread::new do + stdin.puts s + stdin.close + end + output = nil + outh = Thread::new do + output = stdout.read + end + inth.join + outh.join + s = output + if $? && $?.exitstatus != 0 + @logger.warn("Filter command for #{feed.name} exited with status #{$?.exitstatus}. Output might be corrupted !") + end + ensure + mutex.unlock + end end if Time::now - fetch_start > F2I_WARNFETCHTIME @logger.info("Fetching feed #{feed.name} took #{(Time::now - fetch_start).to_i}s") diff --git a/test/tc_config.rb b/test/tc_config.rb index 255bdb7..8d5353c 100755 --- a/test/tc_config.rb +++ b/test/tc_config.rb @@ -54,6 +54,15 @@ url: http://something target: [ *target, "feed1" ] EOF +CONFINTNAME = <