1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#!/usr/bin/ruby
require 'fileutils'
require 'yaml'
base = File.expand_path(File.dirname(__FILE__))
tmp = File.join(base, 'tmp')
FileUtils.mkdir_p(tmp)
# target maildir
maildir = File.join(tmp,'Mail')
FileUtils.mkdir_p(File.join(maildir, 'new'))
FileUtils.mkdir_p(File.join(maildir, 'cur'))
FileUtils.mkdir_p(File.join(maildir, 'tmp'))
cache = File.join(tmp, 'cache')
case ARGV.length
when 0
config_data = <<EOF
cache: #{cache}
feeds:
- name: CNPQ
url: http://www.cnpq.br/web/guest/noticias/-/asset_publisher/6QsO/rss?p_p_cacheability=cacheLevelPage
target: maildir://#{maildir}
filter: /bin/cat
- name: Planet Debian (broken filter)
url: http://planet.debian.org/atom.xml
target: maildir://#{maildir}
filter: /bin/epicfail
- name: XKCD
url: http://www.xkcd.com/atom.xml
target: maildir://#{maildir}
EOF
when 1
config_data = <<EOF
cache: #{cache}
feeds:
- name: Test
url: #{ARGV.first}
target: maildir://#{maildir}
EOF
else
puts("usage: %s [FEED]" % $PROGRAM_NAME)
exit(1)
end
config = File.join(tmp, 'feed2imap.yaml')
File.open(config, 'w') do |f|
f.write(config_data)
end
FileUtils.chmod 0600, config
unless system('ruby', "-I#{base}/lib", "#{base}/bin/feed2imap", '--config', config, '--verbose')
puts("E: feed2imap failed")
exit(1)
end
print "Open target maildir with mutt? [Y/n]"
response = $stdin.gets.strip
if response.downcase == 'y' || response == ''
exec('mutt', '-f', maildir)
end
|