Sha256: 837f67a297954511dde27e957d62c0731b18a60665982d839d1da1ef6b286ceb

Contents?: true

Size: 811 Bytes

Versions: 17

Compression:

Stored size: 811 Bytes

Contents

module GhostInThePost
  class MailGhost
    attr_reader :email, :included_scripts, :timeout, :wait_event

    def initialize(email, timeout=nil, wait_event=nil, included_scripts=[])
      @email = email
      @timeout = timeout
      @wait_event = wait_event
      @included_scripts = Array(included_scripts).compact
    end

    def execute
      improve_body if email.content_type =~ /^text\/html/
      improve_html_part(email.html_part) if email.html_part
      email
    end

    private

    def improve_body
      email.body = ghost_html(email.body.decoded)
    end

    def improve_html_part(html_part)
      html_part.body = ghost_html(html_part.body.decoded)
    end

    def ghost_html(old_html)
      PhantomTransform.new(old_html, timeout, wait_event, included_scripts).transform
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ghost_in_the_post-0.1.4 lib/ghost_in_the_post/mail_ghost.rb
ghost_in_the_post-0.1.3 lib/ghost_in_the_post/mail_ghost.rb
ghost_in_the_post-0.1.2 lib/ghost_in_the_post/mail_ghost.rb
ghost_in_the_post-0.1.0 lib/ghost_in_the_post/mail_ghost.rb
ghost_in_the_post-0.0.14 lib/ghost_in_the_post/mail_ghost.rb
ghost_in_the_post-0.0.13 lib/ghost_in_the_post/mail_ghost.rb
ghost_in_the_post-0.0.12 lib/ghost_in_the_post/mail_ghost.rb
ghost_in_the_post-0.0.11 lib/ghost_in_the_post/mail_ghost.rb
ghost_in_the_post-0.0.10 lib/ghost_in_the_post/mail_ghost.rb
ghost_in_the_post-0.0.9 lib/ghost_in_the_post/mail_ghost.rb
ghost_in_the_post-0.0.8 lib/ghost_in_the_post/mail_ghost.rb
ghost_in_the_post-0.0.7 lib/ghost_in_the_post/mail_ghost.rb
ghost_in_the_post-0.0.6 lib/ghost_in_the_post/mail_ghost.rb
ghost_in_the_post-0.0.5 lib/ghost_in_the_post/mail_ghost.rb
ghost_in_the_post-0.0.4 lib/ghost_in_the_post/mail_ghost.rb
ghost_in_the_post-0.0.3 lib/ghost_in_the_post/mail_ghost.rb
ghost_in_the_post-0.0.2 lib/ghost_in_the_post/mail_ghost.rb