Sha256: 223378617da610d0347310b3e7d19d6701ff8c76883d01e65133f6304d53c96f

Contents?: true

Size: 1.34 KB

Versions: 16

Compression:

Stored size: 1.34 KB

Contents

module HtmlEmailCreator
  class EmailCreator
    def create_email(file_or_configuration, format)
      email(file_or_configuration).render_only(format)
    end

    def create_html_email(file_or_configuration)
      email(file_or_configuration).render_html_email
    end

    def create_plain_text_email(file_or_configuration)
      email(file_or_configuration).render_plain_text_email
    end

    def create_all_email_versions(file_or_configuration)
      email(file_or_configuration).render_all
    end

    def save_email(file_or_configuration)
      formats_and_paths = {}
      create_all_email_versions(file_or_configuration).each_value do |version|
        formats_and_paths[version.id] = version.save
      end
      formats_and_paths
    end

    def save_emails(file_or_directory, recursively = false)
      files = {}
      HtmlEmailCreator::Email.find_emails(file_or_directory, recursively).each do |file|
        files[file] = save_email(file)
      end
      files
    end
    
    private
    
    def email(file_or_configuration)
      if file_or_configuration.kind_of?(String)
        # Is file so update settings before creating email (makes sure that we have the latest settings file)
        HtmlEmailCreator.update_settings(File.dirname(file_or_configuration))
      end
      Email.new(file_or_configuration, HtmlEmailCreator.settings)
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
html_email_creator-1.0.18 lib/html_email_creator/email_creator.rb
html_email_creator-1.0.16 lib/html_email_creator/email_creator.rb
html_email_creator-1.0.15 lib/html_email_creator/email_creator.rb
html_email_creator-1.0.14 lib/html_email_creator/email_creator.rb
html_email_creator-1.0.13 lib/html_email_creator/email_creator.rb
html_email_creator-1.0.10 lib/html_email_creator/email_creator.rb
html_email_creator-1.0.9 lib/html_email_creator/email_creator.rb
html_email_creator-1.0.8 lib/html_email_creator/email_creator.rb
html_email_creator-1.0.7 lib/html_email_creator/email_creator.rb
html_email_creator-1.0.6 lib/html_email_creator/email_creator.rb
html_email_creator-1.0.5 lib/html_email_creator/email_creator.rb
html_email_creator-1.0.4 lib/html_email_creator/email_creator.rb
html_email_creator-1.0.3 lib/html_email_creator/email_creator.rb
html_email_creator-1.0.2 lib/html_email_creator/email_creator.rb
html_email_creator-1.0.1 lib/html_email_creator/email_creator.rb
html_email_creator-1.0.0 lib/html_email_creator/email_creator.rb