summaryrefslogtreecommitdiff
path: root/feed2imap-test
blob: b976bea61708111701a71b77cb599d6331fdc62e (plain)
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
#!/usr/bin/ruby

require 'fileutils'
require 'yaml'

base = File.expand_path(File.dirname(__FILE__))
tmp = File.join(base, 'tmp')

FileUtils.rm_rf(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')
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}
  - name: XKCD
    url: http://www.xkcd.com/atom.xml
    target: maildir://#{maildir}
EOF
config = File.join(tmp, 'feed2imap.yaml')
File.open(config, 'w') do |f|
  f.write(config_data)
end

system('ruby', "-I#{base}/lib", "#{base}/bin/feed2imap", '--config', config, '--verbose') || exit(1)

print "Open target maildir with mutt? [Y/n]"
response = gets.strip
if response.downcase == 'y' || response == ''
  exec('mutt', '-f', maildir)
end