Class: MessageTrain::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Generators::Utils, Rails::Generators::Migration
Defined in:
lib/generators/message_train/install/install_generator.rb

Overview

Install Generator

Instance Method Summary collapse

Methods included from Generators::Utils

#ask_for, #output

Instance Method Details

#add_initializerObject

all public methods in here will be run in order



15
16
17
18
19
20
21
22
# File 'lib/generators/message_train/install/install_generator.rb', line 15

def add_initializer
  output(
    "First, you'll need an initializer. "\
      'This is where you put your configuration options.',
    :magenta
  )
  template 'initializer.rb', 'config/initializers/message_train.rb'
end

#add_migrationsObject

Not doing this any more thanks to: blog.pivotal.io/pivotal-labs/labs/\ leave-your-migrations-in-your-rails-engines



27
28
29
30
# File 'lib/generators/message_train/install/install_generator.rb', line 27

def add_migrations
  output 'Next come migrations.', :magenta
  rake 'message_train:install:migrations'
end

#add_routeObject



32
33
34
35
36
37
38
39
40
# File 'lib/generators/message_train/install/install_generator.rb', line 32

def add_route
  output 'Adding MessageTrain to your routes.rb file', :magenta
  gsub_file(
    'config/routes.rb',
    %r{mount MessageTrain::Engine => '/.*', as: 'message_train'},
    ''
  )
  route("mount MessageTrain::Engine => '/', as: 'message_train'")
end

#goodbyeObject



42
43
44
45
46
47
48
49
# File 'lib/generators/message_train/install/install_generator.rb', line 42

def goodbye
  output(
    "Thanks for installing! Don't forget to run your migrations. "\
      'See http://gemvein.com/museum/cases/message_train for '\
      'configuration tips.',
    :magenta
  )
end

#helloObject



9
10
11
# File 'lib/generators/message_train/install/install_generator.rb', line 9

def hello
  output 'MessageTrain Installer will now install itself', :magenta
end