Class: EffectiveEmailTemplates::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/effective_email_templates/install_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/generators/effective_email_templates/install_generator.rb', line 10

def self.next_migration_number(dirname)
  unless ActiveRecord::Base.timestamped_migrations
    Time.new.utc.strftime("%Y%m%d%H%M%S")
  else
    "%.3d" % (current_migration_number(dirname) + 1)
  end
end

Instance Method Details

#copy_initializerObject



18
19
20
# File 'lib/generators/effective_email_templates/install_generator.rb', line 18

def copy_initializer
  template ('../' * 3) + 'config/effective_email_templates.rb', 'config/initializers/effective_email_templates.rb'
end

#copy_liquidObject



26
27
28
# File 'lib/generators/effective_email_templates/install_generator.rb', line 26

def copy_liquid
  template ('../' * 3) + 'config/welcome.liquid', 'app/views/email_templates_mailer/welcome.liquid'
end

#copy_mailerObject



22
23
24
# File 'lib/generators/effective_email_templates/install_generator.rb', line 22

def copy_mailer
  template ('../' * 3) + 'config/email_templates_mailer.rb', 'app/mailers/email_templates_mailer.rb'
end

#copy_previewObject



30
31
32
# File 'lib/generators/effective_email_templates/install_generator.rb', line 30

def copy_preview
  template ('../' * 3) + 'config/email_templates_mailer_preview.rb', 'test/mailers/previews/email_templates_mailer_preview.rb'
end

#create_migration_fileObject



34
35
36
# File 'lib/generators/effective_email_templates/install_generator.rb', line 34

def create_migration_file
  migration_template ('../' * 3) + 'db/migrate/101_create_effective_email_templates.rb', 'db/migrate/create_effective_email_templates.rb'
end

#messageObject



38
39
40
# File 'lib/generators/effective_email_templates/install_generator.rb', line 38

def message
  puts("Please run rake db:migrate and rake effective_email_templates:import")
end