class MailDaemon::EmailBodyParser
Public Class Methods
parse(text, type="text/plain")
click to toggle source
# File lib/mail_daemon/email_body_parser.rb, line 5 def self.parse(text, type="text/plain") data_hash = {:body => text, :type => type} json_hash = data_hash.to_json stdin, stdout, stderr, wait_thr = Open3.popen3('python', '/Users/stewartmckee/code/talon/test.py') stdin.write(json_hash) stdin.close result = stdout.read stdout.close error = stderr.read stderr.close exit_code = wait_thr.value if exit_code == 0 result else puts result if @options[:debug] raise error end end