Package list feed2imap / upstream/1.2.4
Imported Upstream version 1.2.4 Antonio Terceiro 6 years ago
5 changed file(s) with 71 addition(s) and 64 deletion(s). Raw diff Collapse all Expand all
99 PKG_VERSION = `ruby -Ilib -rfeed2imap/feed2imap -e 'print F2I_VERSION'`
1010 PKG_FILES = [ 'ChangeLog', 'README', 'COPYING', 'setup.rb', 'Rakefile']
1111 Find.find('bin/', 'lib/', 'test/', 'data/') do |f|
12 if FileTest.directory?(f) and f =~ /\.svn/
13 Find.prune
14 else
15 PKG_FILES << f
16 end
12 if FileTest.directory?(f) and f =~ /\.svn/
13 Find.prune
14 else
15 PKG_FILES << f
16 end
1717 end
1818 Rake::TestTask.new do |t|
19 t.libs << "libs/feed2imap"
20 t.libs << "test"
21 t.test_files = FileList['test/tc_*.rb'] - ['test/tc_httpfetcher.rb']
19 t.verbose = true
20 t.libs << "test"
21 t.test_files = FileList['test/tc_*.rb'] - ['test/tc_httpfetcher.rb']
2222 end
2323
2424 RDoc::Task.new do |rd|
25 rd.main = 'README'
26 rd.rdoc_files.include('lib/*.rb', 'lib/feed2imap/*.rb')
27 rd.options << '--all'
25 rd.main = 'README'
26 rd.rdoc_files.include('lib/*.rb', 'lib/feed2imap/*.rb')
27 rd.options << '--all'
2828 rd.options << '--diagram'
2929 rd.options << '--fileboxes'
3030 rd.options << '--inline-source'
3131 rd.options << '--line-numbers'
32 rd.rdoc_dir = 'rdoc'
32 rd.rdoc_dir = 'rdoc'
3333 end
3434
3535 Rake::PackageTask.new(PKG_NAME, PKG_VERSION) do |p|
36 p.need_tar = true
37 p.need_zip = true
38 p.package_files = PKG_FILES
36 p.need_tar = true
37 p.need_zip = true
38 p.package_files = PKG_FILES
3939 end
4040
4141 # "Gem" part of the Rakefile
4242 begin
43 require 'rubygems/package_task'
43 require 'rubygems/package_task'
4444
45 spec = Gem::Specification.new do |s|
46 s.platform = Gem::Platform::RUBY
47 s.summary = "RSS/Atom feed aggregator"
48 s.name = PKG_NAME
49 s.version = PKG_VERSION
50 s.add_runtime_dependency 'ruby-feedparser', '>= 0.9'
51 s.require_path = 'lib'
52 s.executables = PKG_FILES.grep(%r{\Abin\/.}).map { |bin|
53 bin.gsub(%r{\Abin/}, '')
54 }
55 s.files = PKG_FILES
56 s.description = "RSS/Atom feed aggregator"
57 s.authors = ['Lucas Nussbaum']
58 end
45 spec = Gem::Specification.new do |s|
46 s.platform = Gem::Platform::RUBY
47 s.summary = "RSS/Atom feed aggregator"
48 s.name = PKG_NAME
49 s.version = PKG_VERSION
50 s.add_runtime_dependency 'ruby-feedparser', '>= 0.9'
51 s.require_path = 'lib'
52 s.executables = PKG_FILES.grep(%r{\Abin\/.}).map { |bin|
53 bin.gsub(%r{\Abin/}, '')
54 }
55 s.files = PKG_FILES
56 s.description = "RSS/Atom feed aggregator"
57 s.authors = ['Lucas Nussbaum']
58 end
5959
60 Gem::PackageTask.new(spec) do |pkg|
61 pkg.need_zip = true
62 pkg.need_tar = true
63 end
60 Gem::PackageTask.new(spec) do |pkg|
61 pkg.need_zip = true
62 pkg.need_tar = true
63 end
6464 rescue LoadError
6565 puts "Will not generate gem."
6666 end
6767 @imap_accounts = ImapAccounts::new
6868 maildir_account = MaildirAccount::new
6969 @conf['feeds'].each do |f|
70 f['name'] = f['name'].to_s
7071 if f['disable'].nil?
7172 uri = URI::parse(Array(f['target']).join(''))
7273 path = URI::unescape(uri.path)
1717 =end
1818
1919 # Feed2Imap version
20 F2I_VERSION = '1.2.3'
20 F2I_VERSION = '1.2.4'
2121 F2I_WARNFETCHTIME = 10
2222
2323 require 'feed2imap/config'
129129 # thread-safe, and we need to get the right exitcode
130130 mutex.lock
131131 s = %x{#{feed.execurl}}
132 if $?.exitstatus != 0
132 if $? && $?.exitstatus != 0
133133 @logger.warn("Command for #{feed.name} exited with status #{$?.exitstatus} !")
134134 end
135135 mutex.unlock
142142 # thread-safe, and we need to get the right exitcode.
143143 mutex.lock
144144 # hack hack hack, avoid buffering problems
145 stdin, stdout, stderr = Open3::popen3(feed.filter)
146 inth = Thread::new do
147 stdin.puts s
148 stdin.close
149 end
150 output = nil
151 outh = Thread::new do
152 output = stdout.read
153 end
154 inth.join
155 outh.join
156 s = output
157 if $?.exitstatus != 0
158 @logger.warn("Filter command for #{feed.name} exited with status #{$?.exitstatus}. Output might be corrupted !")
159 end
160 mutex.unlock
145 begin
146 stdin, stdout, stderr = Open3::popen3(feed.filter)
147 inth = Thread::new do
148 stdin.puts s
149 stdin.close
150 end
151 output = nil
152 outh = Thread::new do
153 output = stdout.read
154 end
155 inth.join
156 outh.join
157 s = output
158 if $? && $?.exitstatus != 0
159 @logger.warn("Filter command for #{feed.name} exited with status #{$?.exitstatus}. Output might be corrupted !")
160 end
161 ensure
162 mutex.unlock
163 end
161164 end
162165 if Time::now - fetch_start > F2I_WARNFETCHTIME
163166 @logger.info("Fetching feed #{feed.name} took #{(Time::now - fetch_start).to_i}s")
5353 url: http://something
5454 target: [ *target, "feed1" ]
5555 EOF
56 CONFINTNAME = <<EOF
57 parts: text
58 include-images: false
59 prefix: &target "maildir:///tmp/Maildir/"
60 feeds:
61 - name: 10
62 url: http://something
63 target: [ *target, "feed1" ]
64 EOF
5665
5766 class ConfigTest < Test::Unit::TestCase
5867 def test_cache
94103 assert_equal "/tmp/Maildir/feed1", conf.feeds.first.folder
95104 end
96105
106 def test_integer_as_name
107 sio = StringIO.new CONFINTNAME
108 conf = F2IConfig.new(sio)
109 assert_equal "10", conf.feeds.first.name
110 end
111
97112 end
+0
-12
test/ts_feed2imap.rb less more
0 #!/usr/bin/ruby -w
1
2 $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3 $:.unshift File.join(File.dirname(__FILE__), '..', 'test')
4 $:.unshift File.join(File.dirname(__FILE__), 'lib')
5 $:.unshift File.join(File.dirname(__FILE__), 'test')
6
7 require 'feed2imap'
8 require 'tc_cache'
9 require 'tc_config'
10 require 'tc_mail'
11 require 'tc_httpfetcher'