Class: Ahoy::VagrantGenerator

Inherits:
Generator::Base show all
Defined in:
lib/generators/ahoy/vagrant_generator.rb

Instance Method Summary collapse

Methods inherited from Generator::Base

source_root

Instance Method Details

#backup_filesObject



43
44
45
# File 'lib/generators/ahoy/vagrant_generator.rb', line 43

def backup_files
  FileUtils.mv 'config/database.yml', 'config/database.yml.bak'
end

#copy_filesObject



39
40
41
# File 'lib/generators/ahoy/vagrant_generator.rb', line 39

def copy_files
  copy_file 'ansible_templates/playbooks/_vagrant.yml', 'config/ansible/playbooks/vagrant.yml'
end

#copy_templatesObject



47
48
49
50
# File 'lib/generators/ahoy/vagrant_generator.rb', line 47

def copy_templates
  template '_database.yml', 'config/database.yml'
  template '_Vagrantfile', 'Vagrantfile'
end

#prompt_userObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/generators/ahoy/vagrant_generator.rb', line 19

def prompt_user
  if Ahoy::VariableStore.variables['use_vagrant'] == true
    question :string do
      {
        vagrant_memory: 'How many Megabytes of memory would you like to allocate to your VM? [enter for default]',
        default: '2'
      }
    end
    question :string do
      {
        vagrant_cpus: 'How many CPUs would you like to allocated? [enter for default]',
        default: '1'
      }
    end
  else
    puts 'Skipping Vagrant'
    exit
  end
end

#use_vagrantObject



10
11
12
13
14
15
16
17
# File 'lib/generators/ahoy/vagrant_generator.rb', line 10

def use_vagrant
  question :boolean do
    {
      use_vagrant: 'Would you like to use Vagrant with your project?',
      default: 'No'
    }
  end
end