Sha256: 210d50efa7e421501f06041e0e0e1798b386c5a80f1493389f5d72fdd90ee771

Contents?: true

Size: 679 Bytes

Versions: 1

Compression:

Stored size: 679 Bytes

Contents

module GhostInThePost
  class MailGhost
    attr_reader :email, :included_scripts

    def initialize(email, included_scripts)
      @email = email
      @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, included_scripts).transform
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ghost_in_the_post-0.0.1 lib/ghost_in_the_post/mail_ghost.rb