Class: Mail2cb::EmailBodyCleanser

Inherits:
Object
  • Object
show all
Defined in:
lib/mail2cb/email_body_cleanser.rb

Class Method Summary collapse

Class Method Details

.parse(text, type = "text/plain") ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/mail2cb/email_body_cleanser.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
    raise error
  end
end