Imported Upstream version 1.2.4
Antonio Terceiro
8 years ago
9 | 9 | PKG_VERSION = `ruby -Ilib -rfeed2imap/feed2imap -e 'print F2I_VERSION'` |
10 | 10 | PKG_FILES = [ 'ChangeLog', 'README', 'COPYING', 'setup.rb', 'Rakefile'] |
11 | 11 | 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 | |
17 | 17 | end |
18 | 18 | 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'] | |
22 | 22 | end |
23 | 23 | |
24 | 24 | 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' | |
28 | 28 | rd.options << '--diagram' |
29 | 29 | rd.options << '--fileboxes' |
30 | 30 | rd.options << '--inline-source' |
31 | 31 | rd.options << '--line-numbers' |
32 | rd.rdoc_dir = 'rdoc' | |
32 | rd.rdoc_dir = 'rdoc' | |
33 | 33 | end |
34 | 34 | |
35 | 35 | 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 | |
39 | 39 | end |
40 | 40 | |
41 | 41 | # "Gem" part of the Rakefile |
42 | 42 | begin |
43 | require 'rubygems/package_task' | |
43 | require 'rubygems/package_task' | |
44 | 44 | |
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 | |
59 | 59 | |
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 | |
64 | 64 | rescue LoadError |
65 | 65 | puts "Will not generate gem." |
66 | 66 | end |
67 | 67 | @imap_accounts = ImapAccounts::new |
68 | 68 | maildir_account = MaildirAccount::new |
69 | 69 | @conf['feeds'].each do |f| |
70 | f['name'] = f['name'].to_s | |
70 | 71 | if f['disable'].nil? |
71 | 72 | uri = URI::parse(Array(f['target']).join('')) |
72 | 73 | path = URI::unescape(uri.path) |
17 | 17 | =end |
18 | 18 | |
19 | 19 | # Feed2Imap version |
20 | F2I_VERSION = '1.2.3' | |
20 | F2I_VERSION = '1.2.4' | |
21 | 21 | F2I_WARNFETCHTIME = 10 |
22 | 22 | |
23 | 23 | require 'feed2imap/config' |
129 | 129 | # thread-safe, and we need to get the right exitcode |
130 | 130 | mutex.lock |
131 | 131 | s = %x{#{feed.execurl}} |
132 | if $?.exitstatus != 0 | |
132 | if $? && $?.exitstatus != 0 | |
133 | 133 | @logger.warn("Command for #{feed.name} exited with status #{$?.exitstatus} !") |
134 | 134 | end |
135 | 135 | mutex.unlock |
142 | 142 | # thread-safe, and we need to get the right exitcode. |
143 | 143 | mutex.lock |
144 | 144 | # 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 | |
161 | 164 | end |
162 | 165 | if Time::now - fetch_start > F2I_WARNFETCHTIME |
163 | 166 | @logger.info("Fetching feed #{feed.name} took #{(Time::now - fetch_start).to_i}s") |
53 | 53 | url: http://something |
54 | 54 | target: [ *target, "feed1" ] |
55 | 55 | 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 | |
56 | 65 | |
57 | 66 | class ConfigTest < Test::Unit::TestCase |
58 | 67 | def test_cache |
94 | 103 | assert_equal "/tmp/Maildir/feed1", conf.feeds.first.folder |
95 | 104 | end |
96 | 105 | |
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 | ||
97 | 112 | end |
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' |