Class: Inboxer::Reporter
- Inherits:
-
Object
- Object
- Inboxer::Reporter
- Defined in:
- lib/inboxer.rb
Instance Method Summary collapse
-
#initialize(filename) ⇒ Reporter
constructor
A new instance of Reporter.
- #send! ⇒ Object
- #send_pdf! ⇒ Object
Constructor Details
#initialize(filename) ⇒ Reporter
Returns a new instance of Reporter.
12 13 14 |
# File 'lib/inboxer.rb', line 12 def initialize(filename) @yml = YAML::load(File.open(filename)) end |
Instance Method Details
#send! ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/inboxer.rb', line 16 def send! @yml.each do |report| premailer = Premailer.new(report['URL'], :warn_level => Premailer::Warnings::SAFE) report['Recipients'].each do |email| Pony.mail(:to => email, :from => report['From'], :subject => report['Subject'], :html_body => premailer.to_inline_css, :headers => {'X-Software' => 'Inboxer'} ) end end end |
#send_pdf! ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/inboxer.rb', line 28 def send_pdf! @yml.each do |report| report['Recipients'].each do |email| script = File.('../rasterize.js', __FILE__) file = "/tmp/output.#{rand(36**8).to_s(36)}.pdf" output = Phantomjs.run(script, report['URL'], file) Pony.mail(:to => email, :from => report['From'], :subject => report['Subject'], :body => report['Content'], :attachments => {'report.pdf' => File.read(file)}, :headers => {'X-Software' => 'Inboxer'} ) end end end |