/lib/heliotrope.rb

https://github.com/bdimcheff/heliotrope · Ruby · 42 lines · 35 code · 5 blank · 2 comment · 0 complexity · 5b0b808e3d902036f2b8dad3453751a1 MD5 · raw file

  1. module Heliotrope
  2. ## ruby 1.9 versions of this don't work with Timeout::timeout, so
  3. ## we use this ruby 1.8 backport.
  4. def popen3(*cmd)
  5. pw, pr, pe = IO::pipe, IO::pipe, IO::pipe # [0] = read, [1] = write
  6. pid = fork do
  7. fork do
  8. pw[1].close; STDIN.reopen pw[0]; pw[0].close
  9. pr[0].close; STDOUT.reopen pr[1]; pr[1].close
  10. pe[0].close; STDERR.reopen pe[1]; pe[1].close
  11. exec(*cmd)
  12. end
  13. exit!(0)
  14. end
  15. pw[0].close; pr[1].close; pe[1].close
  16. Process.waitpid pid
  17. pi = [pw[1], pr[0], pe[0]]
  18. pw[1].sync = true
  19. begin
  20. yield(*pi)
  21. ensure
  22. pi.each { |p| p.close unless p.closed? }
  23. end
  24. end
  25. module_function :popen3
  26. end
  27. require "heliotrope/decoder"
  28. require "heliotrope/person"
  29. require "heliotrope/message"
  30. require "heliotrope/mbox-splitter"
  31. require "heliotrope/imap-dumper"
  32. require "heliotrope/gmail-dumper"
  33. require "heliotrope/maildir-walker"
  34. require "heliotrope/meta-index"
  35. require "heliotrope/zmbox"
  36. require "heliotrope/query"
  37. require "heliotrope/hooks"