lib/railsthemes/email_installer.rb in railsthemes-1.2.0 vs lib/railsthemes/email_installer.rb in railsthemes-2.0.0.pre
- old
+ new
@@ -1,87 +1,26 @@
module Railsthemes
- class EmailInstaller < Thor
- no_tasks do
- include Railsthemes::Logging
- include Thor::Actions
+ class EmailInstaller
+ include Railsthemes::Logging
- def install_from_file_system original_source_filepath
- logger.warn 'Installing email theme...'
- source_filepath = original_source_filepath.gsub(/\\/, '/')
- logger.info "Source filepath: #{source_filepath}"
+ def install
+ logger.warn 'Installing email...'
- if File.directory?(source_filepath)
- install_from_directory source_filepath
- elsif Utils.archive?(source_filepath + '.tar.gz')
- install_from_archive source_filepath + '.tar.gz'
- end
- end
+ install_mail_gems_if_necessary
- def install_from_directory source_filepath
- Dir["#{source_filepath}/email/**/*"].each do |src|
- logger.debug "src: #{src}"
- dest = src.sub("#{source_filepath}/email/", '')
- logger.debug "dest: #{dest}"
- if File.directory?(src)
- unless File.directory?(dest)
- logger.debug "mkdir -p #{dest}"
- FileUtils.mkdir_p(dest)
- end
- else
- unless src =~ /\/\./ # remove any pesky hidden files that crept into the archive
- logger.debug "cp #{src} #{dest}"
- FileUtils.cp(src, dest)
- end
- end
- end
+ logger.warn 'Done installing email.'
+ end
- inject_into_file File.join('app', 'controllers', 'railsthemes_controller.rb'), :after => 'class RailsthemesController < ApplicationController', :verbose => false do
-<<-EOS
-
-def email
-end
-
-def send_email
- RailsthemesMailer.test_email(:to => params[:email]).deliver
- render :sent_email
-end
-EOS
+ def install_mail_gems_if_necessary
+ gem_names = Utils.gemspecs.map(&:name)
+ logger.debug "gem_names: #{gem_names}"
+ unless gem_names.include?('premailer-rails')
+ if (gem_names & ['hpricot', 'nokogiri']).empty?
+ Utils.add_gem_to_gemfile 'hpricot'
end
-
- Utils.conditionally_insert_routes({
- 'railsthemes/email' => 'railsthemes#email',
- 'railsthemes/send_email' => 'railsthemes#send_email'
- })
-
- install_mail_gems_if_necessary
-
- create_file File.join('config', 'initializers', 'premailer.rb'), :verbose => false do
- "PremailerRails.config.merge(:input_encoding => 'UTF-8', :generate_text_part => true)"
- end
-
- logger.warn 'Done installing email theme.'
+ logger.warn 'Installing assistant mail gems...'
+ Utils.add_gem_to_gemfile 'premailer-rails'
+ logger.warn 'Done installing assistant mail gems.'
end
-
- def install_mail_gems_if_necessary
- gem_names = Utils.gemspecs.map(&:name)
- logger.debug "gem_names: #{gem_names}"
- unless gem_names.include?('premailer-rails3')
- if (gem_names & ['hpricot', 'nokogiri']).empty?
- Utils.add_gem_to_gemfile 'hpricot'
- end
- Utils.add_gem_to_gemfile 'premailer-rails3'
- logger.warn 'Installing assistant mail gems...'
- Safe.system_call 'bundle'
- logger.warn 'Done installing assistant mail gems.'
- end
- end
-
- def install_from_archive filepath
- Railsthemes::Utils.with_tempdir do |tempdir|
- Utils.unarchive filepath, tempdir
- install_from_file_system tempdir
- end
- end
-
end
end
end